steveire created this revision. steveire added a reviewer: aaron.ballman. Herald added a project: clang. Herald added a subscriber: cfe-commits. steveire requested review of this revision.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D91144 Files: clang/include/clang/ASTMatchers/ASTMatchersInternal.h clang/lib/ASTMatchers/ASTMatchFinder.cpp clang/lib/ASTMatchers/ASTMatchersInternal.cpp Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -191,6 +191,10 @@ static llvm::ManagedStatic<TrueMatcherImpl> TrueMatcherInstance; +bool ASTMatchFinder::isTraversalAsIs() const { + return getASTContext().getParentMapContext().getTraversalKind() == TK_AsIs; +} + DynTypedMatcher DynTypedMatcher::constructVariadic(DynTypedMatcher::VariadicOperator Op, ASTNodeKind SupportedKind, @@ -284,8 +288,7 @@ TraversalKindScope RAII(Finder->getASTContext(), Implementation->TraversalKind()); - if (Finder->getASTContext().getParentMapContext().getTraversalKind() == - TK_IgnoreUnlessSpelledInSource && + if (!Finder->isTraversalAsIs() && Finder->IsMatchingInTemplateInstantiationNotSpelledInSource()) return false; @@ -309,8 +312,7 @@ TraversalKindScope raii(Finder->getASTContext(), Implementation->TraversalKind()); - if (Finder->getASTContext().getParentMapContext().getTraversalKind() == - TK_IgnoreUnlessSpelledInSource && + if (!Finder->isTraversalAsIs() && Finder->IsMatchingInTemplateInstantiationNotSpelledInSource()) return false; Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp =================================================================== --- clang/lib/ASTMatchers/ASTMatchFinder.cpp +++ clang/lib/ASTMatchers/ASTMatchFinder.cpp @@ -153,9 +153,7 @@ Stmt *StmtToTraverse = StmtNode; if (auto *ExprNode = dyn_cast_or_null<Expr>(StmtNode)) { auto *LambdaNode = dyn_cast_or_null<LambdaExpr>(StmtNode); - if (LambdaNode && - Finder->getASTContext().getParentMapContext().getTraversalKind() == - TK_IgnoreUnlessSpelledInSource) + if (LambdaNode && !Finder->isTraversalAsIs()) StmtToTraverse = LambdaNode; else StmtToTraverse = @@ -232,8 +230,7 @@ return traverse(TAL); } bool TraverseLambdaExpr(LambdaExpr *Node) { - if (Finder->getASTContext().getParentMapContext().getTraversalKind() != - TK_IgnoreUnlessSpelledInSource) + if (!Finder->isTraversalAsIs()) return VisitorBase::TraverseLambdaExpr(Node); if (!Node) return true; Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h =================================================================== --- clang/include/clang/ASTMatchers/ASTMatchersInternal.h +++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -1062,6 +1062,8 @@ virtual bool IsMatchingInTemplateInstantiationNotSpelledInSource() const = 0; + bool isTraversalAsIs() const; + protected: virtual bool matchesChildOf(const DynTypedNode &Node, ASTContext &Ctx, const DynTypedMatcher &Matcher,
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp =================================================================== --- clang/lib/ASTMatchers/ASTMatchersInternal.cpp +++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp @@ -191,6 +191,10 @@ static llvm::ManagedStatic<TrueMatcherImpl> TrueMatcherInstance; +bool ASTMatchFinder::isTraversalAsIs() const { + return getASTContext().getParentMapContext().getTraversalKind() == TK_AsIs; +} + DynTypedMatcher DynTypedMatcher::constructVariadic(DynTypedMatcher::VariadicOperator Op, ASTNodeKind SupportedKind, @@ -284,8 +288,7 @@ TraversalKindScope RAII(Finder->getASTContext(), Implementation->TraversalKind()); - if (Finder->getASTContext().getParentMapContext().getTraversalKind() == - TK_IgnoreUnlessSpelledInSource && + if (!Finder->isTraversalAsIs() && Finder->IsMatchingInTemplateInstantiationNotSpelledInSource()) return false; @@ -309,8 +312,7 @@ TraversalKindScope raii(Finder->getASTContext(), Implementation->TraversalKind()); - if (Finder->getASTContext().getParentMapContext().getTraversalKind() == - TK_IgnoreUnlessSpelledInSource && + if (!Finder->isTraversalAsIs() && Finder->IsMatchingInTemplateInstantiationNotSpelledInSource()) return false; Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp =================================================================== --- clang/lib/ASTMatchers/ASTMatchFinder.cpp +++ clang/lib/ASTMatchers/ASTMatchFinder.cpp @@ -153,9 +153,7 @@ Stmt *StmtToTraverse = StmtNode; if (auto *ExprNode = dyn_cast_or_null<Expr>(StmtNode)) { auto *LambdaNode = dyn_cast_or_null<LambdaExpr>(StmtNode); - if (LambdaNode && - Finder->getASTContext().getParentMapContext().getTraversalKind() == - TK_IgnoreUnlessSpelledInSource) + if (LambdaNode && !Finder->isTraversalAsIs()) StmtToTraverse = LambdaNode; else StmtToTraverse = @@ -232,8 +230,7 @@ return traverse(TAL); } bool TraverseLambdaExpr(LambdaExpr *Node) { - if (Finder->getASTContext().getParentMapContext().getTraversalKind() != - TK_IgnoreUnlessSpelledInSource) + if (!Finder->isTraversalAsIs()) return VisitorBase::TraverseLambdaExpr(Node); if (!Node) return true; Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h =================================================================== --- clang/include/clang/ASTMatchers/ASTMatchersInternal.h +++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -1062,6 +1062,8 @@ virtual bool IsMatchingInTemplateInstantiationNotSpelledInSource() const = 0; + bool isTraversalAsIs() const; + protected: virtual bool matchesChildOf(const DynTypedNode &Node, ASTContext &Ctx, const DynTypedMatcher &Matcher,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits