r252668 - Define __unsafe_unretained and __autoreleasing in ObjC GC mode.

John McCall via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 10 15:00:25 PST 2015


Author: rjmccall
Date: Tue Nov 10 17:00:25 2015
New Revision: 252668

URL: http://llvm.org/viewvc/llvm-project?rev=252668&view=rev
Log:
Define __unsafe_unretained and __autoreleasing in ObjC GC mode.

This was an accidental regression from the MRC __weak patch.

Modified:
    cfe/trunk/lib/Frontend/InitPreprocessor.cpp
    cfe/trunk/test/SemaObjC/gc-attributes.m

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=252668&r1=252667&r2=252668&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Nov 10 17:00:25 2015
@@ -867,6 +867,8 @@ static void InitializePredefinedMacros(c
       LangOpts.getGC() != LangOptions::NonGC) {
     Builder.defineMacro("__weak", "__attribute__((objc_gc(weak)))");
     Builder.defineMacro("__strong", "__attribute__((objc_gc(strong)))");
+    Builder.defineMacro("__autoreleasing", "");
+    Builder.defineMacro("__unsafe_unretained", "");
   } else if (LangOpts.ObjC1) {
     Builder.defineMacro("__weak", "__attribute__((objc_ownership(weak)))");
     Builder.defineMacro("__strong", "__attribute__((objc_ownership(strong)))");

Modified: cfe/trunk/test/SemaObjC/gc-attributes.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/gc-attributes.m?rev=252668&r1=252667&r2=252668&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/gc-attributes.m (original)
+++ cfe/trunk/test/SemaObjC/gc-attributes.m Tue Nov 10 17:00:25 2015
@@ -20,3 +20,7 @@ void test_f1() {
   f1(&a);
   f1(&a2); // expected-warning{{passing 'A *__strong *' to parameter of type 'A *__weak *' discards qualifiers}} 
 }
+
+// These qualifiers should silently expand to nothing in GC mode.
+void test_unsafe_unretained(__unsafe_unretained id *x) {}
+void test_autoreleasing(__autoreleasing id *x) {}




More information about the cfe-commits mailing list