diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -574,6 +574,10 @@ } namespace { + +llvm::SmallVector refInTypeLoc(TypeLoc L, + const HeuristicResolver *Resolver); + llvm::SmallVector refInDecl(const Decl *D, const HeuristicResolver *Resolver) { struct Visitor : ConstDeclVisitor { @@ -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. diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp --- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ b/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.