[clang] [llvm] [polly] [IRBuilder] Make IRBuilder inserter non-virtual (PR #229700)

Florian Hahn via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 7 05:04:41 PDT 2026


================
@@ -137,15 +136,15 @@ class IRBuilderBase {
 
 public:
   IRBuilderBase(LLVMContext &context, const IRBuilderFolder &Folder,
-                const IRBuilderDefaultInserter &Inserter)
-      : Context(context), Folder(Folder), Inserter(Inserter) {
+                InsertFn InsertCB)
+      : Context(context), Folder(Folder), InsertCB(InsertCB) {
     ClearInsertionPoint();
   }
 
   /// Insert and return the specified instruction.
   template<typename InstTy>
   InstTy *Insert(InstTy *I, const Twine &Name = "") const {
-    Inserter.InsertHelper(I, Name, InsertPt);
+    InsertCB(*this, I, Name, InsertPt);
----------------
fhahn wrote:

I think we allow copying to `IRBuilderBase` and could end up with a copied over call back that would cast to a sub-type/specialized `IRBuilder`, which would be UB.

It looks like we already delete copy assignment, perhaps we should just also delete the copy ctor?

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


More information about the cfe-commits mailing list