[clang] [Clang][ExprConst] Accept prvalue for nothrow new (PR #226753)

via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 27 10:28:40 PDT 2026


================
@@ -11030,8 +11030,11 @@ bool PointerExprEvaluator::VisitCXXNewExpr(const CXXNewExpr *E) {
     // (which should presumably be valid only if N is a multiple of
     // alignof(int), and in any case can't be deallocated unless N is
     // alignof(X) and X has new-extended alignment).
-    LValue Nothrow;
-    if (!EvaluateLValue(E->getPlacementArg(0), Nothrow, Info))
+    //
+    // The argument is usually an lvalue (the standard signature takes a
+    // 'const std::nothrow_t &'), but a user-declared allocation function may
+    // take 'std::nothrow_t' by value, in which case it is a prvalue.
+    if (!EvaluateIgnoredValue(Info, E->getPlacementArg(0)))
----------------
aokblast wrote:

I reorder the check so isUsableAsGlobalAllocationFunctionInConstantEvaluation goes first. It should be fine now I think.

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


More information about the cfe-commits mailing list