aboutsummaryrefslogtreecommitdiff
path: root/lib/Basic/Targets.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-07 04:48:21 +0000
committerChris Lattner <sabre@nondot.org>2009-04-07 04:48:21 +0000
commit3a5cbd37c91d29bbd169ae869b234ed1fc954cb6 (patch)
tree35110c516197bd2ca1a88d9e823e7148ed7fd5d6 /lib/Basic/Targets.cpp
parent90658ec72542df44eb462c69056184d2946bdbce (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68494 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/Targets.cpp')
-rw-r--r--lib/Basic/Targets.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 40bc31381d..5fa2967e59 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -138,11 +138,21 @@ static bool getDarwinNumber(const char *Triple, unsigned &Maj, unsigned &Min) {
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.
@@ -375,7 +385,7 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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.