Objective-C fast enumeration loop variables are not retained in ARC, but
they should still be officially __strong for the purposes of errors, 
block capture, etc.  Make a new bit on variables, isARCPseudoStrong(),
and set this for 'self' and these enumeration-loop variables.  Change
the code that was looking for the old patterns to look for this bit,
and change IR generation to find this bit and treat the resulting         
variable as __unsafe_unretained for the purposes of init/destroy in
the two places it can come up.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133243 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index cdc2fff..ce9c262 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -1110,6 +1110,9 @@
     elementLValue = EmitLValue(&tempDRE);
     elementType = D->getType();
     elementIsVariable = true;
+
+    if (D->isARCPseudoStrong())
+      elementLValue.getQuals().setObjCLifetime(Qualifiers::OCL_ExplicitNone);
   } else {
     elementLValue = LValue(); // suppress warning
     elementType = cast<Expr>(S.getElement())->getType();
@@ -1136,10 +1139,12 @@
 
   // Make sure we have an l-value.  Yes, this gets evaluated every
   // time through the loop.
-  if (!elementIsVariable)
+  if (!elementIsVariable) {
     elementLValue = EmitLValue(cast<Expr>(S.getElement()));
-
-  EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue, elementType);
+    EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue, elementType);
+  } else {
+    EmitScalarInit(CurrentItem, elementLValue);
+  }
 
   // If we do have an element variable, this assignment is the end of
   // its initialization.