diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-16 06:42:30 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-16 06:42:30 +0000 |
commit | 586dc233bb88f2920c9f3638f69cef0ccd55dced (patch) | |
tree | 2a856f9e457d0e44a817f67e964ddcf4854b6d95 /lib/Driver | |
parent | 2ba38ba9a18b8ec88e2509fad622eeec01562769 (diff) |
Driver: Migrate some data into the Compilation; after pipelining
access to most data should go through the current Compilation, not the
Driver (which shouldn't be specialized on variables for a single
compilation).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67037 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver')
-rw-r--r-- | lib/Driver/Compilation.cpp | 30 | ||||
-rw-r--r-- | lib/Driver/Driver.cpp | 34 |
2 files changed, 46 insertions, 18 deletions
diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index a636e2dbac..949bbe7d6b 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -8,12 +8,38 @@ //===----------------------------------------------------------------------===// #include "clang/Driver/Compilation.h" + +#include "clang/Driver/ArgList.h" +#include "clang/Driver/ToolChain.h" + using namespace clang::driver; -Compilation::Compilation() { +Compilation::Compilation(ToolChain &_DefaultToolChain, + ArgList *_Args) + : DefaultToolChain(_DefaultToolChain), Args(_Args) { +} + +Compilation::~Compilation() { + delete Args; + + // Free any derived arg lists. + for (llvm::DenseMap<const ToolChain*, ArgList*>::iterator + it = TCArgs.begin(), ie = TCArgs.end(); it != ie; ++it) { + ArgList *A = it->second; + if (A != Args) + delete Args; + } } -Compilation::~Compilation() { +const ArgList &Compilation::getArgsForToolChain(const ToolChain *TC) { + if (!TC) + TC = &DefaultToolChain; + + ArgList *&Args = TCArgs[TC]; + if (!Args) + Args = TC->TranslateArgs(*Args); + + return *Args; } int Compilation::Execute() const { diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 60dd45cd53..cba2c9f7c6 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -171,19 +171,9 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) { return 0; } - Compilation *C = BuildJobs(*Args, Actions); - - // If there were no errors, warn about any unused arguments. - for (ArgList::iterator it = Args->begin(), ie = Args->end(); it != ie; ++it) { - Arg *A = *it; - - // FIXME: It would be nice to be able to send the argument to the - // Diagnostic, so that extra values, position, and so on could be - // printed. - if (!A->isClaimed()) - Diag(clang::diag::warn_drv_unused_argument) - << A->getOption().getName(); - } + // The compilation takes ownership of Args. + Compilation *C = new Compilation(*DefaultToolChain, Args); + BuildJobs(*C, Actions); return C; } @@ -577,9 +567,21 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase, return 0; } -Compilation *Driver::BuildJobs(const ArgList &Args, - const ActionList &Actions) const { - return 0; +void Driver::BuildJobs(Compilation &C, + const ActionList &Actions) const { + + // If there were no errors, warn about any unused arguments. + for (ArgList::const_iterator it = C.getArgs().begin(), ie = C.getArgs().end(); + it != ie; ++it) { + Arg *A = *it; + + // FIXME: It would be nice to be able to send the argument to the + // Diagnostic, so that extra values, position, and so on could be + // printed. + if (!A->isClaimed()) + Diag(clang::diag::warn_drv_unused_argument) + << A->getOption().getName(); + } } llvm::sys::Path Driver::GetFilePath(const char *Name, |