[PATCH] D111224: [clang] Traverse enum integer-base specifiers in RAV

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 6 07:03:32 PDT 2021


hokein added a comment.

the RAV change looks good.

I think it might be worth to split this patch (one for RAV, one for libindex).



================
Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:1866
 
+  if (auto *TSI = D->getIntegerTypeSourceInfo())
+    TRY_TO(TraverseTypeLoc(TSI->getTypeLoc()));
----------------
we have unittests for RAV, they are in `clang/unittests/Tooling/RecursiveASTVisitorTests/`, but unfortunately, we don't have one for enum decl, we can create one.


================
Comment at: clang/lib/Index/IndexTypeSourceInfo.cpp:310
         }
+      } else if (auto *ED = dyn_cast<EnumDecl>(D)) {
+        if (auto *TSI = ED->getIntegerTypeSourceInfo())
----------------
this seem to work if the D is a definition, I think it won't report the reference if the enum decl is a declaration.

```
 typedef int MyTypedef;
 enum Foo : MyTypedef;
```


================
Comment at: clang/unittests/Index/IndexTests.cpp:387
+  tooling::runToolOnCode(std::make_unique<IndexAction>(Index), Code);
+  // A should not be the base of anything.
+  EXPECT_THAT(Index->Symbols,
----------------
This seems to be a copy-paste error.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111224/new/

https://reviews.llvm.org/D111224



More information about the cfe-commits mailing list