Skip to content

Commit

Permalink
[clang][NFC] Use a more accurate size type in the new operation
Browse files Browse the repository at this point in the history
This prevents issues when PointerWidth and the SizeType width are not same.

Differential Revision: https://reviews.llvm.org/D152160
  • Loading branch information
CaprYang authored and AaronBallman committed Jul 20, 2023
1 parent f52e61f commit 54aca3f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2657,11 +2657,10 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
// FIXME: Should the Sema create the expression and embed it in the syntax
// tree? Or should the consumer just recalculate the value?
// FIXME: Using a dummy value will interact poorly with attribute enable_if.
IntegerLiteral Size(
Context,
llvm::APInt::getZero(
Context.getTargetInfo().getPointerWidth(LangAS::Default)),
Context.getSizeType(), SourceLocation());
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;
Expand Down

0 comments on commit 54aca3f

Please sign in to comment.