Author: Stephen Kelly Date: 2020-11-17T16:28:59Z New Revision: 019723fc295b692af31ced0d8e5c3c1736117de9
URL: https://github.com/llvm/llvm-project/commit/019723fc295b692af31ced0d8e5c3c1736117de9 DIFF: https://github.com/llvm/llvm-project/commit/019723fc295b692af31ced0d8e5c3c1736117de9.diff LOG: Invert accessor for checking traversal mode For now, there is a traversal mode which ignores implicit casts and parenthesis. Invert the check in order to not obviously break that. 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 2c2e67ace1575..81c7222810671 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -1062,7 +1062,7 @@ class ASTMatchFinder { virtual bool IsMatchingInTemplateInstantiationNotSpelledInSource() const = 0; - bool isTraversalAsIs() const; + bool isTraversalIgnoringImplicitNodes() const; protected: virtual bool matchesChildOf(const DynTypedNode &Node, ASTContext &Ctx, diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp index 33dd45d434236..e3723bb20dd2d 100644 --- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp @@ -153,7 +153,7 @@ class MatchChildASTVisitor Stmt *StmtToTraverse = StmtNode; if (auto *ExprNode = dyn_cast_or_null<Expr>(StmtNode)) { auto *LambdaNode = dyn_cast_or_null<LambdaExpr>(StmtNode); - if (LambdaNode && !Finder->isTraversalAsIs()) + if (LambdaNode && Finder->isTraversalIgnoringImplicitNodes()) StmtToTraverse = LambdaNode; else StmtToTraverse = @@ -230,7 +230,7 @@ class MatchChildASTVisitor return traverse(TAL); } bool TraverseLambdaExpr(LambdaExpr *Node) { - if (Finder->isTraversalAsIs()) + if (!Finder->isTraversalIgnoringImplicitNodes()) return VisitorBase::TraverseLambdaExpr(Node); if (!Node) return true; diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp index b7044cd23ffeb..874752bf2f7d9 100644 --- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -191,8 +191,9 @@ class DynTraversalMatcherImpl : public DynMatcherInterface { static llvm::ManagedStatic<TrueMatcherImpl> TrueMatcherInstance; -bool ASTMatchFinder::isTraversalAsIs() const { - return getASTContext().getParentMapContext().getTraversalKind() == TK_AsIs; +bool ASTMatchFinder::isTraversalIgnoringImplicitNodes() const { + return getASTContext().getParentMapContext().getTraversalKind() == + TK_IgnoreUnlessSpelledInSource; } DynTypedMatcher @@ -288,7 +289,7 @@ bool DynTypedMatcher::matches(const DynTypedNode &DynNode, TraversalKindScope RAII(Finder->getASTContext(), Implementation->TraversalKind()); - if (!Finder->isTraversalAsIs() && + if (Finder->isTraversalIgnoringImplicitNodes() && Finder->IsMatchingInTemplateInstantiationNotSpelledInSource()) return false; @@ -312,7 +313,7 @@ bool DynTypedMatcher::matchesNoKindCheck(const DynTypedNode &DynNode, TraversalKindScope raii(Finder->getASTContext(), Implementation->TraversalKind()); - if (!Finder->isTraversalAsIs() && + if (Finder->isTraversalIgnoringImplicitNodes() && Finder->IsMatchingInTemplateInstantiationNotSpelledInSource()) return false; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits