================ @@ -1573,19 +1574,41 @@ bool MatchASTVisitor::TraverseAttr(Attr *AttrNode) { class MatchASTConsumer : public ASTConsumer { public: MatchASTConsumer(MatchFinder *Finder, - MatchFinder::ParsingDoneTestCallback *ParsingDone) - : Finder(Finder), ParsingDone(ParsingDone) {} + MatchFinder::ParsingDoneTestCallback *ParsingDone, + const MatchFinderOptions &Options) + : Finder(Finder), ParsingDone(ParsingDone), Options(Options) {} private: + bool HandleTopLevelDecl(DeclGroupRef DG) override { + if (Options.SkipSystemHeaders) { + for (Decl *D : DG) { + if (!isInSystemHeader(D)) + TraversalScope.push_back(D); + } + } + return true; + } + void HandleTranslationUnit(ASTContext &Context) override { + if (!TraversalScope.empty()) + Context.setTraversalScope(TraversalScope); ---------------- PiotrZSL wrote:
This mean that if .cpp file is empty, then we will traverse system headers includes regardless of SkipSystemHeaders. Shouldn't this check actually Options.SkipSystemHeaders. Maybe in such case we shoudn't even call matchAST. By default TraversalScope in Context is set to TranslationUnit. https://github.com/llvm/llvm-project/pull/128150 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits