[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


================
@@ -8651,14 +8651,52 @@ class Sema final : public SemaBase {
   bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
                           SourceRange R);
 
+  struct ImplicitAllocationArguments {
+    friend Sema;
+
+    ArrayRef<Expr *> getImplicitArguments() const {
+      return ArrayRef(ImplicitArguments, ArgumentCount);
+    }
+
+    Expr *getAlignmentArgument() const {
+      if (PassAlignment == AlignedAllocationMode::Yes)
+        return ImplicitArguments[ArgumentCount - 1];
+      return nullptr;
+    }
+
+    void updateLookupForMSVCCompatibility(Sema &, LookupResult &);
+    TypeAwareAllocationMode PassTypeIdentity;
+    AlignedAllocationMode PassAlignment;
+
+  private:
+    ImplicitAllocationArguments(Sema &SemaRef, Expr *TypeIdentityArg,
+                                Expr *SizeArg, Expr *AlignArg,
+                                bool IsMSVCCompatibilityFallback);
+
+    // Type-identity, size, and alignment
+    static constexpr unsigned MaxImplicitArguments = 3;
+    bool IsMSVCCompatibilityFallback;
+
+    unsigned ArgumentCount;
+    Expr *ImplicitArguments[MaxImplicitArguments];
+  };
+
+  struct AllocationArgumentSet {
+    bool TypeAwareViable;
+    SmallVector<ImplicitAllocationArguments, 3> Candidates;
+  };
+
+private:
+  struct ResolvedAllocation;
+
+public:
----------------
cor3ntin wrote:

Part of the supporting types are defined in ExprCXX,h. Did you consider having everything in one place, possibly in a new headers?

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


More information about the cfe-commits mailing list