[clang] [analyzer][CTU] Macro expansions for imported translation units (PR #176126)
Vladimir Vuksanovic via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 27 07:22:14 PST 2026
================
@@ -1222,6 +1223,9 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
if (!Act->BeginSourceFile(*Clang, Clang->getFrontendOpts().Inputs[0]))
return true;
+ if (OnCompilerCreated)
+ OnCompilerCreated(*Clang);
----------------
vvuksanovic wrote:
There are a couple of alternatives to that. We should be able to pass the `MacroExpansionContext` here instead of the callback function, though that exposes that class in `ASTUnit`. Technically, we only need to pass the preprocessor instance in the callback.
I agree that exposing the compiler instance this way can allow the callback to modify it in some unexpected/problematic way which is not ideal. Looking through all parameters of `CreateASTUnitFromCommandLine` I couldn't find any option that would allow us to register the `MacroExpansionContext`.
https://github.com/llvm/llvm-project/pull/176126
More information about the cfe-commits
mailing list