carlosgalvezp wrote: I believe I found something promising:
* Revert the parts of the code that sets the TraversalScope. This messes up the `ParentMapContext`. * Apply this change: ``` bool MatchASTVisitor::TraverseDecl(Decl *DeclNode) { if (!DeclNode) { return true; } + if (Options.SkipSystemHeaders && isInSystemHeader(DeclNode)) { + return true; + } ``` Pros: * Leaves the `ASTContext` and `ParentMapContext` untouched. * Keeps avoiding matching and checking decls outside of system headers. * The broken unit test in readability now works, because we are no longer dealing with TopLevelDecls. * Most likely we don't lose any functionality or introduce false negatives. Cons: * We still have to traverse decls in system headers. I did try to `return false;` instead of `return true;` in the proposed code but that made around 60 clang-tidy tests to fail. I don't know how much this matters in practice, I will come back with measurements. What do you think @AaronBallman @Xazax-hun , does this sound reasonable? If so I can put up a PR right away. 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