[cfe-commits] r39831 - in /cfe/trunk/CodeGen: CGExpr.cpp CodeGenFunction.h
Chris Lattner
sabre at nondot.org
Fri Jul 13 13:25:53 PDT 2007
Author: lattner
Date: Fri Jul 13 15:25:53 2007
New Revision: 39831
URL: http://llvm.org/viewvc/llvm-project?rev=39831&view=rev
Log:
implement codegen support for implicit casts.
Modified:
cfe/trunk/CodeGen/CGExpr.cpp
cfe/trunk/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExpr.cpp?rev=39831&r1=39830&r2=39831&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGExpr.cpp Fri Jul 13 15:25:53 2007
@@ -472,8 +472,10 @@
return EmitExpr(cast<ParenExpr>(E)->getSubExpr());
case Expr::UnaryOperatorClass:
return EmitUnaryOperator(cast<UnaryOperator>(E));
+ case Expr::ImplicitCastExprClass:
+ return EmitCastExpr(cast<ImplicitCastExpr>(E)->getSubExpr(), E->getType());
case Expr::CastExprClass:
- return EmitCastExpr(cast<CastExpr>(E));
+ return EmitCastExpr(cast<CastExpr>(E)->getSubExpr(), E->getType());
case Expr::CallExprClass:
return EmitCallExpr(cast<CallExpr>(E));
case Expr::BinaryOperatorClass:
@@ -518,16 +520,18 @@
return RValue::get(Builder.CreateExtractElement(Base, Idx, "vecext"));
}
-
-RValue CodeGenFunction::EmitCastExpr(const CastExpr *E) {
+// EmitCastExpr - Emit code for an explicit or implicit cast. Implicit casts
+// have to handle a more broad range of conversions than explicit casts, as they
+// handle things like function to ptr-to-function decay etc.
+RValue CodeGenFunction::EmitCastExpr(const Expr *Op, QualType DestTy) {
QualType SrcTy;
- RValue Src = EmitExprWithUsualUnaryConversions(E->getSubExpr(), SrcTy);
+ RValue Src = EmitExprWithUsualUnaryConversions(Op, SrcTy);
// If the destination is void, just evaluate the source.
- if (E->getType()->isVoidType())
+ if (DestTy->isVoidType())
return RValue::getAggregate(0);
- return EmitConversion(Src, SrcTy, E->getType());
+ return EmitConversion(Src, SrcTy, DestTy);
}
RValue CodeGenFunction::EmitCallExpr(const CallExpr *E) {
Modified: cfe/trunk/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CodeGenFunction.h?rev=39831&r1=39830&r2=39831&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/CodeGen/CodeGenFunction.h Fri Jul 13 15:25:53 2007
@@ -313,7 +313,7 @@
RValue EmitFloatingLiteral(const FloatingLiteral *E);
RValue EmitCharacterLiteral(const CharacterLiteral *E);
- RValue EmitCastExpr(const CastExpr *E);
+ RValue EmitCastExpr(const Expr *Op, QualType DestTy);
RValue EmitCallExpr(const CallExpr *E);
RValue EmitArraySubscriptExprRV(const ArraySubscriptExpr *E);
More information about the cfe-commits
mailing list