blob: a9dc17b320f880095f06a2bc613edc7bafe7e17b [file] [log] [blame]
Nick Lewycky3fdcc6f2010-12-31 17:31:54 +00001//===--- Action.cpp - Abstract compilation steps --------------------------===//
Daniel Dunbar2fe63e62009-03-12 18:40:18 +00002//
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/Action.h"
David Blaikie548f6c82011-09-23 05:57:42 +000011#include "llvm/Support/ErrorHandling.h"
Daniel Dunbar2fe63e62009-03-12 18:40:18 +000012
13#include <cassert>
14using namespace clang::driver;
15
Daniel Dunbar21549232009-03-18 02:55:38 +000016Action::~Action() {
Daniel Dunbar32c1a2a2010-03-11 18:04:58 +000017 if (OwnsInputs) {
18 for (iterator it = begin(), ie = end(); it != ie; ++it)
19 delete *it;
20 }
Daniel Dunbar21549232009-03-18 02:55:38 +000021}
Daniel Dunbar85da0072009-03-13 12:17:08 +000022
23const char *Action::getClassName(ActionClass AC) {
24 switch (AC) {
25 case InputClass: return "input";
26 case BindArchClass: return "bind-arch";
Daniel Dunbar20933352009-03-13 17:52:07 +000027 case PreprocessJobClass: return "preprocessor";
28 case PrecompileJobClass: return "precompiler";
29 case AnalyzeJobClass: return "analyzer";
30 case CompileJobClass: return "compiler";
31 case AssembleJobClass: return "assembler";
32 case LinkJobClass: return "linker";
Daniel Dunbar85da0072009-03-13 12:17:08 +000033 case LipoJobClass: return "lipo";
Daniel Dunbar6e0f2542010-06-04 18:28:36 +000034 case DsymutilJobClass: return "dsymutil";
Eric Christopherf8571862011-08-23 17:56:55 +000035 case VerifyJobClass: return "verify";
Daniel Dunbar85da0072009-03-13 12:17:08 +000036 }
Mike Stump1eb44332009-09-09 15:08:12 +000037
David Blaikieb219cfc2011-09-23 05:06:16 +000038 llvm_unreachable("invalid class");
Daniel Dunbar85da0072009-03-13 12:17:08 +000039}
Daniel Dunbarf40ed172009-03-13 23:08:03 +000040
David Blaikie99ba9e32011-12-20 02:48:34 +000041void InputAction::anchor() {}
42
Mike Stump1eb44332009-09-09 15:08:12 +000043InputAction::InputAction(const Arg &_Input, types::ID _Type)
Daniel Dunbarf40ed172009-03-13 23:08:03 +000044 : Action(InputClass, _Type), Input(_Input) {
45}
46
David Blaikie99ba9e32011-12-20 02:48:34 +000047void BindArchAction::anchor() {}
48
Mike Stump1eb44332009-09-09 15:08:12 +000049BindArchAction::BindArchAction(Action *Input, const char *_ArchName)
Daniel Dunbarf40ed172009-03-13 23:08:03 +000050 : Action(BindArchClass, Input, Input->getType()), ArchName(_ArchName) {
51}
52
David Blaikie99ba9e32011-12-20 02:48:34 +000053void JobAction::anchor() {}
54
Daniel Dunbarf40ed172009-03-13 23:08:03 +000055JobAction::JobAction(ActionClass Kind, Action *Input, types::ID Type)
56 : Action(Kind, Input, Type) {
57}
58
Mike Stump1eb44332009-09-09 15:08:12 +000059JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
Daniel Dunbarf40ed172009-03-13 23:08:03 +000060 : Action(Kind, Inputs, Type) {
61}
62
David Blaikie99ba9e32011-12-20 02:48:34 +000063void PreprocessJobAction::anchor() {}
64
Daniel Dunbarf40ed172009-03-13 23:08:03 +000065PreprocessJobAction::PreprocessJobAction(Action *Input, types::ID OutputType)
66 : JobAction(PreprocessJobClass, Input, OutputType) {
67}
68
David Blaikie99ba9e32011-12-20 02:48:34 +000069void PrecompileJobAction::anchor() {}
70
Daniel Dunbarf40ed172009-03-13 23:08:03 +000071PrecompileJobAction::PrecompileJobAction(Action *Input, types::ID OutputType)
72 : JobAction(PrecompileJobClass, Input, OutputType) {
73}
74
David Blaikie99ba9e32011-12-20 02:48:34 +000075void AnalyzeJobAction::anchor() {}
76
Daniel Dunbarf40ed172009-03-13 23:08:03 +000077AnalyzeJobAction::AnalyzeJobAction(Action *Input, types::ID OutputType)
78 : JobAction(AnalyzeJobClass, Input, OutputType) {
79}
80
David Blaikie99ba9e32011-12-20 02:48:34 +000081void CompileJobAction::anchor() {}
82
Daniel Dunbarf40ed172009-03-13 23:08:03 +000083CompileJobAction::CompileJobAction(Action *Input, types::ID OutputType)
84 : JobAction(CompileJobClass, Input, OutputType) {
85}
86
David Blaikie99ba9e32011-12-20 02:48:34 +000087void AssembleJobAction::anchor() {}
88
Daniel Dunbarf40ed172009-03-13 23:08:03 +000089AssembleJobAction::AssembleJobAction(Action *Input, types::ID OutputType)
90 : JobAction(AssembleJobClass, Input, OutputType) {
91}
92
David Blaikie99ba9e32011-12-20 02:48:34 +000093void LinkJobAction::anchor() {}
94
Mike Stump1eb44332009-09-09 15:08:12 +000095LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
Daniel Dunbarf40ed172009-03-13 23:08:03 +000096 : JobAction(LinkJobClass, Inputs, Type) {
97}
98
David Blaikie99ba9e32011-12-20 02:48:34 +000099void LipoJobAction::anchor() {}
100
Mike Stump1eb44332009-09-09 15:08:12 +0000101LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
Daniel Dunbarf40ed172009-03-13 23:08:03 +0000102 : JobAction(LipoJobClass, Inputs, Type) {
103}
Daniel Dunbar6e0f2542010-06-04 18:28:36 +0000104
David Blaikie99ba9e32011-12-20 02:48:34 +0000105void DsymutilJobAction::anchor() {}
106
Daniel Dunbar6e0f2542010-06-04 18:28:36 +0000107DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type)
108 : JobAction(DsymutilJobClass, Inputs, Type) {
109}
Eric Christopherf8571862011-08-23 17:56:55 +0000110
David Blaikie99ba9e32011-12-20 02:48:34 +0000111void VerifyJobAction::anchor() {}
112
Eric Christopherf8571862011-08-23 17:56:55 +0000113VerifyJobAction::VerifyJobAction(ActionList &Inputs, types::ID Type)
114 : JobAction(VerifyJobClass, Inputs, Type) {
115}