blob: 86a48fd8b7f9594426ce87794afd76933e657da5 [file] [log] [blame]
Nick Lewycky6da90772010-12-31 17:31:54 +00001//===--- Action.cpp - Abstract compilation steps --------------------------===//
Daniel Dunbarf479c122009-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 Blaikie79000202011-09-23 05:57:42 +000011#include "llvm/Support/ErrorHandling.h"
Daniel Dunbarf479c122009-03-12 18:40:18 +000012#include <cassert>
13using namespace clang::driver;
Reid Kleckner898229a2013-06-14 17:17:23 +000014using namespace llvm::opt;
Daniel Dunbarf479c122009-03-12 18:40:18 +000015
Daniel Dunbarf0eddb82009-03-18 02:55:38 +000016Action::~Action() {
Daniel Dunbar66187b32010-03-11 18:04:58 +000017 if (OwnsInputs) {
18 for (iterator it = begin(), ie = end(); it != ie; ++it)
19 delete *it;
20 }
Daniel Dunbarf0eddb82009-03-18 02:55:38 +000021}
Daniel Dunbar80665fb2009-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 Dunbar7326ad52009-03-13 17:52:07 +000027 case PreprocessJobClass: return "preprocessor";
28 case PrecompileJobClass: return "precompiler";
29 case AnalyzeJobClass: return "analyzer";
Ted Kremenekf7639e12012-03-06 20:06:33 +000030 case MigrateJobClass: return "migrator";
Daniel Dunbar7326ad52009-03-13 17:52:07 +000031 case CompileJobClass: return "compiler";
32 case AssembleJobClass: return "assembler";
33 case LinkJobClass: return "linker";
Daniel Dunbar80665fb2009-03-13 12:17:08 +000034 case LipoJobClass: return "lipo";
Daniel Dunbar88299622010-06-04 18:28:36 +000035 case DsymutilJobClass: return "dsymutil";
Ben Langmuir9b9a8d32014-02-06 18:53:25 +000036 case VerifyDebugInfoJobClass: return "verify-debug-info";
37 case VerifyPCHJobClass: return "verify-pch";
Daniel Dunbar80665fb2009-03-13 12:17:08 +000038 }
Mike Stump11289f42009-09-09 15:08:12 +000039
David Blaikie83d382b2011-09-23 05:06:16 +000040 llvm_unreachable("invalid class");
Daniel Dunbar80665fb2009-03-13 12:17:08 +000041}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000042
David Blaikie68e081d2011-12-20 02:48:34 +000043void InputAction::anchor() {}
44
Mike Stump11289f42009-09-09 15:08:12 +000045InputAction::InputAction(const Arg &_Input, types::ID _Type)
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000046 : Action(InputClass, _Type), Input(_Input) {
47}
48
David Blaikie68e081d2011-12-20 02:48:34 +000049void BindArchAction::anchor() {}
50
Mike Stump11289f42009-09-09 15:08:12 +000051BindArchAction::BindArchAction(Action *Input, const char *_ArchName)
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000052 : Action(BindArchClass, Input, Input->getType()), ArchName(_ArchName) {
53}
54
David Blaikie68e081d2011-12-20 02:48:34 +000055void JobAction::anchor() {}
56
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000057JobAction::JobAction(ActionClass Kind, Action *Input, types::ID Type)
58 : Action(Kind, Input, Type) {
59}
60
Mike Stump11289f42009-09-09 15:08:12 +000061JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000062 : Action(Kind, Inputs, Type) {
63}
64
David Blaikie68e081d2011-12-20 02:48:34 +000065void PreprocessJobAction::anchor() {}
66
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000067PreprocessJobAction::PreprocessJobAction(Action *Input, types::ID OutputType)
68 : JobAction(PreprocessJobClass, Input, OutputType) {
69}
70
David Blaikie68e081d2011-12-20 02:48:34 +000071void PrecompileJobAction::anchor() {}
72
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000073PrecompileJobAction::PrecompileJobAction(Action *Input, types::ID OutputType)
74 : JobAction(PrecompileJobClass, Input, OutputType) {
75}
76
David Blaikie68e081d2011-12-20 02:48:34 +000077void AnalyzeJobAction::anchor() {}
78
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000079AnalyzeJobAction::AnalyzeJobAction(Action *Input, types::ID OutputType)
80 : JobAction(AnalyzeJobClass, Input, OutputType) {
81}
82
Ted Kremenekf7639e12012-03-06 20:06:33 +000083void MigrateJobAction::anchor() {}
84
85MigrateJobAction::MigrateJobAction(Action *Input, types::ID OutputType)
86 : JobAction(MigrateJobClass, Input, OutputType) {
87}
88
David Blaikie68e081d2011-12-20 02:48:34 +000089void CompileJobAction::anchor() {}
90
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000091CompileJobAction::CompileJobAction(Action *Input, types::ID OutputType)
92 : JobAction(CompileJobClass, Input, OutputType) {
93}
94
David Blaikie68e081d2011-12-20 02:48:34 +000095void AssembleJobAction::anchor() {}
96
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000097AssembleJobAction::AssembleJobAction(Action *Input, types::ID OutputType)
98 : JobAction(AssembleJobClass, Input, OutputType) {
99}
100
David Blaikie68e081d2011-12-20 02:48:34 +0000101void LinkJobAction::anchor() {}
102
Mike Stump11289f42009-09-09 15:08:12 +0000103LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
Daniel Dunbar3f261ff2009-03-13 23:08:03 +0000104 : JobAction(LinkJobClass, Inputs, Type) {
105}
106
David Blaikie68e081d2011-12-20 02:48:34 +0000107void LipoJobAction::anchor() {}
108
Mike Stump11289f42009-09-09 15:08:12 +0000109LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
Daniel Dunbar3f261ff2009-03-13 23:08:03 +0000110 : JobAction(LipoJobClass, Inputs, Type) {
111}
Daniel Dunbar88299622010-06-04 18:28:36 +0000112
David Blaikie68e081d2011-12-20 02:48:34 +0000113void DsymutilJobAction::anchor() {}
114
Daniel Dunbar88299622010-06-04 18:28:36 +0000115DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type)
116 : JobAction(DsymutilJobClass, Inputs, Type) {
117}
Eric Christopher551ef452011-08-23 17:56:55 +0000118
David Blaikie68e081d2011-12-20 02:48:34 +0000119void VerifyJobAction::anchor() {}
120
Ben Langmuir9b9a8d32014-02-06 18:53:25 +0000121VerifyJobAction::VerifyJobAction(ActionClass Kind, Action *Input,
122 types::ID Type)
123 : JobAction(Kind, Input, Type) {
124 assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
125 "ActionClass is not a valid VerifyJobAction");
126}
127
128VerifyJobAction::VerifyJobAction(ActionClass Kind, ActionList &Inputs,
129 types::ID Type)
130 : JobAction(Kind, Inputs, Type) {
131 assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
132 "ActionClass is not a valid VerifyJobAction");
133}
134
135void VerifyDebugInfoJobAction::anchor() {}
136
137VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(Action *Input,
138 types::ID Type)
139 : VerifyJobAction(VerifyDebugInfoJobClass, Input, Type) {
140}
141
142void VerifyPCHJobAction::anchor() {}
143
144VerifyPCHJobAction::VerifyPCHJobAction(Action *Input, types::ID Type)
145 : VerifyJobAction(VerifyPCHJobClass, Input, Type) {
Eric Christopher551ef452011-08-23 17:56:55 +0000146}