From 510d8a8dd8d19436fa9d4126a5e7f4f2ef0ded98 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 18 Sep 2009 08:14:46 +0000 Subject: [PATCH] Lift getMacosxVersionMin out into Darwin ToolChain. llvm-svn: 82210 --- clang/lib/Driver/ToolChains.cpp | 15 +++++++++++++++ clang/lib/Driver/ToolChains.h | 4 ++++ clang/lib/Driver/Tools.cpp | 14 +------------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp index deb06720f497..ce4fc1eea3d9 100644 --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/lib/Driver/ToolChains.cpp @@ -154,6 +154,21 @@ void Darwin::AddLinkSearchPathArgs(const ArgList &Args, "/../../..")); } +void Darwin::getMacosxVersionMin(const ArgList &Args, + unsigned (&Res)[3]) const { + if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ)) { + bool HadExtra; + if (!Driver::GetReleaseVersion(A->getValue(Args), Res[0], Res[1], Res[2], + HadExtra) || + HadExtra) { + const Driver &D = getHost().getDriver(); + D.Diag(clang::diag::err_drv_invalid_version_number) + << A->getAsString(Args); + } + } else + return getMacosxVersion(Res); +} + DerivedArgList *Darwin::TranslateArgs(InputArgList &Args, const char *BoundArch) const { DerivedArgList *DAL = new DerivedArgList(Args, false); diff --git a/clang/lib/Driver/ToolChains.h b/clang/lib/Driver/ToolChains.h index fc3201980396..aebc8fae4e78 100644 --- a/clang/lib/Driver/ToolChains.h +++ b/clang/lib/Driver/ToolChains.h @@ -91,6 +91,10 @@ public: Res[2] = DarwinVersion[1]; } + /// getMacosxVersionMin - Get the effective -mmacosx-version-min, which is + /// either the -mmacosx-version-min, or the current version if unspecified. + void getMacosxVersionMin(const ArgList &Args, unsigned (&Res)[3]) const; + const char *getMacosxVersionStr() const { return MacosxVersionMin.c_str(); } diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 104d3a3567d7..ca7baef76d13 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1929,19 +1929,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(Output.getFilename()); unsigned MacosxVersionMin[3]; - if (Arg *A = Args.getLastArg(options::OPT_mmacosx_version_min_EQ)) { - bool HadExtra; - if (!Driver::GetReleaseVersion(A->getValue(Args), MacosxVersionMin[0], - MacosxVersionMin[1], MacosxVersionMin[2], - HadExtra) || - HadExtra) { - const Driver &D = getToolChain().getHost().getDriver(); - D.Diag(clang::diag::err_drv_invalid_version_number) - << A->getAsString(Args); - } - } else { - getDarwinToolChain().getMacosxVersion(MacosxVersionMin); - } + getDarwinToolChain().getMacosxVersionMin(Args, MacosxVersionMin); if (!Args.hasArg(options::OPT_A) && !Args.hasArg(options::OPT_nostdlib) &&