]> granicus.if.org Git - clang/commitdiff
IRGen. Fix IR when message returns reference type.
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 2 Mar 2011 20:09:49 +0000 (20:09 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 2 Mar 2011 20:09:49 +0000 (20:09 +0000)
// rdar://8604515.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126869 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExprScalar.cpp
test/CodeGenObjCXX/message-reference.mm [new file with mode: 0644]

index b11236a97f8e0b9be8712a021cae91b1161fc5fb..6f52a539cf607258114d819631abb045ac34da03 100644 (file)
@@ -245,6 +245,9 @@ public:
     return EmitLoadOfLValue(E);
   }
   Value *VisitObjCMessageExpr(ObjCMessageExpr *E) {
+    if (E->getMethodDecl() && 
+        E->getMethodDecl()->getResultType()->isReferenceType())
+      return EmitLoadOfLValue(E);
     return CGF.EmitObjCMessageExpr(E).getScalarVal();
   }
 
diff --git a/test/CodeGenObjCXX/message-reference.mm b/test/CodeGenObjCXX/message-reference.mm
new file mode 100644 (file)
index 0000000..b7cf98d
--- /dev/null
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
+// rdar://8604515
+
+@interface I {}
+-(unsigned int&)referenceCount;
+@end
+
+@interface MyClass
++(int)writeBlip:(I*)srcBlip;
+@end
+
+@implementation MyClass
++(int)writeBlip:(I*)srcBlip{
+  return ([srcBlip referenceCount] == 0);
+}
+@end
+
+// CHECK: [[T:%.*]] = call i32* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
+// CHECK: [[U:%.*]] = load i32* [[T]]
+// CHECK  [[V:%.*]] = icmp eq i32 [[U]], 0