forked from OSchip/llvm-project
Add utility for testing if we're matching nodes AsIs
Differential Revision: https://reviews.llvm.org/D91144
This commit is contained in:
parent
7d85f732b1
commit
e73296d3b9
|
@ -1062,6 +1062,8 @@ public:
|
|||
|
||||
virtual bool IsMatchingInTemplateInstantiationNotSpelledInSource() const = 0;
|
||||
|
||||
bool isTraversalAsIs() const;
|
||||
|
||||
protected:
|
||||
virtual bool matchesChildOf(const DynTypedNode &Node, ASTContext &Ctx,
|
||||
const DynTypedMatcher &Matcher,
|
||||
|
|
|
@ -153,9 +153,7 @@ public:
|
|||
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 @@ public:
|
|||
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;
|
||||
|
|
|
@ -191,6 +191,10 @@ private:
|
|||
|
||||
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 @@ bool DynTypedMatcher::matches(const DynTypedNode &DynNode,
|
|||
TraversalKindScope RAII(Finder->getASTContext(),
|
||||
Implementation->TraversalKind());
|
||||
|
||||
if (Finder->getASTContext().getParentMapContext().getTraversalKind() ==
|
||||
TK_IgnoreUnlessSpelledInSource &&
|
||||
if (!Finder->isTraversalAsIs() &&
|
||||
Finder->IsMatchingInTemplateInstantiationNotSpelledInSource())
|
||||
return false;
|
||||
|
||||
|
@ -309,8 +312,7 @@ bool DynTypedMatcher::matchesNoKindCheck(const DynTypedNode &DynNode,
|
|||
TraversalKindScope raii(Finder->getASTContext(),
|
||||
Implementation->TraversalKind());
|
||||
|
||||
if (Finder->getASTContext().getParentMapContext().getTraversalKind() ==
|
||||
TK_IgnoreUnlessSpelledInSource &&
|
||||
if (!Finder->isTraversalAsIs() &&
|
||||
Finder->IsMatchingInTemplateInstantiationNotSpelledInSource())
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue