@@ -128,6 +128,9 @@ class MatchChildASTVisitor
128128 traverse (*T);
129129 else if (const auto *C = DynNode.get <CXXCtorInitializer>())
130130 traverse (*C);
131+ else if (const TemplateArgumentLoc *TALoc =
132+ DynNode.get <TemplateArgumentLoc>())
133+ traverse (*TALoc);
131134 // FIXME: Add other base types after adding tests.
132135
133136 // It's OK to always overwrite the bound nodes, as if there was
@@ -224,6 +227,10 @@ class MatchChildASTVisitor
224227 ScopedIncrement ScopedDepth (&CurrentDepth);
225228 return traverse (*CtorInit);
226229 }
230+ bool TraverseTemplateArgumentLoc (TemplateArgumentLoc TAL) {
231+ ScopedIncrement ScopedDepth (&CurrentDepth);
232+ return traverse (TAL);
233+ }
227234 bool TraverseLambdaExpr (LambdaExpr *Node) {
228235 if (Finder->getASTContext ().getParentMapContext ().getTraversalKind () !=
229236 TK_IgnoreUnlessSpelledInSource)
@@ -304,6 +311,9 @@ class MatchChildASTVisitor
304311 return VisitorBase::TraverseConstructorInitializer (
305312 const_cast <CXXCtorInitializer *>(&CtorInit));
306313 }
314+ bool baseTraverse (TemplateArgumentLoc TAL) {
315+ return VisitorBase::TraverseTemplateArgumentLoc (TAL);
316+ }
307317
308318 // Sets 'Matched' to true if 'Matcher' matches 'Node' and:
309319 // 0 < CurrentDepth <= MaxDepth.
@@ -447,6 +457,7 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
447457 bool TraverseNestedNameSpecifier (NestedNameSpecifier *NNS);
448458 bool TraverseNestedNameSpecifierLoc (NestedNameSpecifierLoc NNS);
449459 bool TraverseConstructorInitializer (CXXCtorInitializer *CtorInit);
460+ bool TraverseTemplateArgumentLoc (TemplateArgumentLoc TAL);
450461
451462 // Matches children or descendants of 'Node' with 'BaseMatcher'.
452463 bool memoizedMatchesRecursively (const DynTypedNode &Node, ASTContext &Ctx,
@@ -557,6 +568,8 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
557568 match (*N);
558569 } else if (auto *N = Node.get <CXXCtorInitializer>()) {
559570 match (*N);
571+ } else if (auto *N = Node.get <TemplateArgumentLoc>()) {
572+ match (*N);
560573 }
561574 }
562575
@@ -680,6 +693,9 @@ class MatchASTVisitor : public RecursiveASTVisitor<MatchASTVisitor>,
680693 void matchDispatch (const CXXCtorInitializer *Node) {
681694 matchWithoutFilter (*Node, Matchers->CtorInit );
682695 }
696+ void matchDispatch (const TemplateArgumentLoc *Node) {
697+ matchWithoutFilter (*Node, Matchers->TemplateArgumentLoc );
698+ }
683699 void matchDispatch (const void *) { /* Do nothing. */ }
684700 // / @}
685701
@@ -1035,6 +1051,11 @@ bool MatchASTVisitor::TraverseConstructorInitializer(
10351051 CtorInit);
10361052}
10371053
1054+ bool MatchASTVisitor::TraverseTemplateArgumentLoc (TemplateArgumentLoc Loc) {
1055+ match (Loc);
1056+ return RecursiveASTVisitor<MatchASTVisitor>::TraverseTemplateArgumentLoc (Loc);
1057+ }
1058+
10381059class MatchASTConsumer : public ASTConsumer {
10391060public:
10401061 MatchASTConsumer (MatchFinder *Finder,
@@ -1111,6 +1132,12 @@ void MatchFinder::addMatcher(const CXXCtorInitializerMatcher &NodeMatch,
11111132 Matchers.AllCallbacks .insert (Action);
11121133}
11131134
1135+ void MatchFinder::addMatcher (const TemplateArgumentLocMatcher &NodeMatch,
1136+ MatchCallback *Action) {
1137+ Matchers.TemplateArgumentLoc .emplace_back (NodeMatch, Action);
1138+ Matchers.AllCallbacks .insert (Action);
1139+ }
1140+
11141141bool MatchFinder::addDynamicMatcher (const internal::DynTypedMatcher &NodeMatch,
11151142 MatchCallback *Action) {
11161143 if (NodeMatch.canConvertTo <Decl>()) {
@@ -1134,6 +1161,9 @@ bool MatchFinder::addDynamicMatcher(const internal::DynTypedMatcher &NodeMatch,
11341161 } else if (NodeMatch.canConvertTo <CXXCtorInitializer>()) {
11351162 addMatcher (NodeMatch.convertTo <CXXCtorInitializer>(), Action);
11361163 return true ;
1164+ } else if (NodeMatch.canConvertTo <TemplateArgumentLoc>()) {
1165+ addMatcher (NodeMatch.convertTo <TemplateArgumentLoc>(), Action);
1166+ return true ;
11371167 }
11381168 return false ;
11391169}
0 commit comments