From 1b3a448170d7e8a9bbac02a84702fcb36a4fc376 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Tue, 1 Sep 2026 08:48:21 +0200 Subject: [PATCH] [clang] Simplify updating CodeGenOptions This works now since upstream commit https://github.com/llvm/llvm-project/commit/ddeab07ca63235f8d952e1171b56fdb0f2d761c9 changed the intentional copy in CodeGeneratorImpl to a reference with a single copy of the CodeGenOptions stored in the CompilerInvocation. This reverts the downstream modifications from commit 0d60867be9, allowing to drop one more Clang patch. --- .../cling/lib/Interpreter/IncrementalParser.cpp | 3 +-- .../clang/include/clang/CodeGen/ModuleBuilder.h | 3 --- .../clang/lib/CodeGen/ModuleBuilder.cpp | 15 +-------------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/IncrementalParser.cpp b/interpreter/cling/lib/Interpreter/IncrementalParser.cpp index 220f570113fa9..ef94a4c5f2b5f 100644 --- a/interpreter/cling/lib/Interpreter/IncrementalParser.cpp +++ b/interpreter/cling/lib/Interpreter/IncrementalParser.cpp @@ -556,8 +556,7 @@ namespace cling { llvm::Module* IncrementalParser::StartModule() { return m_Interpreter->withLLVMContextDo([&](llvm::LLVMContext* Ctx) { - return getCodeGenerator()->StartModule(makeModuleName(), *Ctx, - getCI()->getCodeGenOpts()); + return getCodeGenerator()->StartModule(makeModuleName(), *Ctx); }); } diff --git a/interpreter/llvm-project/clang/include/clang/CodeGen/ModuleBuilder.h b/interpreter/llvm-project/clang/include/clang/CodeGen/ModuleBuilder.h index 5dd5d9a813f77..9a91ae40c70c4 100644 --- a/interpreter/llvm-project/clang/include/clang/CodeGen/ModuleBuilder.h +++ b/interpreter/llvm-project/clang/include/clang/CodeGen/ModuleBuilder.h @@ -113,9 +113,6 @@ class CodeGenerator : public ASTConsumer { /// enable codegen in interactive processing environments. llvm::Module* StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C); - llvm::Module *StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C, - const CodeGenOptions &CGO); - void forgetGlobal(llvm::GlobalValue *GV); void forgetDecl(llvm::StringRef MangledName); }; diff --git a/interpreter/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp b/interpreter/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp index b9d32a19486eb..4d9d3b32e6df7 100644 --- a/interpreter/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp +++ b/interpreter/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp @@ -38,7 +38,7 @@ namespace clang { IntrusiveRefCntPtr FS; // Only used for debug info. const HeaderSearchOptions &HeaderSearchOpts; // Only used for debug info. const PreprocessorOptions &PreprocessorOpts; // Only used for debug info. - CodeGenOptions CodeGenOpts; // Intentionally copied in. + const CodeGenOptions &CodeGenOpts; unsigned HandlingTopLevelDecls; @@ -267,12 +267,6 @@ namespace clang { return M.get(); } - llvm::Module *StartModule(llvm::StringRef ModuleName, llvm::LLVMContext &C, - const CodeGenOptions &CGO) { - CodeGenOpts = CGO; - return StartModule(ModuleName, C); - } - void forgetGlobal(llvm::GlobalValue *GV) { for (auto I = Builder->ConstantStringMap.begin(), E = Builder->ConstantStringMap.end(); @@ -511,13 +505,6 @@ llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName, return static_cast(this)->StartModule(ModuleName, C); } -llvm::Module *CodeGenerator::StartModule(llvm::StringRef ModuleName, - llvm::LLVMContext &C, - const CodeGenOptions &CGO) { - return static_cast(this)->StartModule(ModuleName, C, - CGO); -} - void CodeGenerator::forgetGlobal(llvm::GlobalValue *GV) { static_cast(this)->forgetGlobal(GV); }