[PATCH] D80961: [clang][AST] Ignore template instantiations if not in AsIs mode

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 05:34:36 PST 2020


aaron.ballman added a comment.

In D80961#2353384 <https://reviews.llvm.org/D80961#2353384>, @steveire wrote:

> Many of the changes which were part of a previous iteration of this change were related to the change of default behavior of matchers. As the default is no longer changed, those changes fell away.

Indeed! Thank you for continuing on this. Aside from a few small nits, I think this LGTM.



================
Comment at: clang/include/clang/AST/ASTNodeTraverser.h:485
 
-    for (const auto *Child : D->specializations())
-      dumpTemplateDeclSpecialization(Child);
+    if (Traversal == TK_AsIs)
+      for (const auto *Child : D->specializations())
----------------
Any interest in using curly braces here for readability?


================
Comment at: clang/lib/AST/ASTDumper.cpp:132
 
-  for (const auto *Child : D->specializations())
-    dumpTemplateDeclSpecialization(Child, DumpExplicitInst,
-                                   !D->isCanonicalDecl());
+  if (GetTraversalKind() == TK_AsIs)
+    for (const auto *Child : D->specializations())
----------------
Any interest in using curly braces here for readability?


================
Comment at: clang/lib/ASTMatchers/ASTMatchersInternal.cpp:287-289
+  if (Finder->getASTContext().getParentMapContext().getTraversalKind() ==
+      TK_IgnoreUnlessSpelledInSource) {
+    if (Finder->isMatchingInImplicitTemplateInstantiation()) {
----------------
You can combine these into a single `if` statement (and then elide the braces).


================
Comment at: clang/lib/ASTMatchers/ASTMatchersInternal.cpp:314
 
+  if (Finder->getASTContext().getParentMapContext().getTraversalKind() ==
+      TK_IgnoreUnlessSpelledInSource) {
----------------
Same here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80961



More information about the cfe-commits mailing list