diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-01-27 00:56:49 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-01-27 00:56:49 +0000 |
commit | 408fceda7a518ac25975fb6299c856bfaa753939 (patch) | |
tree | d2f2feb70b22e900b25555c51da8810ebd744db5 /lib/Driver/Tools.cpp | |
parent | cc8e1894109b7c02258b7f4be5624d3d8d1523ce (diff) |
Driver/Darwin: Switch clang -triple synthesis to use computed target information.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94639 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Tools.cpp')
-rw-r--r-- | lib/Driver/Tools.cpp | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 89d6fe60f6..f6e88e2264 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -586,50 +586,36 @@ static std::string getEffectiveClangTriple(const Driver &D, const ArgList &Args) { llvm::Triple Triple(getLLVMTriple(TC, Args)); - // Honor -mmacosx-version-min and -miphoneos-version-min. - Arg *VersionArg = Args.getLastArg(options::OPT_mmacosx_version_min_EQ, - options::OPT_miphoneos_version_min_EQ); + // Handle -mmacosx-version-min and -miphoneos-version-min. if (Triple.getOS() != llvm::Triple::Darwin) { // Diagnose use of -mmacosx-version-min and -miphoneos-version-min on // non-Darwin. - if (VersionArg) - D.Diag(clang::diag::err_drv_clang_unsupported) - << VersionArg->getAsString(Args); + if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ, + options::OPT_miphoneos_version_min_EQ)) + D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args); } else { - bool isIPhoneTarget = - VersionArg->getOption().matches(options::OPT_miphoneos_version_min_EQ); - assert(VersionArg && "Missing version argument (lost in translation)?"); - - // Validate the version number. - unsigned Major, Minor, Micro; - bool HadExtra; - if (!Driver::GetReleaseVersion(VersionArg->getValue(Args), Major, Minor, - Micro, HadExtra) || HadExtra) - D.Diag(clang::diag::err_drv_invalid_version_number) - << VersionArg->getAsString(Args); + const toolchains::Darwin &DarwinTC( + reinterpret_cast<const toolchains::Darwin&>(TC)); + unsigned Version[3]; + DarwinTC.getTargetVersion(Version); // Mangle the target version into the OS triple component. For historical // reasons that make little sense, the version passed here is the "darwin" // version, which drops the 10 and offsets by 4. See inverse code when // setting the OS version preprocessor define. - if (!isIPhoneTarget) { - if (Major != 10 || Minor >= 10 || Micro >= 10) - D.Diag(clang::diag::err_drv_invalid_version_number) - << VersionArg->getAsString(Args); - - Major = Minor + 4; - Minor = Micro; - Micro = 0; + if (!DarwinTC.isTargetIPhoneOS()) { + Version[0] = Version[1] + 4; + Version[1] = Version[2]; + Version[2] = 0; + } else { + // Use the environment to communicate that we are targetting iPhoneOS. + Triple.setEnvironmentName("iphoneos"); } llvm::SmallString<16> Str; - llvm::raw_svector_ostream(Str) << "darwin" << Major << "." << Minor - << "." << Micro; + llvm::raw_svector_ostream(Str) << "darwin" << Version[0] + << "." << Version[1] << "." << Version[2]; Triple.setOSName(Str.str()); - - // Use the environment to communicate OS we are targetting. - if (isIPhoneTarget) - Triple.setEnvironmentName("iphoneos"); } return Triple.getTriple(); |