Skip to content

Commit 7bf188f

Browse files
authored
[NFC] Minor fix to tryEmitAbstract type in EmitCXXNewAllocSize (#123433)
In EmitCXXNewAllocSize, when handling a constant array size, we were calling tryEmitAbstract with the type of the object being allocated rather than the expected type of the array size. This worked out because the allocated 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 usually the same width as the pointer. This change fixes the type, but it makes no functional difference with the current constant emitter implementation.
1 parent 9f83c4e commit 7bf188f

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(), (*e->getArraySize())->getType());
737737
if (!numElements)
738738
numElements = CGF.EmitScalarExpr(*e->getArraySize());
739739
assert(isa<llvm::IntegerType>(numElements->getType()));

0 commit comments

Comments
 (0)