summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-04-19 21:40:34 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-04-19 21:40:34 +0000
commitecf1356057de02d8ce1911fb78fd17d968b47f38 (patch)
tree61870abeb7bbf791b630a67f1754f50be8e4f323 /clang/lib
parent3c5199042a1206d11eb062c142c13aedd96c108e (diff)
downloadbcm5719-llvm-ecf1356057de02d8ce1911fb78fd17d968b47f38.tar.gz
bcm5719-llvm-ecf1356057de02d8ce1911fb78fd17d968b47f38.zip
Basic/Darwin: Add support for new -osx and -ios style triples (not yet used).
llvm-svn: 129820
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/Targets.cpp50
1 files changed, 33 insertions, 17 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index aa32cbd28f3..5d363a49f45 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -101,18 +101,44 @@ static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
if (Opts.POSIXThreads)
Builder.defineMacro("_REENTRANT");
- // Get the OS version number from the triple.
+ // Get the platform type and version number from the triple.
unsigned Maj, Min, Rev;
// If no version was given, default to to 10.4.0, for simplifying tests.
- if (Triple.getOSName() == "darwin") {
+ if (Triple.getOSName() == "darwin" || Triple.getOSName() == "osx") {
+ PlatformName = "macosx";
Min = Rev = 0;
Maj = 8;
- } else
- Triple.getDarwinNumber(Maj, Min, Rev);
+ } else {
+ // Otherwise, honor all three triple forms ("-darwinNNN[-iphoneos]",
+ // "-osxNNN", and "-iosNNN").
+
+ if (Triple.getOS() == llvm::Triple::Darwin) {
+ // For historical reasons that make little sense, the version passed here
+ // is the "darwin" version, which drops the 10 and offsets by 4.
+ Triple.getOSVersion(Maj, Min, Rev);
+
+ if (Triple.getEnvironmentName() == "iphoneos") {
+ PlatformName = "ios";
+ } else {
+ assert(Rev == 0 && "invalid triple, unexpected micro version!");
+ PlatformName = "macosx";
+ Rev = Min;
+ Min = Maj - 4;
+ Maj = 10;
+ }
+ } else if (Triple.getOS() == llvm::Triple::OSX) {
+ Triple.getOSVersion(Maj, Min, Rev);
+ PlatformName = "macosx";
+ } else {
+ assert(Triple.getOS() == llvm::Triple::IOS && "unexpected triple!");
+ Triple.getOSVersion(Maj, Min, Rev);
+ PlatformName = "ios";
+ }
+ }
// Set the appropriate OS version define.
- if (Triple.getEnvironmentName() == "iphoneos") {
+ if (PlatformName == "ios") {
assert(Maj < 10 && Min < 99 && Rev < 99 && "Invalid version!");
char Str[6];
Str[0] = '0' + Maj;
@@ -122,16 +148,7 @@ static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
Str[4] = '0' + (Rev % 10);
Str[5] = '\0';
Builder.defineMacro("__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__", Str);
-
- PlatformName = "ios";
- PlatformMinVersion = VersionTuple(Maj, Min, Rev);
} else {
- // For historical reasons that make little sense, the version passed here is
- // the "darwin" version, which drops the 10 and offsets by 4.
- Rev = Min;
- Min = Maj - 4;
- Maj = 10;
-
assert(Triple.getEnvironmentName().empty() && "Invalid environment!");
assert(Maj < 99 && Min < 10 && Rev < 10 && "Invalid version!");
char Str[5];
@@ -141,10 +158,9 @@ static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
Str[3] = '0' + Rev;
Str[4] = '\0';
Builder.defineMacro("__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__", Str);
-
- PlatformName = "macosx";
- PlatformMinVersion = VersionTuple(Maj, Min, Rev);
}
+
+ PlatformMinVersion = VersionTuple(Maj, Min, Rev);
}
namespace {
OpenPOWER on IntegriCloud