[clang-tools-extra] [clangd] Do not collect macros when clang-tidy checks call into the preprocessor (PR #106329)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 27 19:54:44 PDT 2024
================
@@ -702,6 +704,10 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
log("Execute() failed when building AST for {0}: {1}", MainInput.getFile(),
toString(std::move(Err)));
+ // Disable the macro collector for the remainder of this function, e.g.
+ // clang-tidy checkers.
+ MacroCollectorPtr->doneParse();
----------------
HighCommander4 wrote:
The first approach I tried was to remove `CollectMainFileMacros` from the preprocessor callbacks at this point, however the current `Preprocessor` API does not make that easy to do (adding a new callback creates a `PPChainedCallbacks`, and there are further internal calls made to `addPPCallbacks()` that chain other ones on top of ours). So, I opted to "neutralize" our callback rather than try to remove it.
https://github.com/llvm/llvm-project/pull/106329
More information about the cfe-commits
mailing list