Skip to content

Commit 9062cf5

Browse files
[clangd] Report reference to UsingType's target decl at the correct location (llvm#186310)
Fixes clangd/clangd#2617
1 parent e7041d4 commit 9062cf5

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,14 +845,14 @@ refInTypeLoc(TypeLoc L, const HeuristicResolver *Resolver) {
845845

846846
void VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc L) {
847847
Refs.push_back(ReferenceLoc{L.getQualifierLoc(),
848-
L.getLocalSourceRange().getBegin(),
848+
L.getNameLoc(),
849849
/*IsDecl=*/false,
850850
{L.getDecl()}});
851851
}
852852

853853
void VisitUsingTypeLoc(UsingTypeLoc L) {
854854
Refs.push_back(ReferenceLoc{L.getQualifierLoc(),
855-
L.getLocalSourceRange().getBegin(),
855+
L.getNameLoc(),
856856
/*IsDecl=*/false,
857857
{L.getDecl()}});
858858
}

clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,13 @@ sizeof...($TemplateParameter[[Elements]]);
11001100
struct $Class_def[[Inner]] {};
11011101
};
11021102
using $Typedef_decl[[Alias]] = void ($Class[[Outer]]::$Class[[Inner]]:: *)();
1103-
)cpp"};
1103+
)cpp",
1104+
// Forwarded typedef
1105+
R"cpp(
1106+
using $Primitive_decl[[MyInt]] = int;
1107+
namespace $Namespace_decl[[N]] { using ::MyInt; }
1108+
using $Primitive_decl[[X]] = $Namespace[[N]]::$Primitive[[MyInt]];
1109+
)cpp"};
11041110
for (const auto &TestCase : TestCases)
11051111
// Mask off scope modifiers to keep the tests manageable.
11061112
// They're tested separately.

0 commit comments

Comments
 (0)