Add a sanity check for constant expression casts
authorChris Lattner <sabre@nondot.org>
Tue, 7 Oct 2003 22:19:19 +0000 (22:19 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 7 Oct 2003 22:19:19 +0000 (22:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8951 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Constants.cpp

index 3e481fd0481e236b1b8e9ecd7db32f3dcae5779d..4e1d905fecbf0f73bc9a48634b09def5d9f1e85d 100644 (file)
@@ -897,6 +897,8 @@ struct ConvertConstantType<ConstantExpr, Type> {
 static ValueMap<ExprMapKeyType, Type, ConstantExpr> ExprConstants;
 
 Constant *ConstantExpr::getCast(Constant *C, const Type *Ty) {
+  assert(Ty->isFirstClassType() && "Cannot cast to an aggregate type!");
+
   if (Constant *FC = ConstantFoldCastInstruction(C, Ty))
     return FC;          // Fold a few common cases...