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
diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp
index a636e2d..949bbe7 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() {
+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;
+ }
+}
+
+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 {