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.

llvm-svn: 133243
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 99eb0d3..67f6531 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -474,19 +474,22 @@
   } else // we have a factory method.
     selfTy = Context.getObjCClassType();
 
+  bool selfIsPseudoStrong = false;
   bool selfIsConsumed = false;
   if (isInstanceMethod() && Context.getLangOptions().ObjCAutoRefCount) {
     selfIsConsumed = hasAttr<NSConsumesSelfAttr>();
 
-    // 'self' is always __strong, although as a special case we don't
-    // actually retain it except in init methods.
+    // 'self' is always __strong.  It's actually pseudo-strong except
+    // in init methods, though.
     Qualifiers qs;
     qs.setObjCLifetime(Qualifiers::OCL_Strong);
     selfTy = Context.getQualifiedType(selfTy, qs);
 
     // In addition, 'self' is const unless this is an init method.
-    if (getMethodFamily() != OMF_init)
+    if (getMethodFamily() != OMF_init) {
       selfTy = selfTy.withConst();
+      selfIsPseudoStrong = true;
+    }
   }
 
   ImplicitParamDecl *self
@@ -497,6 +500,9 @@
   if (selfIsConsumed)
     self->addAttr(new (Context) NSConsumedAttr(SourceLocation(), Context));
 
+  if (selfIsPseudoStrong)
+    self->setARCPseudoStrong(true);
+
   setCmdDecl(ImplicitParamDecl::Create(Context, this, SourceLocation(),
                                        &Context.Idents.get("_cmd"),
                                        Context.getObjCSelType()));