[clang-tools-extra] 9062cf5 - [clangd] Report reference to UsingType's target decl at the correct location (#186310)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 15 23:28:57 PDT 2026
Author: Nathan Ridge
Date: 2026-03-16T06:28:51Z
New Revision: 9062cf5039c637a3f0122cea581c5477236e3303
URL: https://github.com/llvm/llvm-project/commit/9062cf5039c637a3f0122cea581c5477236e3303
DIFF: https://github.com/llvm/llvm-project/commit/9062cf5039c637a3f0122cea581c5477236e3303.diff
LOG: [clangd] Report reference to UsingType's target decl at the correct location (#186310)
Fixes https://github.com/clangd/clangd/issues/2617
Added:
Modified:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp
index f80f7325d17ae..064e0db3b5b14 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -845,14 +845,14 @@ refInTypeLoc(TypeLoc L, const HeuristicResolver *Resolver) {
void VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc L) {
Refs.push_back(ReferenceLoc{L.getQualifierLoc(),
- L.getLocalSourceRange().getBegin(),
+ L.getNameLoc(),
/*IsDecl=*/false,
{L.getDecl()}});
}
void VisitUsingTypeLoc(UsingTypeLoc L) {
Refs.push_back(ReferenceLoc{L.getQualifierLoc(),
- L.getLocalSourceRange().getBegin(),
+ L.getNameLoc(),
/*IsDecl=*/false,
{L.getDecl()}});
}
diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 94cecce1f038c..782221306bf85 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -1100,7 +1100,13 @@ sizeof...($TemplateParameter[[Elements]]);
struct $Class_def[[Inner]] {};
};
using $Typedef_decl[[Alias]] = void ($Class[[Outer]]::$Class[[Inner]]:: *)();
- )cpp"};
+ )cpp",
+ // Forwarded typedef
+ R"cpp(
+ using $Primitive_decl[[MyInt]] = int;
+ namespace $Namespace_decl[[N]] { using ::MyInt; }
+ using $Primitive_decl[[X]] = $Namespace[[N]]::$Primitive[[MyInt]];
+ )cpp"};
for (const auto &TestCase : TestCases)
// Mask off scope modifiers to keep the tests manageable.
// They're tested separately.
More information about the cfe-commits
mailing list