[cfe-commits] r56045 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp lib/CodeGen/CodeGenFunction.h test/CodeGen/cxx-condition.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Tue Sep 9 19:36:39 PDT 2008
Author: akirtzidis
Date: Tue Sep 9 21:36:38 2008
New Revision: 56045
URL: http://llvm.org/viewvc/llvm-project?rev=56045&view=rev
Log:
Implement CodeGen support for the 'CXXConditionDeclExpr' expression node, which represents a 'condition' declaration, e.g: "if (int x=0) {...}".
Added:
cfe/trunk/test/CodeGen/cxx-condition.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=56045&r1=56044&r2=56045&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Sep 9 21:36:38 2008
@@ -121,6 +121,9 @@
case Expr::StringLiteralClass:
return EmitStringLiteralLValue(cast<StringLiteral>(E));
+ case Expr::CXXConditionDeclExprClass:
+ return EmitCXXConditionDeclLValue(cast<CXXConditionDeclExpr>(E));
+
case Expr::ObjCMessageExprClass:
return EmitObjCMessageExprLValue(cast<ObjCMessageExpr>(E));
case Expr::ObjCIvarRefExprClass:
@@ -786,6 +789,12 @@
E->getType().getCVRQualifiers());
}
+LValue
+CodeGenFunction::EmitCXXConditionDeclLValue(const CXXConditionDeclExpr *E) {
+ EmitLocalBlockVarDecl(*E->getVarDecl());
+ return EmitDeclRefLValue(E);
+}
+
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/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=56045&r1=56044&r2=56045&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Sep 9 21:36:38 2008
@@ -19,6 +19,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/IRBuilder.h"
#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include <vector>
@@ -333,6 +334,8 @@
LValue EmitLValueForField(llvm::Value* Base, FieldDecl* Field,
bool isUnion, unsigned CVRQualifiers);
+ LValue EmitCXXConditionDeclLValue(const CXXConditionDeclExpr *E);
+
LValue EmitObjCMessageExprLValue(const ObjCMessageExpr *E);
LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E);
LValue EmitObjCPropertyRefLValue(const ObjCPropertyRefExpr *E);
Added: cfe/trunk/test/CodeGen/cxx-condition.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cxx-condition.cpp?rev=56045&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/cxx-condition.cpp (added)
+++ cfe/trunk/test/CodeGen/cxx-condition.cpp Tue Sep 9 21:36:38 2008
@@ -0,0 +1,9 @@
+// RUN: clang -emit-llvm %s -o %t
+
+void f() {
+ int a;
+ if (int x=a) ++a; else a=x;
+ while (int x=a) ++a;
+ for (; int x=a; --a) ;
+ switch (int x=0) { }
+}
More information about the cfe-commits
mailing list