================
@@ -1336,6 +1336,44 @@ class MatchASTVisitor : public 
RecursiveASTVisitor<MatchASTVisitor>,
     return false;
   }
 
+  template <typename T> static SourceLocation getNodeLocation(const T &Node) {
+    return Node.getBeginLoc();
+  }
+
+  static SourceLocation getNodeLocation(const QualType &Node) { return {}; }
+
+  static SourceLocation getNodeLocation(const NestedNameSpecifier &Node) {
+    return {};
+  }
+
+  static SourceLocation getNodeLocation(const CXXCtorInitializer &Node) {
+    return Node.getSourceLocation();
+  }
+
+  static SourceLocation getNodeLocation(const TemplateArgumentLoc &Node) {
+    return Node.getLocation();
+  }
+
+  static SourceLocation getNodeLocation(const Attr &Node) {
+    return Node.getLocation();
+  }
+
+  bool isInSystemHeader(const SourceLocation &Loc) {
+    const SourceManager &SM = getASTContext().getSourceManager();
+    return SM.isInSystemHeader(Loc);
+  }
+
+  template <typename T> bool shouldSkipNode(const T &Node) {
+    if constexpr (std::is_pointer_v<T>)
+      return (Node == nullptr) || shouldSkipNode(*Node);
+    else {
----------------
steakhal wrote:

This recursive dispatching looked weird to me initially.
For example, it opens up usages as `const Expr ***`, which is probably not what 
we wanted to expose on the API surface. If we had a different template 
specialization for pointers, and another one for references, I think that would 
clarify the API.

I have no strong feelings though. I doubt I'll come back to this code too often 
in the future.

https://github.com/llvm/llvm-project/pull/151035
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to