From 3016842613674ab80796567239c15d529aff1458 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Tue, 29 Sep 2009 01:23:39 +0000 Subject: [PATCH] Use a switch statement in VisitCastExpr. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83038 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprAgg.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index e19fb0065f..f710b036a6 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -174,27 +174,31 @@ void AggExprEmitter::EmitFinalDestCopy(const Expr *E, LValue Src, bool Ignore) { //===----------------------------------------------------------------------===// void AggExprEmitter::VisitCastExpr(CastExpr *E) { - if (E->getCastKind() == CastExpr::CK_ToUnion) { + switch (E->getCastKind()) { + default: assert(0 && "Unhandled cast kind!"); + + case CastExpr::CK_ToUnion: { // GCC union extension QualType PtrTy = - CGF.getContext().getPointerType(E->getSubExpr()->getType()); + CGF.getContext().getPointerType(E->getSubExpr()->getType()); llvm::Value *CastPtr = Builder.CreateBitCast(DestPtr, CGF.ConvertType(PtrTy)); EmitInitializationToLValue(E->getSubExpr(), LValue::MakeAddr(CastPtr, Qualifiers())); - return; + break; } // FIXME: Remove the CK_Unknown check here. - assert((E->getCastKind() == CastExpr::CK_NoOp || - E->getCastKind() == CastExpr::CK_Unknown || - E->getCastKind() == CastExpr::CK_UserDefinedConversion || - E->getCastKind() == CastExpr::CK_ConstructorConversion) && - "Only no-op casts allowed!"); - assert(CGF.getContext().hasSameUnqualifiedType(E->getSubExpr()->getType(), - E->getType()) && - "Implicit cast types must be compatible"); - Visit(E->getSubExpr()); + case CastExpr::CK_Unknown: + case CastExpr::CK_NoOp: + case CastExpr::CK_UserDefinedConversion: + case CastExpr::CK_ConstructorConversion: + assert(CGF.getContext().hasSameUnqualifiedType(E->getSubExpr()->getType(), + E->getType()) && + "Implicit cast types must be compatible"); + Visit(E->getSubExpr()); + break; + } } void AggExprEmitter::VisitCallExpr(const CallExpr *E) { -- 2.40.0