Skip to content

Commit 25edfca

Browse files
committed
[NFC] Minor fix to tryEmitAbstract type in EmitCXXNewAllocSize
In EmitCXXNewAllocSize, when handling a constant array size, we were calling tryEmitAbstract with the type of the object being allocated. This worked out because the type was always a pointer and tryEmitAbstract only ends up using the size of the type to extend or truncate the constant, and in this case the destination type should be size_t, which is the same size as the pointer. So, this change fixes the type, but it makes no functional difference with the current constant emitter implementation.
1 parent 87e4b68 commit 25edfca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/lib/CodeGen/CGExprCXX.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,8 @@ static llvm::Value *EmitCXXNewAllocSize(CodeGenFunction &CGF,
732732
// Emit the array size expression.
733733
// We multiply the size of all dimensions for NumElements.
734734
// e.g for 'int[2][3]', ElemType is 'int' and NumElements is 6.
735-
numElements =
736-
ConstantEmitter(CGF).tryEmitAbstract(*e->getArraySize(), e->getType());
735+
numElements = ConstantEmitter(CGF).tryEmitAbstract(
736+
*e->getArraySize(), CGF.getContext().getSizeType());
737737
if (!numElements)
738738
numElements = CGF.EmitScalarExpr(*e->getArraySize());
739739
assert(isa<llvm::IntegerType>(numElements->getType()));

0 commit comments

Comments
 (0)