diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-17 22:07:31 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-17 22:07:31 +0000 |
commit | 670b7f4fe6720e91520ec5a993b33c00058ed77a (patch) | |
tree | 5710d895baf1cd6683ab0beb7b47e940f6e9233c /lib/Driver | |
parent | 83b08eb6d2a7f71328db51baa79c654bb9dcc55d (diff) |
Driver: Stub out generic GCC tool selection.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67108 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver')
-rw-r--r-- | lib/Driver/Tool.cpp | 3 | ||||
-rw-r--r-- | lib/Driver/ToolChains.h | 40 |
2 files changed, 40 insertions, 3 deletions
diff --git a/lib/Driver/Tool.cpp b/lib/Driver/Tool.cpp index 52c047b8dd..090418e3be 100644 --- a/lib/Driver/Tool.cpp +++ b/lib/Driver/Tool.cpp @@ -11,5 +11,8 @@ using namespace clang::driver; +Tool::Tool(const ToolChain &TC) : TheToolChain(TC) { +} + Tool::~Tool() { } diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index a8360af359..be476d78ed 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -10,24 +10,58 @@ #ifndef CLANG_LIB_DRIVER_TOOLCHAINS_H_ #define CLANG_LIB_DRIVER_TOOLCHAINS_H_ +#include "clang/Driver/Action.h" #include "clang/Driver/ToolChain.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/Support/Compiler.h" +#include "Tools.h" + namespace clang { namespace driver { namespace toolchains VISIBILITY_HIDDEN { + /// Generic_GCC - A tool chain using the 'gcc' command to perform + /// all subcommands; this relies on gcc translating the majority of + /// command line options. class Generic_GCC : public ToolChain { + mutable llvm::DenseMap<unsigned, Tool*> Tools; + public: Generic_GCC(const HostInfo &Host, const char *Arch, const char *Platform, - const char *OS) : ToolChain(Host, Arch, Platform, OS) { - } + const char *OS) : ToolChain(Host, Arch, Platform, OS) {} virtual ArgList *TranslateArgs(ArgList &Args) const { return &Args; } virtual Tool &SelectTool(const Compilation &C, const JobAction &JA) const { - return *((Tool*) 0); + Action::ActionClass Key; + if (ShouldUseClangCompiler(C, JA)) + Key = Action::AnalyzeJobClass; + else + Key = JA.getKind(); + + Tool *&T = Tools[Key]; + if (!T) { + switch (Key) { + default: + assert(0 && "Invalid tool kind."); + case Action::PreprocessJobClass: + T = new tools::GCC_Preprocess(*this); break; + case Action::PrecompileJobClass: + T = new tools::GCC_Precompile(*this); break; + case Action::AnalyzeJobClass: + T = new tools::Clang(*this); break; + case Action::CompileJobClass: + T = new tools::GCC_Compile(*this); break; + case Action::AssembleJobClass: + T = new tools::GCC_Assemble(*this); break; + case Action::LinkJobClass: + T = new tools::GCC_Assemble(*this); break; + } + } + + return *T; } virtual bool IsMathErrnoDefault() const { return true; } |