================
@@ -3006,30 +2922,37 @@ bool Sema::FindAllocationFunctions(
TypeAwareAllocationMode OriginalTypeAwareState = IAP.PassTypeIdentity;
CXXScalarValueInitExpr TypeIdentityParam(TypeIdentity, nullptr, StartLoc);
- if (isTypeAwareAllocation(IAP.PassTypeIdentity))
- AllocArgs.push_back(&TypeIdentityParam);
QualType SizeTy = Context.getSizeType();
unsigned SizeTyWidth = Context.getTypeSize(SizeTy);
IntegerLiteral Size(Context, llvm::APInt::getZero(SizeTyWidth), SizeTy,
SourceLocation());
- AllocArgs.push_back(&Size);
QualType AlignValT = Context.VoidTy;
- bool IncludeAlignParam = isAlignedAllocation(IAP.PassAlignment) ||
- isTypeAwareAllocation(IAP.PassTypeIdentity);
- if (IncludeAlignParam) {
+ if (isTypeAwareAllocation(OriginalTypeAwareState) ||
+ isAlignedAllocation(IAP.PassAlignment)) {
DeclareGlobalNewDelete();
AlignValT = Context.getCanonicalTagType(getStdAlignValT());
}
CXXScalarValueInitExpr Align(AlignValT, nullptr, SourceLocation());
- if (IncludeAlignParam)
- AllocArgs.push_back(&Align);
- llvm::append_range(AllocArgs, PlaceArgs);
+ using ArgsVector = SmallVector<Expr *, 8>;
+ auto FillAllocArgs = [&](TypeAwareAllocationMode TAAM,
+ AlignedAllocationMode AAM) {
+ ArgsVector AllocArgs;
+ AllocArgs.reserve(IAP.getNumImplicitArgs() + PlaceArgs.size());
+ if (isTypeAwareAllocation(TAAM))
+ AllocArgs.push_back(&TypeIdentityParam);
+ AllocArgs.push_back(&Size);
+ if (isAlignedAllocation(AAM))
+ AllocArgs.push_back(&Align);
+ llvm::append_range(AllocArgs, PlaceArgs);
+ return AllocArgs;
+ };
----------------
igorkudrin wrote:
This suggestion ignores existing nuances, such as the msvc-specific fallback
and producing the combined diagnostic for some of the candidate argument lists.
The ideas are a good goal for future changes, but they are not minimal NFC
changes required to implement CWG2282.
https://github.com/llvm/llvm-project/pull/203824
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits