From: Sebastian Redl Date: Sat, 25 Feb 2012 20:51:13 +0000 (+0000) Subject: Fix crashers on unexpected std::initializer_list layouts. Found by inspection. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=babcf9d04f4ed9d7ac96812e42c9e8fc0f1ae2c2;p=clang Fix crashers on unexpected std::initializer_list layouts. Found by inspection. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151456 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index d620d3b953..ce0533c7dc 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -324,6 +324,7 @@ void AggExprEmitter::EmitStdInitializerList(llvm::Value *destPtr, RecordDecl::field_iterator field = record->field_begin(); if (field == record->field_end()) { CGF.ErrorUnsupported(initList, "weird std::initializer_list"); + return; } QualType elementPtr = ctx.getPointerType(element.withConst()); @@ -331,6 +332,7 @@ void AggExprEmitter::EmitStdInitializerList(llvm::Value *destPtr, // Start pointer. if (!ctx.hasSameType(field->getType(), elementPtr)) { CGF.ErrorUnsupported(initList, "weird std::initializer_list"); + return; } LValue start = CGF.EmitLValueForFieldInitialization(destPtr, *field, 0); llvm::Value *arrayStart = Builder.CreateStructGEP(alloc, 0, "arraystart"); @@ -339,6 +341,7 @@ void AggExprEmitter::EmitStdInitializerList(llvm::Value *destPtr, if (field == record->field_end()) { CGF.ErrorUnsupported(initList, "weird std::initializer_list"); + return; } LValue endOrLength = CGF.EmitLValueForFieldInitialization(destPtr, *field, 0); if (ctx.hasSameType(field->getType(), elementPtr)) { @@ -350,6 +353,7 @@ void AggExprEmitter::EmitStdInitializerList(llvm::Value *destPtr, CGF.EmitStoreThroughLValue(RValue::get(Builder.getInt(size)), endOrLength); } else { CGF.ErrorUnsupported(initList, "weird std::initializer_list"); + return; } if (!Dest.isExternallyDestructed())