Skip to content

Commit a799a8e

Browse files
[CIR] Cast record size to uint64 to prevent overflow (#167525)
`llvm::TypeSize` uses 64bit integers, so we should cast the `recordSize` before multiplying by 8 to prevent an overflow.
1 parent e5e9c3b commit a799a8e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/lib/CIR/Dialect/IR/CIRTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ RecordType::getTypeSizeInBits(const mlir::DataLayout &dataLayout,
341341
if (isUnion())
342342
return dataLayout.getTypeSize(getLargestMember(dataLayout));
343343

344-
unsigned recordSize = computeStructSize(dataLayout);
344+
auto recordSize = static_cast<uint64_t>(computeStructSize(dataLayout));
345345
return llvm::TypeSize::getFixed(recordSize * 8);
346346
}
347347

0 commit comments

Comments
 (0)