1 //===--- Action.cpp - Abstract compilation steps --------------------------===//
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/Action.h"
11 #include "llvm/Support/ErrorHandling.h"
12 #include <cassert>
13 using namespace clang::driver;
14 using namespace llvm::opt;
15
~Action()16 Action::~Action() {
17 if (OwnsInputs) {
18 for (iterator it = begin(), ie = end(); it != ie; ++it)
19 delete *it;
20 }
21 }
22
getClassName(ActionClass AC)23 const char *Action::getClassName(ActionClass AC) {
24 switch (AC) {
25 case InputClass: return "input";
26 case BindArchClass: return "bind-arch";
27 case PreprocessJobClass: return "preprocessor";
28 case PrecompileJobClass: return "precompiler";
29 case AnalyzeJobClass: return "analyzer";
30 case MigrateJobClass: return "migrator";
31 case CompileJobClass: return "compiler";
32 case AssembleJobClass: return "assembler";
33 case LinkJobClass: return "linker";
34 case LipoJobClass: return "lipo";
35 case DsymutilJobClass: return "dsymutil";
36 case VerifyDebugInfoJobClass: return "verify-debug-info";
37 case VerifyPCHJobClass: return "verify-pch";
38 }
39
40 llvm_unreachable("invalid class");
41 }
42
anchor()43 void InputAction::anchor() {}
44
InputAction(const Arg & _Input,types::ID _Type)45 InputAction::InputAction(const Arg &_Input, types::ID _Type)
46 : Action(InputClass, _Type), Input(_Input) {
47 }
48
anchor()49 void BindArchAction::anchor() {}
50
BindArchAction(Action * Input,const char * _ArchName)51 BindArchAction::BindArchAction(Action *Input, const char *_ArchName)
52 : Action(BindArchClass, Input, Input->getType()), ArchName(_ArchName) {
53 }
54
anchor()55 void JobAction::anchor() {}
56
JobAction(ActionClass Kind,Action * Input,types::ID Type)57 JobAction::JobAction(ActionClass Kind, Action *Input, types::ID Type)
58 : Action(Kind, Input, Type) {
59 }
60
JobAction(ActionClass Kind,const ActionList & Inputs,types::ID Type)61 JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
62 : Action(Kind, Inputs, Type) {
63 }
64
anchor()65 void PreprocessJobAction::anchor() {}
66
PreprocessJobAction(Action * Input,types::ID OutputType)67 PreprocessJobAction::PreprocessJobAction(Action *Input, types::ID OutputType)
68 : JobAction(PreprocessJobClass, Input, OutputType) {
69 }
70
anchor()71 void PrecompileJobAction::anchor() {}
72
PrecompileJobAction(Action * Input,types::ID OutputType)73 PrecompileJobAction::PrecompileJobAction(Action *Input, types::ID OutputType)
74 : JobAction(PrecompileJobClass, Input, OutputType) {
75 }
76
anchor()77 void AnalyzeJobAction::anchor() {}
78
AnalyzeJobAction(Action * Input,types::ID OutputType)79 AnalyzeJobAction::AnalyzeJobAction(Action *Input, types::ID OutputType)
80 : JobAction(AnalyzeJobClass, Input, OutputType) {
81 }
82
anchor()83 void MigrateJobAction::anchor() {}
84
MigrateJobAction(Action * Input,types::ID OutputType)85 MigrateJobAction::MigrateJobAction(Action *Input, types::ID OutputType)
86 : JobAction(MigrateJobClass, Input, OutputType) {
87 }
88
anchor()89 void CompileJobAction::anchor() {}
90
CompileJobAction(Action * Input,types::ID OutputType)91 CompileJobAction::CompileJobAction(Action *Input, types::ID OutputType)
92 : JobAction(CompileJobClass, Input, OutputType) {
93 }
94
anchor()95 void AssembleJobAction::anchor() {}
96
AssembleJobAction(Action * Input,types::ID OutputType)97 AssembleJobAction::AssembleJobAction(Action *Input, types::ID OutputType)
98 : JobAction(AssembleJobClass, Input, OutputType) {
99 }
100
anchor()101 void LinkJobAction::anchor() {}
102
LinkJobAction(ActionList & Inputs,types::ID Type)103 LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
104 : JobAction(LinkJobClass, Inputs, Type) {
105 }
106
anchor()107 void LipoJobAction::anchor() {}
108
LipoJobAction(ActionList & Inputs,types::ID Type)109 LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
110 : JobAction(LipoJobClass, Inputs, Type) {
111 }
112
anchor()113 void DsymutilJobAction::anchor() {}
114
DsymutilJobAction(ActionList & Inputs,types::ID Type)115 DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type)
116 : JobAction(DsymutilJobClass, Inputs, Type) {
117 }
118
anchor()119 void VerifyJobAction::anchor() {}
120
VerifyJobAction(ActionClass Kind,Action * Input,types::ID Type)121 VerifyJobAction::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
VerifyJobAction(ActionClass Kind,ActionList & Inputs,types::ID Type)128 VerifyJobAction::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
anchor()135 void VerifyDebugInfoJobAction::anchor() {}
136
VerifyDebugInfoJobAction(Action * Input,types::ID Type)137 VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(Action *Input,
138 types::ID Type)
139 : VerifyJobAction(VerifyDebugInfoJobClass, Input, Type) {
140 }
141
anchor()142 void VerifyPCHJobAction::anchor() {}
143
VerifyPCHJobAction(Action * Input,types::ID Type)144 VerifyPCHJobAction::VerifyPCHJobAction(Action *Input, types::ID Type)
145 : VerifyJobAction(VerifyPCHJobClass, Input, Type) {
146 }
147