[cfe-commits] r114783 - in /cfe/trunk: lib/Sema/SemaExprCXX.cpp test/CodeGenObjCXX/property-object-conditional-exp.mm
Fariborz Jahanian
fjahanian at apple.com
Fri Sep 24 18:08:05 PDT 2010
Author: fjahanian
Date: Fri Sep 24 20:08:05 2010
New Revision: 114783
URL: http://llvm.org/viewvc/llvm-project?rev=114783&view=rev
Log:
Fix a NYI in IRGen which was due to incorrect AST
for property reference expression (of c++ object type)
in the conditional expression. Fixes // rdar://8291337
Added:
cfe/trunk/test/CodeGenObjCXX/property-object-conditional-exp.mm
Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp
Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=114783&r1=114782&r2=114783&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Fri Sep 24 20:08:05 2010
@@ -2592,8 +2592,16 @@
// the result is of that type [...]
bool Same = Context.hasSameType(LTy, RTy);
if (Same && LHS->isLvalue(Context) == Expr::LV_Valid &&
- RHS->isLvalue(Context) == Expr::LV_Valid)
- return LTy;
+ RHS->isLvalue(Context) == Expr::LV_Valid) {
+ // In this context, property reference is really a message call and
+ // is not considered an l-value.
+ bool lhsProperty = (isa<ObjCPropertyRefExpr>(LHS) ||
+ isa<ObjCImplicitSetterGetterRefExpr>(LHS));
+ bool rhsProperty = (isa<ObjCPropertyRefExpr>(RHS) ||
+ isa<ObjCImplicitSetterGetterRefExpr>(RHS));
+ if (!lhsProperty && !rhsProperty)
+ return LTy;
+ }
// C++0x 5.16p5
// Otherwise, the result is an rvalue. If the second and third operands
Added: cfe/trunk/test/CodeGenObjCXX/property-object-conditional-exp.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/property-object-conditional-exp.mm?rev=114783&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/property-object-conditional-exp.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/property-object-conditional-exp.mm Fri Sep 24 20:08:05 2010
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s
+
+struct CGRect {
+ char* origin;
+ unsigned size;
+};
+typedef struct CGRect CGRect;
+
+extern "C" bool CGRectIsEmpty(CGRect);
+
+ at interface Foo {
+ CGRect out;
+}
+ at property CGRect bounds;
+- (CGRect) out;
+ at end
+
+
+ at implementation Foo
+
+- (void)bar {
+ CGRect dataRect;
+ CGRect virtualBounds;
+
+ dataRect = CGRectIsEmpty(virtualBounds) ? self.bounds : virtualBounds;
+ dataRect = CGRectIsEmpty(virtualBounds) ? [self bounds] : virtualBounds;
+ dataRect = CGRectIsEmpty(virtualBounds) ? virtualBounds : self.bounds;
+
+ dataRect = CGRectIsEmpty(virtualBounds) ? self.out : virtualBounds;
+ dataRect = CGRectIsEmpty(virtualBounds) ? [self out] : virtualBounds;
+ dataRect = CGRectIsEmpty(virtualBounds) ? virtualBounds : self.out;
+}
+
+ at dynamic bounds;
+- (CGRect) out { return out; }
+ at end
More information about the cfe-commits
mailing list