[cfe-commits] r172770 - in /cfe/trunk: lib/Sema/TreeTransform.h test/SemaObjCXX/arc-0x.mm

Douglas Gregor dgregor at apple.com
Thu Jan 17 15:59:28 PST 2013


Author: dgregor
Date: Thu Jan 17 17:59:28 2013
New Revision: 172770

URL: http://llvm.org/viewvc/llvm-project?rev=172770&view=rev
Log:
One can override an Objective-C ARC ownership qualifier that came from
a template parameter; make that also include one that came from
'auto'. Fixes <rdar://problem/12078752>.

Modified:
    cfe/trunk/lib/Sema/TreeTransform.h
    cfe/trunk/test/SemaObjCXX/arc-0x.mm

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=172770&r1=172769&r2=172770&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Thu Jan 17 17:59:28 2013
@@ -3365,6 +3365,7 @@
       // Objective-C ARC:
       //   A lifetime qualifier applied to a substituted template parameter
       //   overrides the lifetime qualifier from the template argument.
+      const AutoType *AutoTy;
       if (const SubstTemplateTypeParmType *SubstTypeParam
                                 = dyn_cast<SubstTemplateTypeParmType>(Result)) {
         QualType Replacement = SubstTypeParam->getReplacementType();
@@ -3377,6 +3378,15 @@
                                         SubstTypeParam->getReplacedParameter(),
                                                               Replacement);
         TLB.TypeWasModifiedSafely(Result);
+      } else if ((AutoTy = dyn_cast<AutoType>(Result)) && AutoTy->isDeduced()) {
+        // 'auto' types behave the same way as template parameters.
+        QualType Deduced = AutoTy->getDeducedType();
+        Qualifiers Qs = Deduced.getQualifiers();
+        Qs.removeObjCLifetime();
+        Deduced = SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(),
+                                                   Qs);
+        Result = SemaRef.Context.getAutoType(Deduced);
+        TLB.TypeWasModifiedSafely(Result);
       } else {
         // Otherwise, complain about the addition of a qualifier to an
         // already-qualified type.

Modified: cfe/trunk/test/SemaObjCXX/arc-0x.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/arc-0x.mm?rev=172770&r1=172769&r2=172770&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/arc-0x.mm (original)
+++ cfe/trunk/test/SemaObjCXX/arc-0x.mm Thu Jan 17 17:59:28 2013
@@ -93,3 +93,11 @@
     __builtin_va_arg(args, id);
 }
 @end
+
+namespace rdar12078752 {
+  void f() {
+    NSObject* o =0;
+    __autoreleasing decltype(o) o2 = o;
+    __autoreleasing auto o3 = o;
+  }
+}





More information about the cfe-commits mailing list