diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-03-18 20:48:54 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-03-18 20:48:54 +0000 |
commit | 5b222059399ec9cccba7a393dc470adfb8a3db0f (patch) | |
tree | 24d77e0536f9541cfbe3e9552da674ba2474ea95 /lib/Driver/ToolChain.cpp | |
parent | 4b94f4daa13118441b4cf53b7e57cae1b48dc427 (diff) |
Centralize the recording of which tools have been constructed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177319 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChain.cpp')
-rw-r--r-- | lib/Driver/ToolChain.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp index 83c16462e2..e5ddfd10d5 100644 --- a/lib/Driver/ToolChain.cpp +++ b/lib/Driver/ToolChain.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "Tools.h" #include "clang/Driver/ToolChain.h" #include "clang/Basic/ObjCRuntime.h" #include "clang/Driver/Action.h" @@ -27,6 +28,10 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, } ToolChain::~ToolChain() { + // Free tool implementations. + for (llvm::DenseMap<unsigned, Tool*>::iterator + it = Tools.begin(), ie = Tools.end(); it != ie; ++it) + delete it->second; } const Driver &ToolChain::getDriver() const { @@ -58,6 +63,25 @@ bool ToolChain::IsUnwindTablesDefault() const { return false; } +Tool &ToolChain::SelectTool(const JobAction &JA) const { + Action::ActionClass Key; + if (getDriver().ShouldUseClangCompiler(JA)) + Key = Action::AnalyzeJobClass; + else + Key = JA.getKind(); + + Tool *&T = Tools[Key]; + if (T) + return *T; + + if (getDriver().ShouldUseClangCompiler(JA)) + T = new tools::Clang(*this); + else + T = constructTool(Key); + + return *T; +} + std::string ToolChain::GetFilePath(const char *Name) const { return D.GetFilePath(Name, *this); |