[PATCH] D111120: [clangd] Find explicit references in the base-specifier of an enum declPartially fixes https://github.com/clangd/clangd/issues/878
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 4 23:50:57 PDT 2021
nridge created this revision.
nridge added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111120
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -729,6 +729,11 @@
}
};
)cpp",
+ // Enum base specifier
+ R"cpp(
+ using $Primitive_decl[[MyTypedef]] = int;
+ enum $Enum_decl[[MyEnum]] : $Primitive[[MyTypedef]] {};
+ )cpp",
};
for (const auto &TestCase : TestCases)
// Mask off scope modifiers to keep the tests manageable.
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -574,6 +574,10 @@
}
namespace {
+
+llvm::SmallVector<ReferenceLoc> refInTypeLoc(TypeLoc L,
+ const HeuristicResolver *Resolver);
+
llvm::SmallVector<ReferenceLoc> refInDecl(const Decl *D,
const HeuristicResolver *Resolver) {
struct Visitor : ConstDeclVisitor<Visitor> {
@@ -610,6 +614,16 @@
{D->getAliasedNamespace()}});
}
+ void VisitEnumDecl(const EnumDecl *ED) {
+ VisitNamedDecl(ED);
+ // FIXME: Should RecursiveASTVisitor be visiting this TypeLoc instead? (It
+ // doesn't).
+ if (TypeSourceInfo *BaseType = ED->getIntegerTypeSourceInfo()) {
+ llvm::copy(refInTypeLoc(BaseType->getTypeLoc(), Resolver),
+ std::back_inserter(Refs));
+ }
+ }
+
void VisitNamedDecl(const NamedDecl *ND) {
// We choose to ignore {Class, Function, Var, TypeAlias}TemplateDecls. As
// as their underlying decls, covering the same range, will be visited.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111120.377095.patch
Type: text/x-patch
Size: 1877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211005/d993a045/attachment.bin>
More information about the cfe-commits
mailing list