[clang] [Preprocessor] Do not expand macros if the input is already preprocessed (PR #137665)

via cfe-commits cfe-commits at lists.llvm.org
Tue May 20 03:01:33 PDT 2025


Juan Manuel Martinez =?utf-8?q?Caamaño?= <juamarti at amd.com>,
Juan Manuel Martinez =?utf-8?q?Caamaño?= <juamarti at amd.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/137665 at github.com>


================
@@ -1558,6 +1558,13 @@ void clang::InitializePreprocessor(Preprocessor &PP,
                                    const PCHContainerReader &PCHContainerRdr,
                                    const FrontendOptions &FEOpts,
                                    const CodeGenOptions &CodeGenOpts) {
+
+  if (all_of(FEOpts.Inputs,
+             [](const FrontendInputFile &FI) { return FI.isPreprocessed(); })) {
+    PP.SetDisableMacroExpansion();
+    return;
+  }
----------------
cor3ntin wrote:

Did you consider doing that on a per-file basis in `FrontendAction::BeginSourceFile`?

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


More information about the cfe-commits mailing list