Rename API to not be constrained to template instantiations

A follow-up commit will use this method to ignore implcit AST nodes.
This commit is contained in:
Stephen Kelly 2020-11-17 15:42:03 +00:00
parent 019723fc29
commit 36011bdfb6
3 changed files with 17 additions and 17 deletions
clang

View File

@ -1060,7 +1060,7 @@ public:
virtual ASTContext &getASTContext() const = 0;
virtual bool IsMatchingInTemplateInstantiationNotSpelledInSource() const = 0;
virtual bool IsMatchingInASTNodeNotSpelledInSource() const = 0;
bool isTraversalIgnoringImplicitNodes() const;

View File

@ -497,7 +497,7 @@ public:
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 @@ public:
ScopedTraversal = true;
}
TemplateInstantiationNotSpelledInSourceScope RAII(this, ScopedTraversal);
ASTNodeNotSpelledInSourceScope RAII(this, ScopedTraversal);
MatchChildASTVisitor Visitor(
&Matcher, this, Builder, MaxDepth, Traversal, Bind);
@ -592,38 +592,38 @@ public:
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:

View File

@ -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 =