[cfe-commits] r91830 - in /cfe/trunk: include/clang/Driver/ToolChain.h lib/Driver/ToolChain.cpp lib/Driver/ToolChains.cpp lib/Driver/Tools.cpp

Daniel Dunbar daniel at zuster.org
Mon Dec 21 10:54:17 PST 2009


Author: ddunbar
Date: Mon Dec 21 12:54:17 2009
New Revision: 91830

URL: http://llvm.org/viewvc/llvm-project?rev=91830&view=rev
Log:
Add ToolChain::getDriver() and use it instead of going through the HostInfo
object.

Modified:
    cfe/trunk/include/clang/Driver/ToolChain.h
    cfe/trunk/lib/Driver/ToolChain.cpp
    cfe/trunk/lib/Driver/ToolChains.cpp
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=91830&r1=91829&r2=91830&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Dec 21 12:54:17 2009
@@ -19,6 +19,7 @@
 namespace driver {
   class Compilation;
   class DerivedArgList;
+  class Driver;
   class HostInfo;
   class InputArgList;
   class JobAction;
@@ -49,6 +50,7 @@
 
   // Accessors
 
+  const Driver &getDriver() const;
   const HostInfo &getHost() const { return Host; }
   const llvm::Triple &getTriple() const { return Triple; }
 

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=91830&r1=91829&r2=91830&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Dec 21 12:54:17 2009
@@ -22,6 +22,10 @@
 ToolChain::~ToolChain() {
 }
 
+const Driver &ToolChain::getDriver() const {
+ return Host.getDriver();
+}
+
 std::string ToolChain::GetFilePath(const Compilation &C,
                                    const char *Name) const {
   return Host.getDriver().GetFilePath(Name, *this);

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=91830&r1=91829&r2=91830&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Dec 21 12:54:17 2009
@@ -88,7 +88,7 @@
 
   std::string Path;
   if (getArchName() == "x86_64") {
-    Path = getHost().getDriver().Dir;
+    Path = getDriver().Dir;
     Path += "/../lib/gcc/";
     Path += ToolChainDir;
     Path += "/x86_64";
@@ -100,7 +100,7 @@
     getFilePaths().push_back(Path);
   }
 
-  Path = getHost().getDriver().Dir;
+  Path = getDriver().Dir;
   Path += "/../lib/gcc/";
   Path += ToolChainDir;
   getFilePaths().push_back(Path);
@@ -109,7 +109,7 @@
   Path += ToolChainDir;
   getFilePaths().push_back(Path);
 
-  Path = getHost().getDriver().Dir;
+  Path = getDriver().Dir;
   Path += "/../libexec/gcc/";
   Path += ToolChainDir;
   getProgramPaths().push_back(Path);
@@ -118,11 +118,11 @@
   Path += ToolChainDir;
   getProgramPaths().push_back(Path);
 
-  Path = getHost().getDriver().Dir;
+  Path = getDriver().Dir;
   Path += "/../libexec";
   getProgramPaths().push_back(Path);
 
-  getProgramPaths().push_back(getHost().getDriver().Dir);
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 Darwin::~Darwin() {
@@ -134,7 +134,7 @@
 
 Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA) const {
   Action::ActionClass Key;
-  if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
+  if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
     Key = Action::AnalyzeJobClass;
   else
     Key = JA.getKind();
@@ -238,12 +238,12 @@
   // Add the relative libexec dir (for clang-cc).
   //
   // FIXME: We should sink clang-cc into libexec/clang/<version>/.
-  std::string Path = getHost().getDriver().Dir;
+  std::string Path = getDriver().Dir;
   Path += "/../libexec";
   getProgramPaths().push_back(Path);
 
   // We expect 'as', 'ld', etc. to be adjacent to our install dir.
-  getProgramPaths().push_back(getHost().getDriver().Dir);
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 void DarwinClang::AddLinkSearchPathArgs(const ArgList &Args,
@@ -264,7 +264,7 @@
   // cares. This is useful in situations where someone wants to statically link
   // something like libstdc++, and needs its runtime support routines.
   if (const Arg *A = Args.getLastArg(options::OPT_static_libgcc)) {
-    getHost().getDriver().Diag(clang::diag::err_drv_unsupported_opt)
+    getDriver().Diag(clang::diag::err_drv_unsupported_opt)
       << A->getAsString(Args);
     return;
   }
@@ -284,7 +284,7 @@
     if (!Driver::GetReleaseVersion(A->getValue(Args), Res[0], Res[1], Res[2],
                                    HadExtra) ||
         HadExtra) {
-      const Driver &D = getHost().getDriver();
+      const Driver &D = getDriver();
       D.Diag(clang::diag::err_drv_invalid_version_number)
         << A->getAsString(Args);
     }
@@ -295,7 +295,7 @@
 DerivedArgList *Darwin::TranslateArgs(InputArgList &Args,
                                       const char *BoundArch) const {
   DerivedArgList *DAL = new DerivedArgList(Args, false);
-  const OptTable &Opts = getHost().getDriver().getOpts();
+  const OptTable &Opts = getDriver().getOpts();
 
   // FIXME: We really want to get out of the tool chain level argument
   // translation business, as it makes the driver functionality much
@@ -309,7 +309,7 @@
   Arg *iPhoneVersion =
     Args.getLastArgNoClaim(options::OPT_miphoneos_version_min_EQ);
   if (OSXVersion && iPhoneVersion) {
-    getHost().getDriver().Diag(clang::diag::err_drv_argument_not_allowed_with)
+    getDriver().Diag(clang::diag::err_drv_argument_not_allowed_with)
           << OSXVersion->getAsString(Args)
           << iPhoneVersion->getAsString(Args);
   } else if (!OSXVersion && !iPhoneVersion) {
@@ -355,7 +355,7 @@
       // like -O4 are going to slip through.
       if (!XarchArg || Index > Prev + 1 ||
           XarchArg->getOption().isDriverOption()) {
-       getHost().getDriver().Diag(clang::diag::err_drv_invalid_Xarch_argument)
+       getDriver().Diag(clang::diag::err_drv_invalid_Xarch_argument)
           << A->getAsString(Args);
         continue;
       }
@@ -548,11 +548,11 @@
 
 Generic_GCC::Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple)
   : ToolChain(Host, Triple) {
-  std::string Path(getHost().getDriver().Dir);
+  std::string Path(getDriver().Dir);
   Path += "/../libexec";
   getProgramPaths().push_back(Path);
 
-  getProgramPaths().push_back(getHost().getDriver().Dir);
+  getProgramPaths().push_back(getDriver().Dir);
 }
 
 Generic_GCC::~Generic_GCC() {
@@ -565,7 +565,7 @@
 Tool &Generic_GCC::SelectTool(const Compilation &C,
                               const JobAction &JA) const {
   Action::ActionClass Key;
-  if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
+  if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
     Key = Action::AnalyzeJobClass;
   else
     Key = JA.getKind();
@@ -626,13 +626,13 @@
 
 OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple)
   : Generic_GCC(Host, Triple) {
-  getFilePaths().push_back(getHost().getDriver().Dir + "/../lib");
+  getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
 }
 
 Tool &OpenBSD::SelectTool(const Compilation &C, const JobAction &JA) const {
   Action::ActionClass Key;
-  if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
+  if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
     Key = Action::AnalyzeJobClass;
   else
     Key = JA.getKind();
@@ -657,17 +657,17 @@
 FreeBSD::FreeBSD(const HostInfo &Host, const llvm::Triple& Triple, bool Lib32)
   : Generic_GCC(Host, Triple) {
   if (Lib32) {
-    getFilePaths().push_back(getHost().getDriver().Dir + "/../lib32");
+    getFilePaths().push_back(getDriver().Dir + "/../lib32");
     getFilePaths().push_back("/usr/lib32");
   } else {
-    getFilePaths().push_back(getHost().getDriver().Dir + "/../lib");
+    getFilePaths().push_back(getDriver().Dir + "/../lib");
     getFilePaths().push_back("/usr/lib");
   }
 }
 
 Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA) const {
   Action::ActionClass Key;
-  if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
+  if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
     Key = Action::AnalyzeJobClass;
   else
     Key = JA.getKind();
@@ -693,13 +693,13 @@
   : Generic_GCC(Host, Triple) {
 
   // Path mangling to find libexec
-  std::string Path(getHost().getDriver().Dir);
+  std::string Path(getDriver().Dir);
 
   Path += "/../libexec";
   getProgramPaths().push_back(Path);
-  getProgramPaths().push_back(getHost().getDriver().Dir);
+  getProgramPaths().push_back(getDriver().Dir);
 
-  getFilePaths().push_back(getHost().getDriver().Dir + "/../lib");
+  getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
   getFilePaths().push_back("/usr/sfw/lib");
   getFilePaths().push_back("/opt/gcc4/lib");
@@ -709,7 +709,7 @@
 
 Tool &AuroraUX::SelectTool(const Compilation &C, const JobAction &JA) const {
   Action::ActionClass Key;
-  if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
+  if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
     Key = Action::AnalyzeJobClass;
   else
     Key = JA.getKind();
@@ -734,7 +734,7 @@
 
 Linux::Linux(const HostInfo &Host, const llvm::Triple& Triple)
   : Generic_GCC(Host, Triple) {
-  getFilePaths().push_back(getHost().getDriver().Dir + "/../lib/clang/1.0/");
+  getFilePaths().push_back(getDriver().Dir + "/../lib/clang/1.0/");
   getFilePaths().push_back("/lib/");
   getFilePaths().push_back("/usr/lib/");
 
@@ -761,20 +761,20 @@
   : Generic_GCC(Host, Triple) {
 
   // Path mangling to find libexec
-  std::string Path(getHost().getDriver().Dir);
+  std::string Path(getDriver().Dir);
 
   Path += "/../libexec";
   getProgramPaths().push_back(Path);
-  getProgramPaths().push_back(getHost().getDriver().Dir);
+  getProgramPaths().push_back(getDriver().Dir);
 
-  getFilePaths().push_back(getHost().getDriver().Dir + "/../lib");
+  getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
   getFilePaths().push_back("/usr/lib/gcc41");
 }
 
 Tool &DragonFly::SelectTool(const Compilation &C, const JobAction &JA) const {
   Action::ActionClass Key;
-  if (getHost().getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
+  if (getDriver().ShouldUseClangCompiler(C, JA, getTriple()))
     Key = Action::AnalyzeJobClass;
   else
     Key = JA.getKind();

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=91830&r1=91829&r2=91830&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Dec 21 12:54:17 2009
@@ -338,7 +338,7 @@
 
 void Clang::AddARMTargetArgs(const ArgList &Args,
                              ArgStringList &CmdArgs) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
 
   // Select the ABI to use.
   //
@@ -607,7 +607,7 @@
                          const InputInfoList &Inputs,
                          const ArgList &Args,
                          const char *LinkingOutput) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
   ArgStringList CmdArgs;
 
   assert(Inputs.size() == 1 && "Unable to handle multiple inputs.");
@@ -1171,7 +1171,7 @@
                                const InputInfoList &Inputs,
                                const ArgList &Args,
                                const char *LinkingOutput) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
   ArgStringList CmdArgs;
 
   for (ArgList::const_iterator
@@ -1259,8 +1259,7 @@
       II.getInputArg().render(Args, CmdArgs);
   }
 
-  const char *GCCName =
-    getToolChain().getHost().getDriver().CCCGenericGCCName.c_str();
+  const char *GCCName = getToolChain().getDriver().CCCGenericGCCName.c_str();
   const char *Exec =
     Args.MakeArgString(getToolChain().GetProgramPath(C, GCCName));
   Dest.addCommand(new Command(JA, *this, Exec, CmdArgs));
@@ -1340,7 +1339,7 @@
 
 void darwin::CC1::AddCC1Args(const ArgList &Args,
                              ArgStringList &CmdArgs) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
 
   CheckCodeGenerationOptions(D, Args);
 
@@ -1369,7 +1368,7 @@
 void darwin::CC1::AddCC1OptionsArgs(const ArgList &Args, ArgStringList &CmdArgs,
                                     const InputInfoList &Inputs,
                                     const ArgStringList &OutputArgs) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
 
   // Derived from cc1_options spec.
   if (Args.hasArg(options::OPT_fast) ||
@@ -1517,7 +1516,7 @@
 void darwin::CC1::AddCPPUniqueOptionsArgs(const ArgList &Args,
                                           ArgStringList &CmdArgs,
                                           const InputInfoList &Inputs) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
 
   CheckPreprocessingOptions(D, Args);
 
@@ -1660,7 +1659,7 @@
                                    const InputInfoList &Inputs,
                                    const ArgList &Args,
                                    const char *LinkingOutput) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
   ArgStringList CmdArgs;
 
   assert(Inputs.size() == 1 && "Unexpected number of inputs!");
@@ -1909,7 +1908,7 @@
 
 void darwin::Link::AddLinkArgs(const ArgList &Args,
                                ArgStringList &CmdArgs) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
 
   // Derived from the "link" spec.
   Args.AddAllArgs(CmdArgs, options::OPT_static);
@@ -2195,7 +2194,7 @@
       !Args.hasArg(options::OPT_nodefaultlibs)) {
     // FIXME: g++ is more complicated here, it tries to put -lstdc++
     // before -lm, for example.
-    if (getToolChain().getHost().getDriver().CCCIsCXX)
+    if (getToolChain().getDriver().CCCIsCXX)
       CmdArgs.push_back("-lstdc++");
 
     // link_ssp spec is empty.
@@ -2309,7 +2308,7 @@
                                   const InputInfoList &Inputs,
                                   const ArgList &Args,
                                   const char *LinkingOutput) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
   ArgStringList CmdArgs;
 
   if ((!Args.hasArg(options::OPT_nostdlib)) &&
@@ -2440,7 +2439,7 @@
                                  const InputInfoList &Inputs,
                                  const ArgList &Args,
                                  const char *LinkingOutput) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
   ArgStringList CmdArgs;
 
   if ((!Args.hasArg(options::OPT_nostdlib)) &&
@@ -2575,7 +2574,7 @@
                                  const InputInfoList &Inputs,
                                  const ArgList &Args,
                                  const char *LinkingOutput) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
   ArgStringList CmdArgs;
 
   if (Args.hasArg(options::OPT_static)) {
@@ -2727,7 +2726,7 @@
                                  const InputInfoList &Inputs,
                                  const ArgList &Args,
                                  const char *LinkingOutput) const {
-  const Driver &D = getToolChain().getHost().getDriver();
+  const Driver &D = getToolChain().getDriver();
   ArgStringList CmdArgs;
 
   if (Args.hasArg(options::OPT_static)) {





More information about the cfe-commits mailing list