[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
Wed Aug 28 20:45:48 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:

Just to make sure I understand correctly, the idea is:

 * add a new method to `PPCallbacks`, e.g. `BuildASTDone()` or such
 * add a call to this new method in [place in libTooling, e.g. FrontendAction or such]
 * override `CollectMainFileMacros::BuildASTDone()` to do what `doneParse()` in the current patch does
 
?

https://github.com/llvm/llvm-project/pull/106329


More information about the cfe-commits mailing list