super and class property reference expressions don't need to be
rebuilt. Fixes <rdar://problem/11052352>. 



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154667 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaPseudoObject.cpp b/lib/Sema/SemaPseudoObject.cpp
index d52c912..3b2cf8d 100644
--- a/lib/Sema/SemaPseudoObject.cpp
+++ b/lib/Sema/SemaPseudoObject.cpp
@@ -1300,8 +1300,13 @@
   Expr *opaqueRef = E->IgnoreParens();
   if (ObjCPropertyRefExpr *refExpr
         = dyn_cast<ObjCPropertyRefExpr>(opaqueRef)) {
-    OpaqueValueExpr *baseOVE = cast<OpaqueValueExpr>(refExpr->getBase());
-    return ObjCPropertyRefRebuilder(S, baseOVE->getSourceExpr()).rebuild(E);
+    if (refExpr->isObjectReceiver()) {
+      OpaqueValueExpr *baseOVE = cast<OpaqueValueExpr>(refExpr->getBase());
+      return ObjCPropertyRefRebuilder(S, baseOVE->getSourceExpr()).rebuild(E);
+    }
+
+    // Neither class or super property references need a rebuild.
+    return E;
   } else if (ObjCSubscriptRefExpr *refExpr
                = dyn_cast<ObjCSubscriptRefExpr>(opaqueRef)) {
     OpaqueValueExpr *baseOVE = cast<OpaqueValueExpr>(refExpr->getBaseExpr());
diff --git a/test/SemaObjCXX/property-reference.mm b/test/SemaObjCXX/property-reference.mm
index 18f0604..b86ae5e 100644
--- a/test/SemaObjCXX/property-reference.mm
+++ b/test/SemaObjCXX/property-reference.mm
@@ -42,3 +42,18 @@
 	cppObjectNonAtomic = cppObject;
 }
 @end
+
+
+// <rdar://problem/11052352>
+@interface NSObject
++ alloc;
+- init;
+- class;
+@end
+
+template<typename T> void f() {
+  NSObject *o = [NSObject.alloc init];
+  [o class];
+}
+
+template void f<int>();