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.

llvm-svn: 148945
This commit is contained in:
Chandler Carruth 2012-01-25 09:12:06 +00:00
parent 509b7af017
commit b65b111d24
6 changed files with 63 additions and 67 deletions

View File

@ -23,7 +23,6 @@ namespace driver {
class Compilation;
class DerivedArgList;
class Driver;
class HostInfo;
class InputArgList;
class JobAction;
class ObjCRuntime;
@ -45,7 +44,7 @@ public:
};
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 @@ private:
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.
///@{

View File

@ -109,9 +109,9 @@ ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args,
// 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 @@ ToolChain *TCEHostInfo::CreateToolChain(const ArgList &Args,
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 @@ ToolChain *UnknownHostInfo::CreateToolChain(const ArgList &Args,
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 @@ ToolChain *OpenBSDHostInfo::CreateToolChain(const ArgList &Args,
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 @@ ToolChain *AuroraUXHostInfo::CreateToolChain(const ArgList &Args,
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 @@ ToolChain *FreeBSDHostInfo::CreateToolChain(const ArgList &Args,
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 @@ ToolChain *NetBSDHostInfo::CreateToolChain(const ArgList &Args,
return TC;
}
TC = new toolchains::NetBSD(*this, TargetTriple, getTriple());
TC = new toolchains::NetBSD(getDriver(), TargetTriple, getTriple());
return TC;
}
@ -425,7 +425,7 @@ ToolChain *MinixHostInfo::CreateToolChain(const ArgList &Args,
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 @@ ToolChain *DragonFlyHostInfo::CreateToolChain(const ArgList &Args,
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 @@ ToolChain *LinuxHostInfo::CreateToolChain(const ArgList &Args,
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 @@ ToolChain *WindowsHostInfo::CreateToolChain(const ArgList &Args,
llvm::Triple TCTriple(getTriple());
TCTriple.setArchName(ArchName);
TC = new toolchains::Windows(*this, TCTriple);
TC = new toolchains::Windows(getDriver(), TCTriple);
}
return TC;

View File

@ -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 {

View File

@ -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 @@ using namespace clang;
/// 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 @@ Tool &Darwin::SelectTool(const Compilation &C, const JobAction &JA,
}
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 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple(
}
}
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 @@ const char *Generic_GCC::GetForcedPicModel() const {
}
/// 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 @@ const char *Hexagon_TC::GetForcedPicModel() const {
/// 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 @@ Tool &TCEToolChain::SelectTool(const Compilation &C,
/// 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 @@ static void addPathIfExists(Twine Path, ToolChain::path_list &Paths) {
/// 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 @@ Tool &FreeBSD::SelectTool(const Compilation &C, const JobAction &JA,
/// 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 @@ Tool &NetBSD::SelectTool(const Compilation &C, const JobAction &JA,
/// 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 @@ Tool &Minix::SelectTool(const Compilation &C, const JobAction &JA,
/// 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 @@ static std::string getMultiarchTriple(const llvm::Triple TargetTriple,
}
}
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 @@ void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
/// 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());

View File

@ -119,7 +119,7 @@ protected:
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 @@ protected:
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 @@ private:
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 @@ private:
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 @@ public:
/// 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 @@ public:
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
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 @@ public:
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 @@ public:
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 @@ public:
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 @@ private:
/// 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 @@ class LLVM_LIBRARY_VISIBILITY Windows : public ToolChain {
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;

View File

@ -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;
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,