[cfe-commits] r68494 - in /cfe/trunk/lib: Basic/Targets.cpp Lex/Preprocessor.cpp
Fariborz Jahanian
fjahanian at apple.com
Tue Apr 7 09:37:44 PDT 2009
On Apr 6, 2009, at 9:48 PM, Chris Lattner wrote:
> Author: lattner
> Date: Mon Apr 6 23:48:21 2009
> New Revision: 68494
>
> URL: http://llvm.org/viewvc/llvm-project?rev=68494&view=rev
> Log:
> The __weak and __strong defines are common to all darwin targets
> and are even set in C mode. As such, move them to Targets.cpp.
>
> __OBJC_GC__ is also darwin specific, but seems reasonable to always
> define it when in objc-gc mode.
>
> This fixes rdar://6761450
>
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/lib/Lex/Preprocessor.cpp
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=68494&r1=68493&r2=68494&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Mon Apr 6 23:48:21 2009
> @@ -138,11 +138,21 @@
> return true;
> }
>
> -static void getDarwinDefines(std::vector<char> &Defs, const char
> *Triple) {
> +static void getDarwinDefines(std::vector<char> &Defs, const
> LangOptions &Opts,
> + const char *Triple) {
> Define(Defs, "__APPLE__");
> Define(Defs, "__MACH__");
> Define(Defs, "OBJC_NEW_PROPERTIES");
>
> + // Darwin defines __weak and __strong even in C mode.
> + if (!Opts.ObjC1 || Opts.getGCMode() == LangOptions::NonGC) {
> + Define(Defs, "__weak", "");
__weak should always we defined to weak attribute. It is used for
blocks.
Have we implemented __weak __block objects (See radar 5847976 for
details)?
- Fariborz
>
> + Define(Defs, "__strong", "");
> + } else {
> + Define(Defs, "__weak", "__attribute__((objc_gc(weak)))");
> + Define(Defs, "__strong", "__attribute__((objc_gc(strong)))");
> + }
> +
> // FIXME: OBJC_ZEROCOST_EXCEPTIONS when using zero cost eh.
>
> // Figure out which "darwin number" the target triple is.
> "darwin9" -> 10.5.
> @@ -375,7 +385,7 @@
> virtual void getTargetDefines(const LangOptions &Opts,
> std::vector<char> &Defines) const {
> PPC32TargetInfo::getTargetDefines(Opts, Defines);
> - getDarwinDefines(Defines, getTargetTriple());
> + getDarwinDefines(Defines, Opts, getTargetTriple());
> }
>
> /// getDefaultLangOptions - Allow the target to specify default
> settings for
> @@ -394,7 +404,7 @@
> virtual void getTargetDefines(const LangOptions &Opts,
> std::vector<char> &Defines) const {
> PPC64TargetInfo::getTargetDefines(Opts, Defines);
> - getDarwinDefines(Defines, getTargetTriple());
> + getDarwinDefines(Defines, Opts, getTargetTriple());
> }
>
> /// getDefaultLangOptions - Allow the target to specify default
> settings for
> @@ -674,7 +684,7 @@
> virtual void getTargetDefines(const LangOptions &Opts,
> std::vector<char> &Defines) const {
> X86_32TargetInfo::getTargetDefines(Opts, Defines);
> - getDarwinDefines(Defines, getTargetTriple());
> + getDarwinDefines(Defines, Opts, getTargetTriple());
> }
>
> /// getDefaultLangOptions - Allow the target to specify default
> settings for
> @@ -835,7 +845,7 @@
> virtual void getTargetDefines(const LangOptions &Opts,
> std::vector<char> &Defines) const {
> X86_64TargetInfo::getTargetDefines(Opts, Defines);
> - getDarwinDefines(Defines, getTargetTriple());
> + getDarwinDefines(Defines, Opts, getTargetTriple());
> }
>
> /// getDefaultLangOptions - Allow the target to specify default
> settings for
> @@ -923,7 +933,7 @@
> virtual void getTargetDefines(const LangOptions &Opts,
> std::vector<char> &Defines) const {
> ARMTargetInfo::getTargetDefines(Opts, Defines);
> - getDarwinDefines(Defines, getTargetTriple());
> + getDarwinDefines(Defines, Opts, getTargetTriple());
> }
> };
> } // end anonymous namespace.
>
> Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=68494&r1=68493&r2=68494&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
> +++ cfe/trunk/lib/Lex/Preprocessor.cpp Mon Apr 6 23:48:21 2009
> @@ -500,15 +500,9 @@
> if (PP.getLangOptions().ObjCNonFragileABI)
> DefineBuiltinMacro(Buf, "__OBJC2__=1");
>
> - if (PP.getLangOptions().getGCMode() == LangOptions::NonGC) {
> - DefineBuiltinMacro(Buf, "__weak=");
> - DefineBuiltinMacro(Buf, "__strong=");
> - } else {
> - DefineBuiltinMacro(Buf,
> "__weak=__attribute__((objc_gc(weak)))");
> - DefineBuiltinMacro(Buf,
> "__strong=__attribute__((objc_gc(strong)))");
> + if (PP.getLangOptions().getGCMode() != LangOptions::NonGC)
> DefineBuiltinMacro(Buf, "__OBJC_GC__=1");
> - }
> -
> +
> if (PP.getLangOptions().NeXTRuntime)
> DefineBuiltinMacro(Buf, "__NEXT_RUNTIME__=1");
> }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list