[cfe-commits] r72648 - in /cfe/trunk/lib/CodeGen: CGCXX.cpp CGExpr.cpp CGExprAgg.cpp CodeGenFunction.h
Anders Carlsson
andersca at mac.com
Sat May 30 16:23:33 PDT 2009
Author: andersca
Date: Sat May 30 18:23:33 2009
New Revision: 72648
URL: http://llvm.org/viewvc/llvm-project?rev=72648&view=rev
Log:
More temporary support.
Modified:
cfe/trunk/lib/CodeGen/CGCXX.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=72648&r1=72647&r2=72648&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Sat May 30 18:23:33 2009
@@ -189,6 +189,17 @@
E->arg_begin(), E->arg_end());
}
+RValue
+CodeGenFunction::EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
+ llvm::Value *AggLoc,
+ bool isAggLocVolatile) {
+ RValue RV = EmitAnyExpr(E->getSubExpr(), AggLoc, isAggLocVolatile);
+
+ // FIXME: Handle the temporaries.
+
+ return RV;
+}
+
static bool canGenerateCXXstructor(const CXXRecordDecl *RD,
ASTContext &Context) {
// The class has base classes - we don't support that right now.
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=72648&r1=72647&r2=72648&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Sat May 30 18:23:33 2009
@@ -189,7 +189,10 @@
case Expr::CXXConditionDeclExprClass:
return EmitCXXConditionDeclLValue(cast<CXXConditionDeclExpr>(E));
-
+ case Expr::CXXTemporaryObjectExprClass:
+ case Expr::CXXConstructExprClass:
+ return EmitCXXConstructLValue(cast<CXXConstructExpr>(E));
+
case Expr::ObjCMessageExprClass:
return EmitObjCMessageExprLValue(cast<ObjCMessageExpr>(E));
case Expr::ObjCIvarRefExprClass:
@@ -1198,6 +1201,12 @@
return EmitDeclRefLValue(E);
}
+LValue CodeGenFunction::EmitCXXConstructLValue(const CXXConstructExpr *E) {
+ llvm::Value *Temp = CreateTempAlloca(ConvertTypeForMem(E->getType()), "tmp");
+ EmitCXXConstructExpr(Temp, E);
+ return LValue::MakeAddr(Temp, E->getType().getCVRQualifiers());
+}
+
LValue CodeGenFunction::EmitObjCMessageExprLValue(const ObjCMessageExpr *E) {
// Can only get l-value for message expression returning aggregate type
RValue RV = EmitObjCMessageExpr(E);
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=72648&r1=72647&r2=72648&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Sat May 30 18:23:33 2009
@@ -105,6 +105,7 @@
void VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
Visit(DAE->getExpr());
}
+ void VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E);
void VisitCXXConstructExpr(const CXXConstructExpr *E);
void VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E);
@@ -290,16 +291,36 @@
EmitFinalDestCopy(VE, LValue::MakeAddr(ArgPtr, 0));
}
+void AggExprEmitter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
+ llvm::Value *Val = DestPtr;
+
+ if (!Val) {
+ // Create a temporary variable.
+ Val = CGF.CreateTempAlloca(CGF.ConvertTypeForMem(E->getType()), "tmp");
+
+ // FIXME: volatile
+ CGF.EmitAggExpr(E->getSubExpr(), Val, false);
+ } else
+ Visit(E->getSubExpr());
+
+ // FIXME: Record the value and dest ptr.
+ Val->dump();
+}
+
void
AggExprEmitter::VisitCXXConstructExpr(const CXXConstructExpr *E) {
- assert(DestPtr && "Must have somewhere to emit into!");
+ llvm::Value *Val = DestPtr;
+
+ if (!Val) {
+ // Create a temporary variable.
+ Val = CGF.CreateTempAlloca(CGF.ConvertTypeForMem(E->getType()), "tmp");
+ }
- CGF.EmitCXXConstructExpr(DestPtr, E);
+ CGF.EmitCXXConstructExpr(Val, E);
}
void AggExprEmitter::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *E) {
- // FIXME: Do something with the temporaries!
- Visit(E->getSubExpr());
+ CGF.EmitCXXExprWithTemporaries(E, DestPtr, VolatileDest);
}
void AggExprEmitter::EmitInitializationToLValue(Expr* E, LValue LV) {
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=72648&r1=72647&r2=72648&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Sat May 30 18:23:33 2009
@@ -653,7 +653,8 @@
LValue EmitBlockDeclRefLValue(const BlockDeclRefExpr *E);
LValue EmitCXXConditionDeclLValue(const CXXConditionDeclExpr *E);
-
+ LValue EmitCXXConstructLValue(const CXXConstructExpr *E);
+
LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E);
LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E);
LValue EmitObjCPropertyRefLValue(const ObjCPropertyRefExpr *E);
@@ -783,6 +784,10 @@
void EmitCXXConstructExpr(llvm::Value *Dest, const CXXConstructExpr *E);
+ RValue EmitCXXExprWithTemporaries(const CXXExprWithTemporaries *E,
+ llvm::Value *AggLoc = 0,
+ bool isAggLocVolatile = false);
+
//===--------------------------------------------------------------------===//
// Internal Helpers
//===--------------------------------------------------------------------===//
More information about the cfe-commits
mailing list