[clang] [Preprocessor] Do not expand macros if the input is already preprocessed (PR #137665)
Juan Manuel Martinez CaamaƱo via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 13 06:47:38 PDT 2025
================
@@ -84,6 +84,8 @@ class FrontendAction {
/// \return True on success; on failure ExecutionAction() and
/// EndSourceFileAction() will not be called.
virtual bool BeginSourceFileAction(CompilerInstance &CI) {
+ if (CurrentInput.isPreprocessed())
+ CI.getPreprocessor().SetEnableMacroExpansion(false);
----------------
jmmartinez wrote:
Use `SetMacroExpansionOnlyInDirectives` instead. We still need to expand macro ids in #pragma directives when going through preprocessed code. Usage of macros on #pragma directives are not expanded in the preprocessed source.
https://github.com/llvm/llvm-project/pull/137665
More information about the cfe-commits
mailing list