[clang] 36011bd - Rename API to not be constrained to template instantiations

Stephen Kelly via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 17 08:29:23 PST 2020


Author: Stephen Kelly
Date: 2020-11-17T16:28:59Z
New Revision: 36011bdfb6486217c45f1b0c7739c1c356ad9592

URL: https://github.com/llvm/llvm-project/commit/36011bdfb6486217c45f1b0c7739c1c356ad9592
DIFF: https://github.com/llvm/llvm-project/commit/36011bdfb6486217c45f1b0c7739c1c356ad9592.diff

LOG: Rename API to not be constrained to template instantiations

A follow-up commit will use this method to ignore implcit AST nodes.

Added: 
    

Modified: 
    clang/include/clang/ASTMatchers/ASTMatchersInternal.h
    clang/lib/ASTMatchers/ASTMatchFinder.cpp
    clang/lib/ASTMatchers/ASTMatchersInternal.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 81c7222810671..74057e24c3b5d 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1060,7 +1060,7 @@ class ASTMatchFinder {
 
   virtual ASTContext &getASTContext() const = 0;
 
-  virtual bool IsMatchingInTemplateInstantiationNotSpelledInSource() const = 0;
+  virtual bool IsMatchingInASTNodeNotSpelledInSource() const = 0;
 
   bool isTraversalIgnoringImplicitNodes() const;
 

diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index e3723bb20dd2d..cb282c9225fb6 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -497,7 +497,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
                           const DynTypedMatcher &Matcher,
                           BoundNodesTreeBuilder *Builder, int MaxDepth,
                           TraversalKind Traversal, BindKind Bind) {
-    bool ScopedTraversal = TraversingTemplateInstantiationNotSpelledInSource;
+    bool ScopedTraversal = TraversingASTNodeNotSpelledInSource;
 
     if (const auto *CTSD = Node.get<ClassTemplateSpecializationDecl>()) {
       int SK = CTSD->getSpecializationKind();
@@ -506,7 +506,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
         ScopedTraversal = true;
     }
 
-    TemplateInstantiationNotSpelledInSourceScope RAII(this, ScopedTraversal);
+    ASTNodeNotSpelledInSourceScope RAII(this, ScopedTraversal);
 
     MatchChildASTVisitor Visitor(
       &Matcher, this, Builder, MaxDepth, Traversal, Bind);
@@ -592,38 +592,38 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
   bool shouldVisitTemplateInstantiations() const { return true; }
   bool shouldVisitImplicitCode() const { return true; }
 
-  bool IsMatchingInTemplateInstantiationNotSpelledInSource() const override {
-    return TraversingTemplateInstantiationNotSpelledInSource;
+  bool IsMatchingInASTNodeNotSpelledInSource() const override {
+    return TraversingASTNodeNotSpelledInSource;
   }
 
   bool TraverseTemplateInstantiations(ClassTemplateDecl *D) {
-    TemplateInstantiationNotSpelledInSourceScope RAII(this, true);
+    ASTNodeNotSpelledInSourceScope RAII(this, true);
     return RecursiveASTVisitor<MatchASTVisitor>::TraverseTemplateInstantiations(
         D);
   }
 
   bool TraverseTemplateInstantiations(VarTemplateDecl *D) {
-    TemplateInstantiationNotSpelledInSourceScope RAII(this, true);
+    ASTNodeNotSpelledInSourceScope RAII(this, true);
     return RecursiveASTVisitor<MatchASTVisitor>::TraverseTemplateInstantiations(
         D);
   }
 
   bool TraverseTemplateInstantiations(FunctionTemplateDecl *D) {
-    TemplateInstantiationNotSpelledInSourceScope RAII(this, true);
+    ASTNodeNotSpelledInSourceScope RAII(this, true);
     return RecursiveASTVisitor<MatchASTVisitor>::TraverseTemplateInstantiations(
         D);
   }
 
 private:
-  bool TraversingTemplateInstantiationNotSpelledInSource = false;
+  bool TraversingASTNodeNotSpelledInSource = false;
 
-  struct TemplateInstantiationNotSpelledInSourceScope {
-    TemplateInstantiationNotSpelledInSourceScope(MatchASTVisitor *V, bool B)
-        : MV(V), MB(V->TraversingTemplateInstantiationNotSpelledInSource) {
-      V->TraversingTemplateInstantiationNotSpelledInSource = B;
+  struct ASTNodeNotSpelledInSourceScope {
+    ASTNodeNotSpelledInSourceScope(MatchASTVisitor *V, bool B)
+        : MV(V), MB(V->TraversingASTNodeNotSpelledInSource) {
+      V->TraversingASTNodeNotSpelledInSource = B;
     }
-    ~TemplateInstantiationNotSpelledInSourceScope() {
-      MV->TraversingTemplateInstantiationNotSpelledInSource = MB;
+    ~ASTNodeNotSpelledInSourceScope() {
+      MV->TraversingASTNodeNotSpelledInSource = MB;
     }
 
   private:

diff  --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 874752bf2f7d9..215afcd29b647 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -290,7 +290,7 @@ bool DynTypedMatcher::matches(const DynTypedNode &DynNode,
                           Implementation->TraversalKind());
 
   if (Finder->isTraversalIgnoringImplicitNodes() &&
-      Finder->IsMatchingInTemplateInstantiationNotSpelledInSource())
+      Finder->IsMatchingInASTNodeNotSpelledInSource())
     return false;
 
   auto N =
@@ -314,7 +314,7 @@ bool DynTypedMatcher::matchesNoKindCheck(const DynTypedNode &DynNode,
                           Implementation->TraversalKind());
 
   if (Finder->isTraversalIgnoringImplicitNodes() &&
-      Finder->IsMatchingInTemplateInstantiationNotSpelledInSource())
+      Finder->IsMatchingInASTNodeNotSpelledInSource())
     return false;
 
   auto N =


        


More information about the cfe-commits mailing list