[clang] [analyzer][CTU] Macro expansions for imported translation units (PR #176126)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 26 07:09:33 PST 2026
================
@@ -620,13 +649,23 @@ CrossTranslationUnitContext::ASTLoader::loadFromSource(
CI.getDiagnostics().getDiagnosticIDs()};
auto Diags = llvm::makeIntrusiveRefCnt<DiagnosticsEngine>(DiagID, *DiagOpts,
DiagClient);
+ std::unique_ptr<MacroExpansionContext> MacroExpansions;
// This runs the driver which isn't expected to be free of sandbox violations.
auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
- return CreateASTUnitFromCommandLine(
+ auto Unit = CreateASTUnitFromCommandLine(
CommandLineArgs.begin(), (CommandLineArgs.end()),
CI.getPCHContainerOperations(), DiagOpts, Diags,
- CI.getHeaderSearchOpts().ResourceDir);
+ CI.getHeaderSearchOpts().ResourceDir, false, StringRef(), false,
+ CaptureDiagsKind::None, {}, true, 0, TU_Complete, false, false, false,
+ SkipFunctionBodiesScope::None, false, false, false, false, std::nullopt,
+ nullptr, nullptr, [&MacroExpansions](CompilerInstance &CI) {
+ MacroExpansions.reset(new MacroExpansionContext(CI.getLangOpts()));
+ MacroExpansions->registerForPreprocessor(CI.getPreprocessor());
+ });
+ MacroExpansions->dumpExpansionRanges();
+ MacroExpansions->dumpExpandedTexts();
----------------
steakhal wrote:
I think you might have forgotten about these dumps here.
https://github.com/llvm/llvm-project/pull/176126
More information about the cfe-commits
mailing list