[PATCH] D152160: [clang][NFC] Use a more accurate size type in the new operation, prevent issues when PointerWidth and the SizeType width are not same.
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 20 11:55:28 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG54aca3f33f63: [clang][NFC] Use a more accurate size type in the new operation (authored by CaprYang, committed by aaron.ballman).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D152160/new/
https://reviews.llvm.org/D152160
Files:
clang/lib/Sema/SemaExprCXX.cpp
Index: clang/lib/Sema/SemaExprCXX.cpp
===================================================================
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -2657,11 +2657,10 @@
// 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152160.542626.patch
Type: text/x-patch
Size: 898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230720/9e642112/attachment.bin>
More information about the cfe-commits
mailing list