[cfe-commits] r142249 - in /cfe/trunk: lib/Sema/SemaExprMember.cpp test/CodeGenObjCXX/lvalue-reference-getter.mm

Fariborz Jahanian fjahanian at apple.com
Mon Oct 17 14:00:23 PDT 2011


Author: fjahanian
Date: Mon Oct 17 16:00:22 2011
New Revision: 142249

URL: http://llvm.org/viewvc/llvm-project?rev=142249&view=rev
Log:
obj-c++: Fix a IRGen crash when getter is a reference type.
Fix is in Sema. // rdar://10153365

Added:
    cfe/trunk/test/CodeGenObjCXX/lvalue-reference-getter.mm
Modified:
    cfe/trunk/lib/Sema/SemaExprMember.cpp

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=142249&r1=142248&r2=142249&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Mon Oct 17 16:00:22 2011
@@ -813,6 +813,15 @@
       !SuppressQualifierCheck &&
       CheckQualifiedMemberReference(BaseExpr, BaseType, SS, R))
     return ExprError();
+  
+  // Perform a property load on the base regardless of whether we
+  // actually need it for the declaration.
+  if (BaseExpr && BaseExpr->getObjectKind() == OK_ObjCProperty) {
+    ExprResult Result = ConvertPropertyForRValue(BaseExpr);
+    if (Result.isInvalid())
+      return ExprError();
+    BaseExpr = Result.take();
+  }
 
   // Construct an unresolved result if we in fact got an unresolved
   // result.
@@ -870,15 +879,6 @@
     return ExprError();
   }
 
-  // Perform a property load on the base regardless of whether we
-  // actually need it for the declaration.
-  if (BaseExpr->getObjectKind() == OK_ObjCProperty) {
-    ExprResult Result = ConvertPropertyForRValue(BaseExpr);
-    if (Result.isInvalid())
-      return ExprError();
-    BaseExpr = Result.take();
-  }
-
   if (FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl))
     return BuildFieldReferenceExpr(*this, BaseExpr, IsArrow,
                                    SS, FD, FoundDecl, MemberNameInfo);

Added: cfe/trunk/test/CodeGenObjCXX/lvalue-reference-getter.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/lvalue-reference-getter.mm?rev=142249&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjCXX/lvalue-reference-getter.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/lvalue-reference-getter.mm Mon Oct 17 16:00:22 2011
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// rdar://10153365
+
+static int gint;
+struct SetSection { 
+      int & at(int __n) { return gint; }
+      const int& at(int __n) const { return gint; }
+};
+
+static SetSection gSetSection;
+
+ at interface SetShow
+- (SetSection&)sections;
+ at end
+
+ at implementation SetShow
+- (SetSection&) sections {
+//  [self sections].at(100);
+    self.sections.at(100);
+   return gSetSection;
+}
+ at end
+
+// CHECK: [[SELF:%.*]] = alloca [[T6:%.*]]*, align
+// CHECK: [[T0:%.*]] = load {{.*}}* [[SELF]], align
+// CHECK: [[T1:%.*]] = load {{.*}}* @"\01L_OBJC_SELECTOR_REFERENCES_"
+// CHECK: [[C:%.*]] = call %struct.SetSection* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: call i32* @_ZN10SetSection2atEi(%struct.SetSection* [[C]]





More information about the cfe-commits mailing list