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;
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,
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) {
}
if (const BindArchAction *BAA = dyn_cast<BindArchAction>(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;
}
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)
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
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)
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.");
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() {
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.");
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() {
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.");
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() {
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 &&
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() {
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.");
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() {
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.");