forked from OSchip/llvm-project
Driver: Pass HostInfo reference into ToolChain.
llvm-svn: 67105
This commit is contained in:
parent
d7e7a51797
commit
7a70c5ddbf
|
@ -17,18 +17,17 @@ namespace clang {
|
||||||
namespace driver {
|
namespace driver {
|
||||||
class ArgList;
|
class ArgList;
|
||||||
class Compilation;
|
class Compilation;
|
||||||
class Driver;
|
class HostInfo;
|
||||||
class JobAction;
|
class JobAction;
|
||||||
class Tool;
|
class Tool;
|
||||||
|
|
||||||
/// ToolChain - Access to tools for a single platform.
|
/// ToolChain - Access to tools for a single platform.
|
||||||
class ToolChain {
|
class ToolChain {
|
||||||
Driver &TheDriver;
|
const HostInfo &Host;
|
||||||
|
|
||||||
std::string Arch, Platform, OS;
|
std::string Arch, Platform, OS;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ToolChain(Driver &D, const char *_Arch, const char *_Platform,
|
ToolChain(const HostInfo &Host, const char *_Arch, const char *_Platform,
|
||||||
const char *_OS);
|
const char *_OS);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -36,6 +35,7 @@ public:
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
|
|
||||||
|
const HostInfo &getHost() const { return Host; }
|
||||||
const std::string &getArchName() const { return Arch; }
|
const std::string &getArchName() const { return Arch; }
|
||||||
const std::string &getPlatform() const { return Platform; }
|
const std::string &getPlatform() const { return Platform; }
|
||||||
const std::string &getOS() const { return OS; }
|
const std::string &getOS() const { return OS; }
|
||||||
|
@ -44,7 +44,10 @@ public:
|
||||||
|
|
||||||
/// TranslateArgs - Create a new derived argument list for any
|
/// TranslateArgs - Create a new derived argument list for any
|
||||||
/// argument translations this ToolChain may wish to perform.
|
/// argument translations this ToolChain may wish to perform.
|
||||||
virtual ArgList *TranslateArgs(const ArgList &Args) const = 0;
|
///
|
||||||
|
/// The client implementation is free to return Args directly if no
|
||||||
|
/// translations need to be performed.
|
||||||
|
virtual ArgList *TranslateArgs(ArgList &Args) const = 0;
|
||||||
|
|
||||||
/// SelectTool - Choose a tool to use to handle the action \arg JA.
|
/// SelectTool - Choose a tool to use to handle the action \arg JA.
|
||||||
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const = 0;
|
virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const = 0;
|
||||||
|
|
|
@ -11,12 +11,13 @@
|
||||||
|
|
||||||
#include "clang/Driver/Action.h"
|
#include "clang/Driver/Action.h"
|
||||||
#include "clang/Driver/Driver.h"
|
#include "clang/Driver/Driver.h"
|
||||||
|
#include "clang/Driver/HostInfo.h"
|
||||||
|
|
||||||
using namespace clang::driver;
|
using namespace clang::driver;
|
||||||
|
|
||||||
ToolChain::ToolChain(Driver &_TheDriver, const char *_Arch,
|
ToolChain::ToolChain(const HostInfo &_Host, const char *_Arch,
|
||||||
const char *_Platform, const char *_OS)
|
const char *_Platform, const char *_OS)
|
||||||
: TheDriver(_TheDriver), Arch(_Arch), Platform(_Platform), OS(_OS) {
|
: Host(_Host), Arch(_Arch), Platform(_Platform), OS(_OS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolChain::~ToolChain() {
|
ToolChain::~ToolChain() {
|
||||||
|
@ -24,38 +25,38 @@ ToolChain::~ToolChain() {
|
||||||
|
|
||||||
llvm::sys::Path ToolChain::GetFilePath(const Compilation &C,
|
llvm::sys::Path ToolChain::GetFilePath(const Compilation &C,
|
||||||
const char *Name) const {
|
const char *Name) const {
|
||||||
return TheDriver.GetFilePath(Name, this);
|
return Host.getDriver().GetFilePath(Name, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C,
|
llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C,
|
||||||
const char *Name) const {
|
const char *Name) const {
|
||||||
return TheDriver.GetProgramPath(Name, this);
|
return Host.getDriver().GetProgramPath(Name, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolChain::ShouldUseClangCompiler(const Compilation &C,
|
bool ToolChain::ShouldUseClangCompiler(const Compilation &C,
|
||||||
const JobAction &JA) const {
|
const JobAction &JA) const {
|
||||||
// Check if user requested no clang, or clang doesn't understand
|
// Check if user requested no clang, or clang doesn't understand
|
||||||
// this type (we only handle single inputs for now).
|
// this type (we only handle single inputs for now).
|
||||||
if (TheDriver.CCCNoClang || JA.size() != 1 ||
|
if (Host.getDriver().CCCNoClang || JA.size() != 1 ||
|
||||||
!types::isAcceptedByClang((*JA.begin())->getType()))
|
!types::isAcceptedByClang((*JA.begin())->getType()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Otherwise make sure this is an action clang undertands.
|
// Otherwise make sure this is an action clang undertands.
|
||||||
if (isa<PreprocessJobAction>(JA)) {
|
if (isa<PreprocessJobAction>(JA)) {
|
||||||
if (TheDriver.CCCNoClangCPP)
|
if (Host.getDriver().CCCNoClangCPP)
|
||||||
return false;
|
return false;
|
||||||
} else if (!isa<PrecompileJobAction>(JA) && !isa<CompileJobAction>(JA))
|
} else if (!isa<PrecompileJobAction>(JA) && !isa<CompileJobAction>(JA))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Avoid CXX if the user requested.
|
// Avoid CXX if the user requested.
|
||||||
if (TheDriver.CCCNoClangCXX && types::isCXX((*JA.begin())->getType()))
|
if (Host.getDriver().CCCNoClangCXX && types::isCXX((*JA.begin())->getType()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Finally, don't use clang if this isn't one of the user specified
|
// Finally, don't use clang if this isn't one of the user specified
|
||||||
// archs to build.
|
// archs to build.
|
||||||
if (!TheDriver.CCCClangArchs.empty() &&
|
if (!Host.getDriver().CCCClangArchs.empty() &&
|
||||||
TheDriver.CCCClangArchs.count(getArchName()))
|
Host.getDriver().CCCClangArchs.count(getArchName()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue