[cfe-commits] r146482 - /cfe/trunk/lib/AST/ASTContext.cpp

Abramo Bagnara abramo.bagnara at gmail.com
Tue Dec 13 03:23:52 PST 2011


Author: abramo
Date: Tue Dec 13 05:23:52 2011
New Revision: 146482

URL: http://llvm.org/viewvc/llvm-project?rev=146482&view=rev
Log:
Added an assertion about overflow in sizeof evaluation. This does not solve the underlying structural issue that is waiting for a proper solution.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=146482&r1=146481&r2=146482&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Dec 13 05:23:52 2011
@@ -852,7 +852,9 @@
     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;





More information about the cfe-commits mailing list