From: John McCall Date: Thu, 16 Jun 2011 00:03:19 +0000 (+0000) Subject: Unconditionally #define the ARC ownership qualifiers, instead of #defining X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=098df7f1de80527d7a70e410a5830c8b2d742310;p=clang Unconditionally #define the ARC ownership qualifiers, instead of #defining them only on Darwin tool chains. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133112 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 541a1ed595..40840275da 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -84,14 +84,7 @@ static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts, Builder.defineMacro("__MACH__"); Builder.defineMacro("OBJC_NEW_PROPERTIES"); - if (Opts.ObjCAutoRefCount) { - Builder.defineMacro("__weak", "__attribute__((objc_lifetime(weak)))"); - Builder.defineMacro("__strong", "__attribute__((objc_lifetime(strong)))"); - Builder.defineMacro("__autoreleasing", - "__attribute__((objc_lifetime(autoreleasing)))"); - Builder.defineMacro("__unsafe_unretained", - "__attribute__((objc_lifetime(none)))"); - } else { + if (!Opts.ObjCAutoRefCount) { // __weak is always defined, for use in blocks and with objc pointers. Builder.defineMacro("__weak", "__attribute__((objc_gc(weak)))"); diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index f1e1d47713..e1c394ea75 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -606,6 +606,15 @@ static void InitializePredefinedMacros(const TargetInfo &TI, if (LangOpts.FastRelaxedMath) Builder.defineMacro("__FAST_RELAXED_MATH__"); + if (LangOpts.ObjCAutoRefCount) { + Builder.defineMacro("__weak", "__attribute__((objc_lifetime(weak)))"); + Builder.defineMacro("__strong", "__attribute__((objc_lifetime(strong)))"); + Builder.defineMacro("__autoreleasing", + "__attribute__((objc_lifetime(autoreleasing)))"); + Builder.defineMacro("__unsafe_unretained", + "__attribute__((objc_lifetime(none)))"); + } + // Get other target #defines. TI.getTargetDefines(LangOpts, Builder); }