Added an assertion about overflow in sizeof evaluation. This does not solve the underlying structural issue that is waiting for a proper solution.

llvm-svn: 146482
This commit is contained in:
Abramo Bagnara 2011-12-13 11:23:52 +00:00
parent 2f1d93ffe0
commit d541a4c70d
1 changed files with 3 additions and 1 deletions

View File

@ -852,7 +852,9 @@ ASTContext::getTypeInfo(const Type *T) const {
const ConstantArrayType *CAT = cast<ConstantArrayType>(T);
std::pair<uint64_t, unsigned> EltInfo = getTypeInfo(CAT->getElementType());
Width = EltInfo.first*CAT->getSize().getZExtValue();
uint64_t Size = CAT->getSize().getZExtValue();
assert((Size == 0 || EltInfo.first <= (uint64_t)(-1)/Size) && "Overflow in array type bit size evaluation");
Width = EltInfo.first*Size;
Align = EltInfo.second;
Width = llvm::RoundUpToAlignment(Width, Align);
break;