[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:17:12 PDT 2026


================
@@ -2787,112 +2789,75 @@ static void diagnoseNoViableFunctionForAllocationOverloadResolution(
   Candidates.NoteCandidates(S, Args, Cands, "", R.getNameLoc());
 }
 
-enum class ResolveMode { Typed, Untyped };
-static bool resolveAllocationOverloadInterior(
-    Sema &S, LookupResult &R, SourceRange Range, ResolveMode Mode,
-    SmallVectorImpl<Expr *> &Args, AlignedAllocationMode &PassAlignment,
-    FunctionDecl *&Operator, OverloadCandidateSet *AlignedCandidates,
-    Expr *AlignArg, bool Diagnose) {
-  unsigned NonTypeArgumentOffset = 0;
-  if (Mode == ResolveMode::Typed) {
-    ++NonTypeArgumentOffset;
-  }
+using ImplicitAllocationArguments = Sema::ImplicitAllocationArguments;
+using AllocationArgumentSet = Sema::AllocationArgumentSet;
 
-  OverloadCandidateSet Candidates(R.getNameLoc(),
-                                  OverloadCandidateSet::CSK_Normal);
+enum class AllocatorResolveResult { Success, Retry, Error };
+static AllocatorResolveResult
+resolveAllocationOverload(Sema &S, LookupResult &R, SourceRange Range,
+                          ImplicitAllocationArguments &AllocationArgs,
+                          ArrayRef<Expr *> TrialArguments,
+                          FunctionDecl *&Operator,
+                          OverloadCandidateSet &Candidates, bool Diagnose) {
+  AllocationArgs.updateLookupForMSVCCompatibility(S, R);
----------------
cor3ntin wrote:

We used to do that on overload resolution failure(ie no viable function found).
Here either I do not understand what's going on, or the fallback is performed before overload resolution. 

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


More information about the cfe-commits mailing list