[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
Mon May 26 08:52:34 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().SetDisableMacroExpansion();
----------------
jmmartinez wrote:
It was quite shortsighted from me, sorry. There were some subclasses that were missing the call to the base-class method.
I should add the calls to the base class in a separate NFC patch.
I've added a `SetEnableMacroExpansion(true/false)` method to set/reset the macro expansion; but I'm not convinced by it (I'm worried about interactions with `SetMacroExpansionOnlyInDirectives`, but these interactions also seem unlikely).
https://github.com/llvm/llvm-project/pull/137665
More information about the cfe-commits
mailing list