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", "");
+ 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.
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
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
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
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
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.
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");
}