From 3ce436d229c8662d7536ca559d4b07724550daf2 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 16 Mar 2009 06:42:30 +0000 Subject: 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). llvm-svn: 67037 --- clang/lib/Driver/Compilation.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'clang/lib/Driver/Compilation.cpp') diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp index a636e2dbac3..949bbe7d6b9 100644 --- a/clang/lib/Driver/Compilation.cpp +++ b/clang/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::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 { -- cgit v1.2.3