================
@@ -1681,7 +1681,13 @@ void MatchFinder::addMatcher(const DeclarationMatcher 
&NodeMatch,
 
 void MatchFinder::addMatcher(const TypeMatcher &NodeMatch,
                              MatchCallback *Action) {
-  Matchers.Type.emplace_back(NodeMatch, Action);
+  std::optional<TraversalKind> TK;
+  if (Action)
+    TK = Action->getCheckTraversalKind();
+  if (TK)
+    Matchers.Type.emplace_back(traverse(*TK, NodeMatch), Action);
+  else
+    Matchers.Type.emplace_back(NodeMatch, Action);
----------------
localspook wrote:

Up to you, but we could factor this logic out into a function like:
```cpp
template <typename T>
static internal::Matcher<T>
adjustTraversalKind(internal::Matcher<T> NodeMatch,
                    MatchFinder::MatchCallback *Action) {
  if (Action)
    if (std::optional<TraversalKind> TK = Action->getCheckTraversalKind())
      return traverse(*TK, NodeMatch);
  return NodeMatch;
}
```
then use it like:
```cpp
Matchers.TypeLoc.emplace_back(adjustTraversalKind(NodeMatch, Action), Action);
```

https://github.com/llvm/llvm-project/pull/170953
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to