[PATCH] D100516: [AST] Add TypeLoc support to node introspection

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 17 03:51:22 PDT 2021


njames93 accepted this revision.
njames93 added a comment.
This revision is now accepted and ready to land.

LGTM, just a few nits before landing please.



================
Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp:172-176
+      if (TypeLocBase && Node->getName() == "getLocalSourceRange")
+        continue;
+      if ((ASTClass->getName() == "PointerLikeTypeLoc" ||
+           ASTClass->getName() == "TypeofLikeTypeLoc") &&
+          Node->getName() == "getLocalSourceRange")
----------------
njames93 wrote:
> Can we have a comment explaining why we are discarding these?
nit: can this be addressed?


================
Comment at: clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp:25
   Finder->addMatcher(
-      cxxRecordDecl(
-          isDefinition(),
-          isSameOrDerivedFrom(
-              // TODO: Extend this with other clades
-              namedDecl(hasAnyName("clang::Stmt", "clang::Decl",
-                                   "clang::CXXCtorInitializer",
-                                   "clang::NestedNameSpecifierLoc",
-                                   "clang::TemplateArgumentLoc",
-                                   "clang::CXXBaseSpecifier"))
-                  .bind("nodeClade")),
-          optionally(isDerivedFrom(cxxRecordDecl().bind("derivedFrom"))))
-          .bind("className"),
+      traverse(
+          TK_IgnoreUnlessSpelledInSource,
----------------
nit: Is it not easier to just override `getCheckTraversalKind` for the class?


================
Comment at: clang/unittests/Introspection/IntrospectionTest.cpp:209-210
+  EXPECT_EQ(
+      ExpectedLocations,
+      (std::vector<std::pair<std::string, SourceLocation>>{
+STRING_LOCATION_STDPAIR(MethodDecl, getBeginLoc()),
----------------
nit: Don't create a vector here unnecessarily, same below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100516



More information about the cfe-commits mailing list