[clang] [clang] Simplify the overload resolution logic for operator new and new[] (PR #211482)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 23 01:16:41 PDT 2026


================
@@ -2454,13 +2455,19 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
   SourceRange AllocationParameterRange = Range;
   if (PlacementLParen.isValid() && PlacementRParen.isValid())
     AllocationParameterRange = SourceRange(PlacementLParen, PlacementRParen);
-  if (!AllocType->isDependentType() &&
-      !Expr::hasAnyTypeDependentArguments(PlacementArgs) &&
-      FindAllocationFunctions(StartLoc, AllocationParameterRange, Scope, Scope,
-                              AllocType, ArraySize.has_value(), IAP,
-                              PlacementArgs, OperatorNew, OperatorDelete))
-    return ExprError();
 
+  if (!AllocType->isDependentType() &&
+      !Expr::hasAnyTypeDependentArguments(PlacementArgs)) {
+    auto FoundAllocation = FindAllocationFunctions(
+        StartLoc, AllocationParameterRange, Scope, Scope, AllocType,
+        ArraySize.has_value(), IAP, PlacementArgs);
----------------
cor3ntin wrote:

```suggestion
        /*IsArray=*/ ArraySize.has_value(), IAP, PlacementArgs);
```

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


More information about the cfe-commits mailing list