Implement CodeGen support for the 'CXXConditionDeclExpr' expression node, which represents a 'condition' declaration, e.g: "if (int x=0) {...}".

llvm-svn: 56045
This commit is contained in:
Argyrios Kyrtzidis 2008-09-10 02:36:38 +00:00
parent 7620ee4550
commit 07052350f0
3 changed files with 21 additions and 0 deletions

View File

@ -121,6 +121,9 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) {
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 @@ LValue CodeGenFunction::EmitCallExprLValue(const CallExpr *E) {
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);

View File

@ -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 @@ public:
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);

View File

@ -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) { }
}