diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Driver/Driver.cpp | 10 | ||||
-rw-r--r-- | lib/Driver/Tool.cpp | 15 | ||||
-rw-r--r-- | lib/Driver/ToolChain.cpp | 62 |
3 files changed, 85 insertions, 2 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index d5b337b707..60dd45cd53 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -582,13 +582,19 @@ Compilation *Driver::BuildJobs(const ArgList &Args, return 0; } -llvm::sys::Path Driver::GetFilePath(const char *Name) const { +llvm::sys::Path Driver::GetFilePath(const char *Name, + const ToolChain *TC) const { // FIXME: Implement. + if (!TC) TC = DefaultToolChain; + return llvm::sys::Path(Name); } -llvm::sys::Path Driver::GetProgramPath(const char *Name) const { +llvm::sys::Path Driver::GetProgramPath(const char *Name, + const ToolChain *TC) const { // FIXME: Implement. + if (!TC) TC = DefaultToolChain; + return llvm::sys::Path(Name); } diff --git a/lib/Driver/Tool.cpp b/lib/Driver/Tool.cpp new file mode 100644 index 0000000000..52c047b8dd --- /dev/null +++ b/lib/Driver/Tool.cpp @@ -0,0 +1,15 @@ +//===--- Tool.cpp - Compilation Tools -----------------------------------*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "clang/Driver/Tool.h" + +using namespace clang::driver; + +Tool::~Tool() { +} diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp new file mode 100644 index 0000000000..ff4e97b1d4 --- /dev/null +++ b/lib/Driver/ToolChain.cpp @@ -0,0 +1,62 @@ +//===--- ToolChain.cpp - Collections of tools for one platform ----------*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "clang/Driver/ToolChain.h" + +#include "clang/Driver/Action.h" +#include "clang/Driver/Driver.h" + +using namespace clang::driver; + +ToolChain::ToolChain(Driver &_TheDriver, const char *_Arch, + const char *_Platform, const char *_OS) + : TheDriver(_TheDriver), Arch(_Arch), Platform(_Platform), OS(_OS) { +} + +ToolChain::~ToolChain() { +} + +llvm::sys::Path ToolChain::GetFilePath(const Compilation &C, + const char *Name) const { + return TheDriver.GetFilePath(Name, this); + +} + +llvm::sys::Path ToolChain::GetProgramPath(const Compilation &C, + const char *Name) const { + return TheDriver.GetProgramPath(Name, this); +} + +bool ToolChain::ShouldUseClangCompiler(const Compilation &C, + const JobAction &JA) const { + // Check if user requested no clang, or clang doesn't understand + // this type (we only handle single inputs for now). + if (TheDriver.CCCNoClang || JA.size() != 1 || + !types::isAcceptedByClang((*JA.begin())->getType())) + return false; + + // Otherwise make sure this is an action clang undertands. + if (isa<PreprocessJobAction>(JA)) { + if (TheDriver.CCCNoClangCPP) + return false; + } else if (!isa<PrecompileJobAction>(JA) && !isa<CompileJobAction>(JA)) + return false; + + // Avoid CXX if the user requested. + if (TheDriver.CCCNoClangCXX && types::isCXX((*JA.begin())->getType())) + return false; + + // Finally, don't use clang if this isn't one of the user specified + // archs to build. + if (!TheDriver.CCCClangArchs.empty() && + TheDriver.CCCClangArchs.count(getArchName())) + return false; + + return true; +} |