From d7502d0a662b5c299125aba04245aefce67cbc22 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 8 Sep 2009 23:37:19 +0000 Subject: [PATCH] Rename HostInfo::getToolChain to HostInfo::CreateToolChain, and don't recreate the default tool chain when binding the default architecture. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81279 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/HostInfo.h | 37 +++++++++++----------- lib/Driver/Driver.cpp | 21 +++++-------- lib/Driver/HostInfo.cpp | 56 ++++++++++++++++----------------- 3 files changed, 55 insertions(+), 59 deletions(-) diff --git a/include/clang/Driver/HostInfo.h b/include/clang/Driver/HostInfo.h index 581ea433b8..fc1c1ca044 100644 --- a/include/clang/Driver/HostInfo.h +++ b/include/clang/Driver/HostInfo.h @@ -20,13 +20,13 @@ namespace driver { class Driver; class ToolChain; -/// HostInfo - Config information about a particular host which may -/// interact with driver behavior. +/// HostInfo - Config information about a particular host which may interact +/// with driver behavior. /// -/// The host information is used for controlling the parts of the -/// driver which interact with the platform the driver is ostensibly -/// being run from. For testing purposes, the HostInfo used by the -/// driver may differ from the actual host. +/// The host information is used for controlling the parts of the driver which +/// interact with the platform the driver is ostensibly being run from. For +/// testing purposes, the HostInfo used by the driver may differ from the actual +/// host. class HostInfo { protected: const Driver &TheDriver; @@ -44,27 +44,28 @@ public: std::string getPlatformName() const { return Triple.getVendorName(); } std::string getOSName() const { return Triple.getOSName(); } - /// useDriverDriver - Whether the driver should act as a driver - /// driver for this host and support -arch, -Xarch, etc. + /// useDriverDriver - Whether the driver should act as a driver driver for + /// this host and support -arch, -Xarch, etc. virtual bool useDriverDriver() const = 0; - /// lookupTypeForExtension - Return the default language type to use - /// for the given extension. + /// lookupTypeForExtension - Return the default language type to use for the + /// given extension. virtual types::ID lookupTypeForExtension(const char *Ext) const = 0; - /// getToolChain - Construct the toolchain to use for this host. + /// CreateToolChain - Construct the toolchain to use for this host (which the + /// host retains ownership of). /// - /// \param Args - The argument list, which may be used to alter the - /// default toolchain, for example in the presence of -m32 or -m64. + /// \param Args - The argument list, which may be used to alter the default + /// toolchain, for example in the presence of -m32 or -m64. /// - /// \param ArchName - The architecture to return a toolchain for, or - /// 0 if unspecified. This will only ever be non-zero for hosts - /// which support a driver driver. + /// \param ArchName - The architecture to return a toolchain for, or 0 if + /// unspecified. This will only ever be non-zero for hosts which support a + /// driver driver. // FIXME: Pin down exactly what the HostInfo is allowed to use Args // for here. Currently this is for -m32 / -m64 defaulting. - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName=0) const = 0; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName=0) const = 0; }; const HostInfo *createAuroraUXHostInfo(const Driver &D, diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index c817cde4e9..f58c8829eb 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -207,7 +207,7 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) { Host = GetHostInfo(HostTriple); // The compilation takes ownership of Args. - Compilation *C = new Compilation(*this, *Host->getToolChain(*Args), Args); + Compilation *C = new Compilation(*this, *Host->CreateToolChain(*Args), Args); // FIXME: This behavior shouldn't be here. if (CCCPrintOptions) { @@ -1017,19 +1017,14 @@ void Driver::BuildJobsForAction(Compilation &C, } if (const BindArchAction *BAA = dyn_cast(A)) { - const char *ArchName = BAA->getArchName(); + const ToolChain *TC = &C.getDefaultToolChain(); + std::string Arch; - if (!ArchName) { - Arch = C.getDefaultToolChain().getArchName(); - ArchName = Arch.c_str(); - } - BuildJobsForAction(C, - *BAA->begin(), - Host->getToolChain(C.getArgs(), ArchName), - CanAcceptPipe, - AtTopLevel, - LinkingOutput, - Result); + if (BAA->getArchName()) + TC = Host->CreateToolChain(C.getArgs(), BAA->getArchName()); + + BuildJobsForAction(C, *BAA->begin(), TC, CanAcceptPipe, AtTopLevel, + LinkingOutput, Result); return; } diff --git a/lib/Driver/HostInfo.cpp b/lib/Driver/HostInfo.cpp index a80e08e107..bf663eb2f3 100644 --- a/lib/Driver/HostInfo.cpp +++ b/lib/Driver/HostInfo.cpp @@ -66,8 +66,8 @@ public: return Ty; } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; DarwinHostInfo::DarwinHostInfo(const Driver &D, const llvm::Triple& Triple) @@ -104,8 +104,8 @@ bool DarwinHostInfo::useDriverDriver() const { return true; } -ToolChain *DarwinHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *DarwinHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { std::string Arch; if (!ArchName) { // If we aren't looking for a specific arch, infer the default architecture @@ -192,8 +192,8 @@ public: return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; UnknownHostInfo::UnknownHostInfo(const Driver &D, const llvm::Triple& Triple) @@ -210,8 +210,8 @@ bool UnknownHostInfo::useDriverDriver() const { return false; } -ToolChain *UnknownHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *UnknownHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { assert(!ArchName && "Unexpected arch name on platform without driver driver support."); @@ -259,8 +259,8 @@ public: return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; OpenBSDHostInfo::~OpenBSDHostInfo() { @@ -273,8 +273,8 @@ bool OpenBSDHostInfo::useDriverDriver() const { return false; } -ToolChain *OpenBSDHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *OpenBSDHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { assert(!ArchName && "Unexpected arch name on platform without driver driver support."); @@ -310,8 +310,8 @@ public: return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; AuroraUXHostInfo::~AuroraUXHostInfo() { @@ -324,8 +324,8 @@ bool AuroraUXHostInfo::useDriverDriver() const { return false; } -ToolChain *AuroraUXHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *AuroraUXHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { assert(!ArchName && "Unexpected arch name on platform without driver driver support."); @@ -359,8 +359,8 @@ public: return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; FreeBSDHostInfo::~FreeBSDHostInfo() { @@ -373,8 +373,8 @@ bool FreeBSDHostInfo::useDriverDriver() const { return false; } -ToolChain *FreeBSDHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *FreeBSDHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { bool Lib32 = false; assert(!ArchName && @@ -419,8 +419,8 @@ public: return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; DragonFlyHostInfo::~DragonFlyHostInfo() { @@ -433,8 +433,8 @@ bool DragonFlyHostInfo::useDriverDriver() const { return false; } -ToolChain *DragonFlyHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *DragonFlyHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { assert(!ArchName && "Unexpected arch name on platform without driver driver support."); @@ -468,8 +468,8 @@ public: return types::lookupTypeForExtension(Ext); } - virtual ToolChain *getToolChain(const ArgList &Args, - const char *ArchName) const; + virtual ToolChain *CreateToolChain(const ArgList &Args, + const char *ArchName) const; }; LinuxHostInfo::~LinuxHostInfo() { @@ -482,8 +482,8 @@ bool LinuxHostInfo::useDriverDriver() const { return false; } -ToolChain *LinuxHostInfo::getToolChain(const ArgList &Args, - const char *ArchName) const { +ToolChain *LinuxHostInfo::CreateToolChain(const ArgList &Args, + const char *ArchName) const { assert(!ArchName && "Unexpected arch name on platform without driver driver support."); -- 2.40.0