[cfe-commits] r148945 - in /cfe/trunk: include/clang/Driver/ToolChain.h lib/Driver/HostInfo.cpp lib/Driver/ToolChain.cpp lib/Driver/ToolChains.cpp lib/Driver/ToolChains.h lib/Driver/WindowsToolChain.cpp

Chandler Carruth chandlerc at gmail.com
Wed Jan 25 01:12:06 PST 2012


Author: chandlerc
Date: Wed Jan 25 03:12:06 2012
New Revision: 148945

URL: http://llvm.org/viewvc/llvm-project?rev=148945&view=rev
Log:
Switch the ToolChain types to all store a Driver reference rather than
a HostInfo reference. Nothing about the HostInfo was used by any
toolchain except digging out the driver from it. This just makes that
a lot more direct. The change was accomplished entirely mechanically.
It's one step closer to removing the shim full of buggy copy/paste code
that is HostInfo.

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

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=148945&r1=148944&r2=148945&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Wed Jan 25 03:12:06 2012
@@ -23,7 +23,6 @@
   class Compilation;
   class DerivedArgList;
   class Driver;
-  class HostInfo;
   class InputArgList;
   class JobAction;
   class ObjCRuntime;
@@ -45,7 +44,7 @@
   };
 
 private:
-  const HostInfo &Host;
+  const Driver &D;
   const llvm::Triple Triple;
 
   /// The list of toolchain specific path prefixes to search for
@@ -57,7 +56,7 @@
   path_list ProgramPaths;
 
 protected:
-  ToolChain(const HostInfo &Host, const llvm::Triple &_Triple);
+  ToolChain(const Driver &D, const llvm::Triple &T);
 
   /// \name Utilities for implementing subclasses.
   ///@{

Modified: cfe/trunk/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=148945&r1=148944&r2=148945&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Wed Jan 25 03:12:06 2012
@@ -109,9 +109,9 @@
     // If we recognized the arch, match it to the toolchains we support.
     if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64 ||
         Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb) {
-      TC = new toolchains::DarwinClang(*this, TCTriple);
+      TC = new toolchains::DarwinClang(getDriver(), TCTriple);
     } else
-      TC = new toolchains::Darwin_Generic_GCC(*this, TCTriple);
+      TC = new toolchains::Darwin_Generic_GCC(getDriver(), TCTriple);
   }
 
   return TC;
@@ -138,7 +138,7 @@
                                         const char *ArchName) const {
   llvm::Triple TCTriple(getTriple());
 //  TCTriple.setArchName(ArchName);
-  return new toolchains::TCEToolChain(*this, TCTriple);
+  return new toolchains::TCEToolChain(getDriver(), TCTriple);
 }
 
 
@@ -192,7 +192,7 @@
     llvm::Triple TCTriple(getTriple());
     TCTriple.setArchName(ArchName);
 
-    TC = new toolchains::Generic_GCC(*this, TCTriple);
+    TC = new toolchains::Generic_GCC(getDriver(), TCTriple);
   }
 
   return TC;
@@ -233,7 +233,7 @@
     llvm::Triple TCTriple(getTriple());
     TCTriple.setArchName(ArchName);
 
-    TC = new toolchains::OpenBSD(*this, TCTriple);
+    TC = new toolchains::OpenBSD(getDriver(), TCTriple);
   }
 
   return TC;
@@ -272,7 +272,7 @@
     llvm::Triple TCTriple(getTriple());
     TCTriple.setArchName(getArchName());
 
-    TC = new toolchains::AuroraUX(*this, TCTriple);
+    TC = new toolchains::AuroraUX(getDriver(), TCTriple);
   }
 
   return TC;
@@ -325,7 +325,7 @@
     llvm::Triple TCTriple(getTriple());
     TCTriple.setArchName(ArchName);
 
-    TC = new toolchains::FreeBSD(*this, TCTriple);
+    TC = new toolchains::FreeBSD(getDriver(), TCTriple);
   }
 
   return TC;
@@ -384,7 +384,7 @@
       return TC;
   }
 
-  TC = new toolchains::NetBSD(*this, TargetTriple, getTriple());
+  TC = new toolchains::NetBSD(getDriver(), TargetTriple, getTriple());
 
   return TC;
 }
@@ -425,7 +425,7 @@
     llvm::Triple TCTriple(getTriple());
     TCTriple.setArchName(ArchName);
 
-    TC = new toolchains::Minix(*this, TCTriple);
+    TC = new toolchains::Minix(getDriver(), TCTriple);
   }
 
   return TC;
@@ -464,7 +464,7 @@
     llvm::Triple TCTriple(getTriple());
     TCTriple.setArchName(getArchName());
 
-    TC = new toolchains::DragonFly(*this, TCTriple);
+    TC = new toolchains::DragonFly(getDriver(), TCTriple);
   }
 
   return TC;
@@ -517,14 +517,14 @@
 
   if (!TC && !Arch.compare ("hexagon")) {
     llvm::Triple TCTriple (getTriple());
-    TC = new toolchains::Hexagon_TC (*this, TCTriple);
+    TC = new toolchains::Hexagon_TC (getDriver(), TCTriple);
   }
 
   if (!TC) {
     llvm::Triple TCTriple(getTriple());
     TCTriple.setArchName(ArchName);
 
-    TC = new toolchains::Linux(*this, TCTriple);
+    TC = new toolchains::Linux(getDriver(), TCTriple);
   }
 
   return TC;
@@ -580,7 +580,7 @@
     llvm::Triple TCTriple(getTriple());
     TCTriple.setArchName(ArchName);
 
-    TC = new toolchains::Windows(*this, TCTriple);
+    TC = new toolchains::Windows(getDriver(), TCTriple);
   }
 
   return TC;

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=148945&r1=148944&r2=148945&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Wed Jan 25 03:12:06 2012
@@ -14,31 +14,30 @@
 #include "clang/Driver/ArgList.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/HostInfo.h"
 #include "clang/Driver/ObjCRuntime.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Support/ErrorHandling.h"
 using namespace clang::driver;
 using namespace clang;
 
-ToolChain::ToolChain(const HostInfo &H, const llvm::Triple &T)
-  : Host(H), Triple(T) {
+ToolChain::ToolChain(const Driver &D, const llvm::Triple &T)
+  : D(D), Triple(T) {
 }
 
 ToolChain::~ToolChain() {
 }
 
 const Driver &ToolChain::getDriver() const {
- return Host.getDriver();
+ return D;
 }
 
 std::string ToolChain::GetFilePath(const char *Name) const {
-  return Host.getDriver().GetFilePath(Name, *this);
+  return D.GetFilePath(Name, *this);
 
 }
 
 std::string ToolChain::GetProgramPath(const char *Name, bool WantFile) const {
-  return Host.getDriver().GetProgramPath(Name, *this, WantFile);
+  return D.GetProgramPath(Name, *this, WantFile);
 }
 
 types::ID ToolChain::LookupTypeForExtension(const char *Ext) const {

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=148945&r1=148944&r2=148945&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Jan 25 03:12:06 2012
@@ -18,7 +18,6 @@
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
-#include "clang/Driver/HostInfo.h"
 #include "clang/Driver/ObjCRuntime.h"
 #include "clang/Driver/OptTable.h"
 #include "clang/Driver/Option.h"
@@ -46,8 +45,8 @@
 
 /// Darwin - Darwin tool chain for i386 and x86_64.
 
-Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple)
-  : ToolChain(Host, Triple), TargetInitialized(false),
+Darwin::Darwin(const Driver &D, const llvm::Triple& Triple)
+  : ToolChain(D, Triple), TargetInitialized(false),
     ARCRuntimeForSimulator(ARCSimulator_None),
     LibCXXForSimulator(LibCXXSimulator_None)
 {
@@ -251,8 +250,8 @@
 }
 
 
-DarwinClang::DarwinClang(const HostInfo &Host, const llvm::Triple& Triple)
-  : Darwin(Host, Triple)
+DarwinClang::DarwinClang(const Driver &D, const llvm::Triple& Triple)
+  : Darwin(D, Triple)
 {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
@@ -1391,8 +1390,8 @@
   }
 }
 
-Generic_GCC::Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple)
-  : ToolChain(Host, Triple), GCCInstallation(getDriver(), Triple) {
+Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple& Triple)
+  : ToolChain(D, Triple), GCCInstallation(getDriver(), Triple) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
     getProgramPaths().push_back(getDriver().Dir);
@@ -1462,8 +1461,8 @@
 }
 /// Hexagon Toolchain
 
-Hexagon_TC::Hexagon_TC(const HostInfo &Host, const llvm::Triple& Triple)
-  : ToolChain(Host, Triple) {
+Hexagon_TC::Hexagon_TC(const Driver &D, const llvm::Triple& Triple)
+  : ToolChain(D, Triple) {
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir.c_str())
     getProgramPaths().push_back(getDriver().Dir);
@@ -1532,8 +1531,8 @@
 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
 /// Currently does not support anything else but compilation.
 
-TCEToolChain::TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple)
-  : ToolChain(Host, Triple) {
+TCEToolChain::TCEToolChain(const Driver &D, const llvm::Triple& Triple)
+  : ToolChain(D, Triple) {
   // Path mangling to find libexec
   std::string Path(getDriver().Dir);
 
@@ -1585,8 +1584,8 @@
 
 /// OpenBSD - OpenBSD tool chain which can call as(1) and ld(1) directly.
 
-OpenBSD::OpenBSD(const HostInfo &Host, const llvm::Triple& Triple)
-  : Generic_ELF(Host, Triple) {
+OpenBSD::OpenBSD(const Driver &D, const llvm::Triple& Triple)
+  : Generic_ELF(D, Triple) {
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
 }
@@ -1629,8 +1628,8 @@
 
 /// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly.
 
-FreeBSD::FreeBSD(const HostInfo &Host, const llvm::Triple& Triple)
-  : Generic_ELF(Host, Triple) {
+FreeBSD::FreeBSD(const Driver &D, const llvm::Triple& Triple)
+  : Generic_ELF(D, Triple) {
 
   // When targeting 32-bit platforms, look for libraries in '/usr/lib32' first;
   // for 64-bit hosts that's where they will live. We fall back to '/usr/lib'
@@ -1675,9 +1674,9 @@
 
 /// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly.
 
-NetBSD::NetBSD(const HostInfo &Host, const llvm::Triple& Triple,
+NetBSD::NetBSD(const Driver &D, const llvm::Triple& Triple,
                const llvm::Triple& ToolTriple)
-  : Generic_ELF(Host, Triple), ToolTriple(ToolTriple) {
+  : Generic_ELF(D, Triple), ToolTriple(ToolTriple) {
 
   // Determine if we are compiling 32-bit code on an x86_64 platform.
   bool Lib32 = false;
@@ -1727,8 +1726,8 @@
 
 /// Minix - Minix tool chain which can call as(1) and ld(1) directly.
 
-Minix::Minix(const HostInfo &Host, const llvm::Triple& Triple)
-  : Generic_ELF(Host, Triple) {
+Minix::Minix(const Driver &D, const llvm::Triple& Triple)
+  : Generic_ELF(D, Triple) {
   getFilePaths().push_back(getDriver().Dir + "/../lib");
   getFilePaths().push_back("/usr/lib");
 }
@@ -1758,8 +1757,8 @@
 
 /// AuroraUX - AuroraUX tool chain which can call as(1) and ld(1) directly.
 
-AuroraUX::AuroraUX(const HostInfo &Host, const llvm::Triple& Triple)
-  : Generic_GCC(Host, Triple) {
+AuroraUX::AuroraUX(const Driver &D, const llvm::Triple& Triple)
+  : Generic_GCC(D, Triple) {
 
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
@@ -1970,8 +1969,8 @@
   }
 }
 
-Linux::Linux(const HostInfo &Host, const llvm::Triple &Triple)
-  : Generic_ELF(Host, Triple) {
+Linux::Linux(const Driver &D, const llvm::Triple &Triple)
+  : Generic_ELF(D, Triple) {
   llvm::Triple::ArchType Arch = Triple.getArch();
   const std::string &SysRoot = getDriver().SysRoot;
 
@@ -2279,8 +2278,8 @@
 
 /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly.
 
-DragonFly::DragonFly(const HostInfo &Host, const llvm::Triple& Triple)
-  : Generic_ELF(Host, Triple) {
+DragonFly::DragonFly(const Driver &D, const llvm::Triple& Triple)
+  : Generic_ELF(D, Triple) {
 
   // Path mangling to find libexec
   getProgramPaths().push_back(getDriver().getInstalledDir());

Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=148945&r1=148944&r2=148945&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Wed Jan 25 03:12:06 2012
@@ -119,7 +119,7 @@
   mutable llvm::DenseMap<unsigned, Tool*> Tools;
 
 public:
-  Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple);
+  Generic_GCC(const Driver &D, const llvm::Triple& Triple);
   ~Generic_GCC();
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -150,7 +150,7 @@
   mutable llvm::DenseMap<unsigned, Tool*> Tools;
 
 public:
-  Hexagon_TC(const HostInfo &Host, const llvm::Triple& Triple);
+  Hexagon_TC(const Driver &D, const llvm::Triple& Triple);
   ~Hexagon_TC();
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -212,7 +212,7 @@
   void AddDeploymentTarget(DerivedArgList &Args) const;
 
 public:
-  Darwin(const HostInfo &Host, const llvm::Triple& Triple);
+  Darwin(const Driver &D, const llvm::Triple& Triple);
   ~Darwin();
 
   std::string ComputeEffectiveClangTriple(const ArgList &Args,
@@ -395,7 +395,7 @@
   void AddGCCLibexecPath(unsigned darwinVersion);
 
 public:
-  DarwinClang(const HostInfo &Host, const llvm::Triple& Triple);
+  DarwinClang(const Driver &D, const llvm::Triple& Triple);
 
   /// @name Darwin ToolChain Implementation
   /// {
@@ -422,8 +422,8 @@
 /// Darwin_Generic_GCC - Generic Darwin tool chain using gcc.
 class LLVM_LIBRARY_VISIBILITY Darwin_Generic_GCC : public Generic_GCC {
 public:
-  Darwin_Generic_GCC(const HostInfo &Host, const llvm::Triple& Triple)
-    : Generic_GCC(Host, Triple) {}
+  Darwin_Generic_GCC(const Driver &D, const llvm::Triple& Triple)
+    : Generic_GCC(D, Triple) {}
 
   std::string ComputeEffectiveClangTriple(const ArgList &Args,
                                           types::ID InputType) const;
@@ -434,8 +434,8 @@
 class LLVM_LIBRARY_VISIBILITY Generic_ELF : public Generic_GCC {
   virtual void anchor();
 public:
-  Generic_ELF(const HostInfo &Host, const llvm::Triple& Triple)
-    : Generic_GCC(Host, Triple) {}
+  Generic_ELF(const Driver &D, const llvm::Triple& Triple)
+    : Generic_GCC(D, Triple) {}
 
   virtual bool IsIntegratedAssemblerDefault() const {
     // Default integrated assembler to on for x86.
@@ -446,7 +446,7 @@
 
 class LLVM_LIBRARY_VISIBILITY AuroraUX : public Generic_GCC {
 public:
-  AuroraUX(const HostInfo &Host, const llvm::Triple& Triple);
+  AuroraUX(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -454,7 +454,7 @@
 
 class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
 public:
-  OpenBSD(const HostInfo &Host, const llvm::Triple& Triple);
+  OpenBSD(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -462,7 +462,7 @@
 
 class LLVM_LIBRARY_VISIBILITY FreeBSD : public Generic_ELF {
 public:
-  FreeBSD(const HostInfo &Host, const llvm::Triple& Triple);
+  FreeBSD(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -472,7 +472,7 @@
   const llvm::Triple ToolTriple;
 
 public:
-  NetBSD(const HostInfo &Host, const llvm::Triple& Triple,
+  NetBSD(const Driver &D, const llvm::Triple& Triple,
          const llvm::Triple& ToolTriple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -481,7 +481,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Minix : public Generic_ELF {
 public:
-  Minix(const HostInfo &Host, const llvm::Triple& Triple);
+  Minix(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -489,7 +489,7 @@
 
 class LLVM_LIBRARY_VISIBILITY DragonFly : public Generic_ELF {
 public:
-  DragonFly(const HostInfo &Host, const llvm::Triple& Triple);
+  DragonFly(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;
@@ -497,7 +497,7 @@
 
 class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
 public:
-  Linux(const HostInfo &Host, const llvm::Triple& Triple);
+  Linux(const Driver &D, const llvm::Triple& Triple);
 
   virtual bool HasNativeLLVMSupport() const;
 
@@ -523,7 +523,7 @@
 /// all subcommands. See http://tce.cs.tut.fi for our peculiar target.
 class LLVM_LIBRARY_VISIBILITY TCEToolChain : public ToolChain {
 public:
-  TCEToolChain(const HostInfo &Host, const llvm::Triple& Triple);
+  TCEToolChain(const Driver &D, const llvm::Triple& Triple);
   ~TCEToolChain();
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
@@ -542,7 +542,7 @@
   mutable llvm::DenseMap<unsigned, Tool*> Tools;
 
 public:
-  Windows(const HostInfo &Host, const llvm::Triple& Triple);
+  Windows(const Driver &D, const llvm::Triple& Triple);
 
   virtual Tool &SelectTool(const Compilation &C, const JobAction &JA,
                            const ActionList &Inputs) const;

Modified: cfe/trunk/lib/Driver/WindowsToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/WindowsToolChain.cpp?rev=148945&r1=148944&r2=148945&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/WindowsToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/WindowsToolChain.cpp Wed Jan 25 03:12:06 2012
@@ -17,7 +17,6 @@
 #include "clang/Driver/ArgList.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
-#include "clang/Driver/HostInfo.h"
 #include "clang/Driver/Options.h"
 #include "clang/Basic/Version.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -36,8 +35,8 @@
 using namespace clang::driver::toolchains;
 using namespace clang;
 
-Windows::Windows(const HostInfo &Host, const llvm::Triple& Triple)
-  : ToolChain(Host, Triple) {
+Windows::Windows(const Driver &D, const llvm::Triple& Triple)
+  : ToolChain(D, Triple) {
 }
 
 Tool &Windows::SelectTool(const Compilation &C, const JobAction &JA,





More information about the cfe-commits mailing list