[llvm] [llvm] Outline some ctors to avoid incomplete types (PR #228946)

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 4 15:44:39 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-openmp

Author: rdong8

<details>
<summary>Changes</summary>

In C++26, new constexpr ctors of types like `unique_ptr`, `forward_list`, etc. make it an error to instantiate them with a forward declared type. Constructors of classes carrying such types thus need to be outlined into the implementation file to avoid these errors.

Assisted by AI.

Related:
- https://github.com/llvm/llvm-project/pull/223284
- https://discourse.llvm.org/t/policy-on-supporting-newer-c-standard-in-llvm-codebase/88114

---
Full diff: https://github.com/llvm/llvm-project/pull/228946.diff


4 Files Affected:

- (modified) llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h (+1-3) 
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+4) 
- (modified) llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFStreamer.cpp (+6) 
- (modified) llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFStreamer.h (+1-2) 


``````````diff
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index 24b542bd7b358..1d8549e650a5f 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -512,9 +512,7 @@ class OpenMPIRBuilder {
 public:
   /// Create a new OpenMPIRBuilder operating on the given module \p M. This will
   /// not have an effect on \p M (see initialize)
-  OpenMPIRBuilder(Module &M)
-      : M(M), Builder(M.getContext()), OffloadInfoManager(this),
-        T(M.getTargetTriple()), IsFinalized(false) {}
+  LLVM_ABI OpenMPIRBuilder(Module &M);
   LLVM_ABI ~OpenMPIRBuilder();
 
   class AtomicInfo : public llvm::AtomicInfo {
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 4e7f22434c95d..b0b5a8519deec 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1180,6 +1180,10 @@ void OpenMPIRBuilder::applyDeclareTargetGlobalReplacements() {
   DeclareTargetGlobalReplacements.clear();
 }
 
+OpenMPIRBuilder::OpenMPIRBuilder(Module &M)
+    : M(M), Builder(M.getContext()), OffloadInfoManager(this),
+      T(M.getTargetTriple()), IsFinalized(false) {}
+
 OpenMPIRBuilder::~OpenMPIRBuilder() {
   assert(OutlineInfos.empty() && "There must be no outstanding outlinings");
 }
diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFStreamer.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFStreamer.cpp
index 91433d8eaddc5..7dc31e4b8cc17 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFStreamer.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFStreamer.cpp
@@ -89,6 +89,12 @@ void LoongArchTargetELFStreamer::finish() {
   W.setELFHeaderEFlags(EFlags);
 }
 
+LoongArchELFStreamer::LoongArchELFStreamer(MCContext &C,
+                                           std::unique_ptr<MCAsmBackend> MAB,
+                                           std::unique_ptr<MCObjectWriter> MOW,
+                                           std::unique_ptr<MCCodeEmitter> MCE)
+    : MCELFStreamer(C, std::move(MAB), std::move(MOW), std::move(MCE)) {}
+
 void LoongArchELFStreamer::emitCodeAlignment(Align Alignment,
                                              const MCSubtargetInfo &STI,
                                              unsigned MaxBytesToEmit) {
diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFStreamer.h b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFStreamer.h
index a9e5ec2bb527c..46c359000134d 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFStreamer.h
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchELFStreamer.h
@@ -33,8 +33,7 @@ class LoongArchELFStreamer : public MCELFStreamer {
 public:
   LoongArchELFStreamer(MCContext &C, std::unique_ptr<MCAsmBackend> MAB,
                        std::unique_ptr<MCObjectWriter> MOW,
-                       std::unique_ptr<MCCodeEmitter> MCE)
-      : MCELFStreamer(C, std::move(MAB), std::move(MOW), std::move(MCE)) {}
+                       std::unique_ptr<MCCodeEmitter> MCE);
 
   void emitCodeAlignment(Align Alignment, const MCSubtargetInfo &STI,
                          unsigned MaxBytesToEmit) override;

``````````

</details>


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


More information about the llvm-commits mailing list