diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/ASTContext.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 47994f495f..32ef0b9c60 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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; |