[clang-tools-extra] [clangd] Report reference to UsingType's target decl at the correct location (PR #186310)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 15 23:20:16 PDT 2026
https://github.com/HighCommander4 updated https://github.com/llvm/llvm-project/pull/186310
>From dc858a212c1ea42c6b761694761dea0a6b0f9849 Mon Sep 17 00:00:00 2001
From: Nathan Ridge <zeratul976 at hotmail.com>
Date: Fri, 13 Mar 2026 00:16:06 -0400
Subject: [PATCH] [clangd] Report reference to UsingType's target decl at the
correct location
Fixes https://github.com/clangd/clangd/issues/2617
---
clang-tools-extra/clangd/FindTarget.cpp | 4 ++--
.../clangd/unittests/SemanticHighlightingTests.cpp | 8 +++++++-
2 files changed, 9 insertions(+), 3 deletions(-)
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