aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAbramo Bagnara <abramo.bagnara@gmail.com>2011-12-13 11:23:52 +0000
committerAbramo Bagnara <abramo.bagnara@gmail.com>2011-12-13 11:23:52 +0000
commitfea966a4103ed9c018d1494b95e9d09b161f5a70 (patch)
tree8d91192df48d33f4cb0544391428486fb3656b83 /lib
parentdf512bfbc4b8c00202ea7a8c900c59ec55890676 (diff)
Added an assertion about overflow in sizeof evaluation. This does not solve the underlying structural issue that is waiting for a proper solution.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146482 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ASTContext.cpp4
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;