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.


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.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to