From: Argyrios Kyrtzidis Date: Wed, 10 Sep 2008 02:36:38 +0000 (+0000) Subject: Implement CodeGen support for the 'CXXConditionDeclExpr' expression node, which repre... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e3a09e6ad09f8d1387ecaa008aaf85527909da0a;p=clang Implement CodeGen support for the 'CXXConditionDeclExpr' expression node, which represents a 'condition' declaration, e.g: "if (int x=0) {...}". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56045 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index f8dc9dcd43..cafe5761ca 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -121,6 +121,9 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) { case Expr::StringLiteralClass: return EmitStringLiteralLValue(cast(E)); + case Expr::CXXConditionDeclExprClass: + return EmitCXXConditionDeclLValue(cast(E)); + case Expr::ObjCMessageExprClass: return EmitObjCMessageExprLValue(cast(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); diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 5054b56d21..263a0f2f53 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -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 @@ -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); diff --git a/test/CodeGen/cxx-condition.cpp b/test/CodeGen/cxx-condition.cpp new file mode 100644 index 0000000000..746aadda55 --- /dev/null +++ b/test/CodeGen/cxx-condition.cpp @@ -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) { } +}