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

Could we use `if constexpr` and merge these 2 functions? IMO, it will be more 
readable.


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