[cfe-commits] r83038 - /cfe/trunk/lib/CodeGen/CGExprAgg.cpp
Anders Carlsson
andersca at mac.com
Mon Sep 28 18:23:40 PDT 2009
Author: andersca
Date: Mon Sep 28 20:23:39 2009
New Revision: 83038
URL: http://llvm.org/viewvc/llvm-project?rev=83038&view=rev
Log:
Use a switch statement in VisitCastExpr.
Modified:
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=83038&r1=83037&r2=83038&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Mon Sep 28 20:23:39 2009
@@ -174,27 +174,31 @@
//===----------------------------------------------------------------------===//
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) {
More information about the cfe-commits
mailing list