Handle reference properties correctly in the trivial-getter check.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139585 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index f0a47af..ca04a7b 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -564,13 +564,19 @@
   FinishFunction();
 }
 
-static bool hasTrivialGetExpr(const ObjCPropertyImplDecl *PID) {
-  const Expr *getter = PID->getGetterCXXConstructor();
+static bool hasTrivialGetExpr(const ObjCPropertyImplDecl *propImpl) {
+  const Expr *getter = propImpl->getGetterCXXConstructor();
   if (!getter) return true;
 
   // Sema only makes only of these when the ivar has a C++ class type,
   // so the form is pretty constrained.
 
+  // If the property has a reference type, we might just be binding a
+  // reference, in which case the result will be a gl-value.  We should
+  // treat this as a non-trivial operation.
+  if (getter->isGLValue())
+    return false;
+
   // If we selected a trivial copy-constructor, we're okay.
   if (const CXXConstructExpr *construct = dyn_cast<CXXConstructExpr>(getter))
     return (construct->getConstructor()->isTrivial());