[llvm-branch-commits] [clang] [llvm] CGExprCXX: emit family and allockind attributes (PR #239732)

Augie Fackler via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Nov 16 19:50:47 PST 2026


================
@@ -1393,12 +1395,58 @@ static RValue EmitNewDeleteCall(CodeGenFunction &CGF,
   ///
   /// We model such elidable calls with the 'builtin' attribute.
   llvm::Function *Fn = dyn_cast<llvm::Function>(CalleePtr);
-  if (CalleeDecl->isReplaceableGlobalAllocationFunction() && Fn) {
-    if (Fn->hasFnAttribute(llvm::Attribute::NoBuiltin))
+  UnsignedOrNone AlignArg = std::nullopt;
+  if (CalleeDecl->isReplaceableGlobalAllocationFunction(&AlignArg)) {
+    auto &Ctx = CallOrInvoke->getContext();
+    llvm::AllocFnKind AK = llvm::AllocFnKind::Unknown;
+    bool IsDeleter = CalleeDecl->getOverloadedOperator() == OO_Array_Delete ||
+                     CalleeDecl->getOverloadedOperator() == OO_Delete;
+    if (IsDeleter) {
+      AK = AK | llvm::AllocFnKind::Free;
+    } else {
+      if (AlignArg)
+        AK = llvm::AllocFnKind::Aligned;
+      AK = AK | llvm::AllocFnKind::Alloc | llvm::AllocFnKind::Uninitialized;
+    }
+    ASTContext &ASTCtx = CalleeDecl->getASTContext();
+    ASTNameGenerator gen = ASTNameGenerator(ASTCtx);
+    std::string Mangled = gen.getName(CalleeDecl);
+
+    if (Mangled.find("??") == 0) {
----------------
durin42 wrote:

lol yeah

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


More information about the llvm-branch-commits mailing list