blob: 1dcb8d8f6e9520712309e0359002f058f2edf4d2 [file] [log] [blame]
Daniel Dunbar63c4da92009-03-02 19:59:07 +00001//===--- Compilation.cpp - Compilation Task Implementation --------------*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "clang/Driver/Compilation.h"
Daniel Dunbar9d625e12009-03-16 06:42:30 +000011
Daniel Dunbar73f7b8c2009-03-18 02:55:38 +000012#include "clang/Driver/Action.h"
Daniel Dunbar9d625e12009-03-16 06:42:30 +000013#include "clang/Driver/ArgList.h"
14#include "clang/Driver/ToolChain.h"
15
Daniel Dunbard6f0e372009-03-04 20:49:20 +000016using namespace clang::driver;
Daniel Dunbar63c4da92009-03-02 19:59:07 +000017
Daniel Dunbar9d625e12009-03-16 06:42:30 +000018Compilation::Compilation(ToolChain &_DefaultToolChain,
19 ArgList *_Args)
20 : DefaultToolChain(_DefaultToolChain), Args(_Args) {
Daniel Dunbar63c4da92009-03-02 19:59:07 +000021}
22
Daniel Dunbar9d625e12009-03-16 06:42:30 +000023Compilation::~Compilation() {
24 delete Args;
25
26 // Free any derived arg lists.
27 for (llvm::DenseMap<const ToolChain*, ArgList*>::iterator
28 it = TCArgs.begin(), ie = TCArgs.end(); it != ie; ++it) {
29 ArgList *A = it->second;
30 if (A != Args)
31 delete Args;
32 }
Daniel Dunbar73f7b8c2009-03-18 02:55:38 +000033
34 // Free the actions, if built.
35 for (ActionList::iterator it = Actions.begin(), ie = Actions.end();
36 it != ie; ++it)
37 delete *it;
Daniel Dunbar9d625e12009-03-16 06:42:30 +000038}
39
40const ArgList &Compilation::getArgsForToolChain(const ToolChain *TC) {
41 if (!TC)
42 TC = &DefaultToolChain;
43
Daniel Dunbare5640282009-03-18 05:58:45 +000044 ArgList *&Entry = TCArgs[TC];
45 if (!Entry)
46 Entry = TC->TranslateArgs(*Args);
Daniel Dunbar9d625e12009-03-16 06:42:30 +000047
Daniel Dunbare5640282009-03-18 05:58:45 +000048 return *Entry;
Daniel Dunbar63c4da92009-03-02 19:59:07 +000049}
50
51int Compilation::Execute() const {
52 return 0;
53}