blob: d7b4bc705305ad9ea19e812d7f2de81f200cb75b [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";
Ted Kremenek30660a82012-03-06 20:06:33 +000030 case MigrateJobClass: return "migrator";
Daniel Dunbar20933352009-03-13 17:52:07 +000031 case CompileJobClass: return "compiler";
32 case AssembleJobClass: return "assembler";
33 case LinkJobClass: return "linker";
Daniel Dunbar85da0072009-03-13 12:17:08 +000034 case LipoJobClass: return "lipo";
Daniel Dunbar6e0f2542010-06-04 18:28:36 +000035 case DsymutilJobClass: return "dsymutil";
Eric Christopherf8571862011-08-23 17:56:55 +000036 case VerifyJobClass: return "verify";
Daniel Dunbar85da0072009-03-13 12:17:08 +000037 }
Mike Stump1eb44332009-09-09 15:08:12 +000038
David Blaikieb219cfc2011-09-23 05:06:16 +000039 llvm_unreachable("invalid class");
Daniel Dunbar85da0072009-03-13 12:17:08 +000040}
Daniel Dunbarf40ed172009-03-13 23:08:03 +000041
David Blaikie99ba9e32011-12-20 02:48:34 +000042void InputAction::anchor() {}
43
Mike Stump1eb44332009-09-09 15:08:12 +000044InputAction::InputAction(const Arg &_Input, types::ID _Type)
Daniel Dunbarf40ed172009-03-13 23:08:03 +000045 : Action(InputClass, _Type), Input(_Input) {
46}
47
David Blaikie99ba9e32011-12-20 02:48:34 +000048void BindArchAction::anchor() {}
49
Mike Stump1eb44332009-09-09 15:08:12 +000050BindArchAction::BindArchAction(Action *Input, const char *_ArchName)
Daniel Dunbarf40ed172009-03-13 23:08:03 +000051 : Action(BindArchClass, Input, Input->getType()), ArchName(_ArchName) {
52}
53
David Blaikie99ba9e32011-12-20 02:48:34 +000054void JobAction::anchor() {}
55
Daniel Dunbarf40ed172009-03-13 23:08:03 +000056JobAction::JobAction(ActionClass Kind, Action *Input, types::ID Type)
57 : Action(Kind, Input, Type) {
58}
59
Mike Stump1eb44332009-09-09 15:08:12 +000060JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
Daniel Dunbarf40ed172009-03-13 23:08:03 +000061 : Action(Kind, Inputs, Type) {
62}
63
David Blaikie99ba9e32011-12-20 02:48:34 +000064void PreprocessJobAction::anchor() {}
65
Daniel Dunbarf40ed172009-03-13 23:08:03 +000066PreprocessJobAction::PreprocessJobAction(Action *Input, types::ID OutputType)
67 : JobAction(PreprocessJobClass, Input, OutputType) {
68}
69
David Blaikie99ba9e32011-12-20 02:48:34 +000070void PrecompileJobAction::anchor() {}
71
Daniel Dunbarf40ed172009-03-13 23:08:03 +000072PrecompileJobAction::PrecompileJobAction(Action *Input, types::ID OutputType)
73 : JobAction(PrecompileJobClass, Input, OutputType) {
74}
75
David Blaikie99ba9e32011-12-20 02:48:34 +000076void AnalyzeJobAction::anchor() {}
77
Daniel Dunbarf40ed172009-03-13 23:08:03 +000078AnalyzeJobAction::AnalyzeJobAction(Action *Input, types::ID OutputType)
79 : JobAction(AnalyzeJobClass, Input, OutputType) {
80}
81
Ted Kremenek30660a82012-03-06 20:06:33 +000082void MigrateJobAction::anchor() {}
83
84MigrateJobAction::MigrateJobAction(Action *Input, types::ID OutputType)
85 : JobAction(MigrateJobClass, Input, OutputType) {
86}
87
David Blaikie99ba9e32011-12-20 02:48:34 +000088void CompileJobAction::anchor() {}
89
Daniel Dunbarf40ed172009-03-13 23:08:03 +000090CompileJobAction::CompileJobAction(Action *Input, types::ID OutputType)
91 : JobAction(CompileJobClass, Input, OutputType) {
92}
93
David Blaikie99ba9e32011-12-20 02:48:34 +000094void AssembleJobAction::anchor() {}
95
Daniel Dunbarf40ed172009-03-13 23:08:03 +000096AssembleJobAction::AssembleJobAction(Action *Input, types::ID OutputType)
97 : JobAction(AssembleJobClass, Input, OutputType) {
98}
99
David Blaikie99ba9e32011-12-20 02:48:34 +0000100void LinkJobAction::anchor() {}
101
Mike Stump1eb44332009-09-09 15:08:12 +0000102LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
Daniel Dunbarf40ed172009-03-13 23:08:03 +0000103 : JobAction(LinkJobClass, Inputs, Type) {
104}
105
David Blaikie99ba9e32011-12-20 02:48:34 +0000106void LipoJobAction::anchor() {}
107
Mike Stump1eb44332009-09-09 15:08:12 +0000108LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
Daniel Dunbarf40ed172009-03-13 23:08:03 +0000109 : JobAction(LipoJobClass, Inputs, Type) {
110}
Daniel Dunbar6e0f2542010-06-04 18:28:36 +0000111
David Blaikie99ba9e32011-12-20 02:48:34 +0000112void DsymutilJobAction::anchor() {}
113
Daniel Dunbar6e0f2542010-06-04 18:28:36 +0000114DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type)
115 : JobAction(DsymutilJobClass, Inputs, Type) {
116}
Eric Christopherf8571862011-08-23 17:56:55 +0000117
David Blaikie99ba9e32011-12-20 02:48:34 +0000118void VerifyJobAction::anchor() {}
119
Eric Christopherf8571862011-08-23 17:56:55 +0000120VerifyJobAction::VerifyJobAction(ActionList &Inputs, types::ID Type)
121 : JobAction(VerifyJobClass, Inputs, Type) {
122}