1f4a2713aSLionel Sambuc //===--- Action.cpp - Abstract compilation steps --------------------------===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc // The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9f4a2713aSLionel Sambuc
10f4a2713aSLionel Sambuc #include "clang/Driver/Action.h"
11f4a2713aSLionel Sambuc #include "llvm/Support/ErrorHandling.h"
12f4a2713aSLionel Sambuc #include <cassert>
13f4a2713aSLionel Sambuc using namespace clang::driver;
14f4a2713aSLionel Sambuc using namespace llvm::opt;
15f4a2713aSLionel Sambuc
~Action()16f4a2713aSLionel Sambuc Action::~Action() {
17f4a2713aSLionel Sambuc if (OwnsInputs) {
18f4a2713aSLionel Sambuc for (iterator it = begin(), ie = end(); it != ie; ++it)
19f4a2713aSLionel Sambuc delete *it;
20f4a2713aSLionel Sambuc }
21f4a2713aSLionel Sambuc }
22f4a2713aSLionel Sambuc
getClassName(ActionClass AC)23f4a2713aSLionel Sambuc const char *Action::getClassName(ActionClass AC) {
24f4a2713aSLionel Sambuc switch (AC) {
25f4a2713aSLionel Sambuc case InputClass: return "input";
26f4a2713aSLionel Sambuc case BindArchClass: return "bind-arch";
27f4a2713aSLionel Sambuc case PreprocessJobClass: return "preprocessor";
28f4a2713aSLionel Sambuc case PrecompileJobClass: return "precompiler";
29f4a2713aSLionel Sambuc case AnalyzeJobClass: return "analyzer";
30f4a2713aSLionel Sambuc case MigrateJobClass: return "migrator";
31f4a2713aSLionel Sambuc case CompileJobClass: return "compiler";
32*0a6a1f1dSLionel Sambuc case BackendJobClass: return "backend";
33f4a2713aSLionel Sambuc case AssembleJobClass: return "assembler";
34f4a2713aSLionel Sambuc case LinkJobClass: return "linker";
35f4a2713aSLionel Sambuc case LipoJobClass: return "lipo";
36f4a2713aSLionel Sambuc case DsymutilJobClass: return "dsymutil";
37*0a6a1f1dSLionel Sambuc case VerifyDebugInfoJobClass: return "verify-debug-info";
38*0a6a1f1dSLionel Sambuc case VerifyPCHJobClass: return "verify-pch";
39f4a2713aSLionel Sambuc }
40f4a2713aSLionel Sambuc
41f4a2713aSLionel Sambuc llvm_unreachable("invalid class");
42f4a2713aSLionel Sambuc }
43f4a2713aSLionel Sambuc
anchor()44f4a2713aSLionel Sambuc void InputAction::anchor() {}
45f4a2713aSLionel Sambuc
InputAction(const Arg & _Input,types::ID _Type)46f4a2713aSLionel Sambuc InputAction::InputAction(const Arg &_Input, types::ID _Type)
47f4a2713aSLionel Sambuc : Action(InputClass, _Type), Input(_Input) {
48f4a2713aSLionel Sambuc }
49f4a2713aSLionel Sambuc
anchor()50f4a2713aSLionel Sambuc void BindArchAction::anchor() {}
51f4a2713aSLionel Sambuc
BindArchAction(std::unique_ptr<Action> Input,const char * _ArchName)52*0a6a1f1dSLionel Sambuc BindArchAction::BindArchAction(std::unique_ptr<Action> Input,
53*0a6a1f1dSLionel Sambuc const char *_ArchName)
54*0a6a1f1dSLionel Sambuc : Action(BindArchClass, std::move(Input)), ArchName(_ArchName) {}
55f4a2713aSLionel Sambuc
anchor()56f4a2713aSLionel Sambuc void JobAction::anchor() {}
57f4a2713aSLionel Sambuc
JobAction(ActionClass Kind,std::unique_ptr<Action> Input,types::ID Type)58*0a6a1f1dSLionel Sambuc JobAction::JobAction(ActionClass Kind, std::unique_ptr<Action> Input,
59*0a6a1f1dSLionel Sambuc types::ID Type)
60*0a6a1f1dSLionel Sambuc : Action(Kind, std::move(Input), Type) {}
61f4a2713aSLionel Sambuc
JobAction(ActionClass Kind,const ActionList & Inputs,types::ID Type)62f4a2713aSLionel Sambuc JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
63f4a2713aSLionel Sambuc : Action(Kind, Inputs, Type) {
64f4a2713aSLionel Sambuc }
65f4a2713aSLionel Sambuc
anchor()66f4a2713aSLionel Sambuc void PreprocessJobAction::anchor() {}
67f4a2713aSLionel Sambuc
PreprocessJobAction(std::unique_ptr<Action> Input,types::ID OutputType)68*0a6a1f1dSLionel Sambuc PreprocessJobAction::PreprocessJobAction(std::unique_ptr<Action> Input,
69*0a6a1f1dSLionel Sambuc types::ID OutputType)
70*0a6a1f1dSLionel Sambuc : JobAction(PreprocessJobClass, std::move(Input), OutputType) {}
71f4a2713aSLionel Sambuc
anchor()72f4a2713aSLionel Sambuc void PrecompileJobAction::anchor() {}
73f4a2713aSLionel Sambuc
PrecompileJobAction(std::unique_ptr<Action> Input,types::ID OutputType)74*0a6a1f1dSLionel Sambuc PrecompileJobAction::PrecompileJobAction(std::unique_ptr<Action> Input,
75*0a6a1f1dSLionel Sambuc types::ID OutputType)
76*0a6a1f1dSLionel Sambuc : JobAction(PrecompileJobClass, std::move(Input), OutputType) {}
77f4a2713aSLionel Sambuc
anchor()78f4a2713aSLionel Sambuc void AnalyzeJobAction::anchor() {}
79f4a2713aSLionel Sambuc
AnalyzeJobAction(std::unique_ptr<Action> Input,types::ID OutputType)80*0a6a1f1dSLionel Sambuc AnalyzeJobAction::AnalyzeJobAction(std::unique_ptr<Action> Input,
81*0a6a1f1dSLionel Sambuc types::ID OutputType)
82*0a6a1f1dSLionel Sambuc : JobAction(AnalyzeJobClass, std::move(Input), OutputType) {}
83f4a2713aSLionel Sambuc
anchor()84f4a2713aSLionel Sambuc void MigrateJobAction::anchor() {}
85f4a2713aSLionel Sambuc
MigrateJobAction(std::unique_ptr<Action> Input,types::ID OutputType)86*0a6a1f1dSLionel Sambuc MigrateJobAction::MigrateJobAction(std::unique_ptr<Action> Input,
87*0a6a1f1dSLionel Sambuc types::ID OutputType)
88*0a6a1f1dSLionel Sambuc : JobAction(MigrateJobClass, std::move(Input), OutputType) {}
89f4a2713aSLionel Sambuc
anchor()90f4a2713aSLionel Sambuc void CompileJobAction::anchor() {}
91f4a2713aSLionel Sambuc
CompileJobAction(std::unique_ptr<Action> Input,types::ID OutputType)92*0a6a1f1dSLionel Sambuc CompileJobAction::CompileJobAction(std::unique_ptr<Action> Input,
93*0a6a1f1dSLionel Sambuc types::ID OutputType)
94*0a6a1f1dSLionel Sambuc : JobAction(CompileJobClass, std::move(Input), OutputType) {}
95*0a6a1f1dSLionel Sambuc
anchor()96*0a6a1f1dSLionel Sambuc void BackendJobAction::anchor() {}
97*0a6a1f1dSLionel Sambuc
BackendJobAction(std::unique_ptr<Action> Input,types::ID OutputType)98*0a6a1f1dSLionel Sambuc BackendJobAction::BackendJobAction(std::unique_ptr<Action> Input,
99*0a6a1f1dSLionel Sambuc types::ID OutputType)
100*0a6a1f1dSLionel Sambuc : JobAction(BackendJobClass, std::move(Input), OutputType) {}
101f4a2713aSLionel Sambuc
anchor()102f4a2713aSLionel Sambuc void AssembleJobAction::anchor() {}
103f4a2713aSLionel Sambuc
AssembleJobAction(std::unique_ptr<Action> Input,types::ID OutputType)104*0a6a1f1dSLionel Sambuc AssembleJobAction::AssembleJobAction(std::unique_ptr<Action> Input,
105*0a6a1f1dSLionel Sambuc types::ID OutputType)
106*0a6a1f1dSLionel Sambuc : JobAction(AssembleJobClass, std::move(Input), OutputType) {}
107f4a2713aSLionel Sambuc
anchor()108f4a2713aSLionel Sambuc void LinkJobAction::anchor() {}
109f4a2713aSLionel Sambuc
LinkJobAction(ActionList & Inputs,types::ID Type)110f4a2713aSLionel Sambuc LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
111f4a2713aSLionel Sambuc : JobAction(LinkJobClass, Inputs, Type) {
112f4a2713aSLionel Sambuc }
113f4a2713aSLionel Sambuc
anchor()114f4a2713aSLionel Sambuc void LipoJobAction::anchor() {}
115f4a2713aSLionel Sambuc
LipoJobAction(ActionList & Inputs,types::ID Type)116f4a2713aSLionel Sambuc LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
117f4a2713aSLionel Sambuc : JobAction(LipoJobClass, Inputs, Type) {
118f4a2713aSLionel Sambuc }
119f4a2713aSLionel Sambuc
anchor()120f4a2713aSLionel Sambuc void DsymutilJobAction::anchor() {}
121f4a2713aSLionel Sambuc
DsymutilJobAction(ActionList & Inputs,types::ID Type)122f4a2713aSLionel Sambuc DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type)
123f4a2713aSLionel Sambuc : JobAction(DsymutilJobClass, Inputs, Type) {
124f4a2713aSLionel Sambuc }
125f4a2713aSLionel Sambuc
anchor()126f4a2713aSLionel Sambuc void VerifyJobAction::anchor() {}
127f4a2713aSLionel Sambuc
VerifyJobAction(ActionClass Kind,std::unique_ptr<Action> Input,types::ID Type)128*0a6a1f1dSLionel Sambuc VerifyJobAction::VerifyJobAction(ActionClass Kind,
129*0a6a1f1dSLionel Sambuc std::unique_ptr<Action> Input, types::ID Type)
130*0a6a1f1dSLionel Sambuc : JobAction(Kind, std::move(Input), Type) {
131*0a6a1f1dSLionel Sambuc assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
132*0a6a1f1dSLionel Sambuc "ActionClass is not a valid VerifyJobAction");
133f4a2713aSLionel Sambuc }
134*0a6a1f1dSLionel Sambuc
VerifyJobAction(ActionClass Kind,ActionList & Inputs,types::ID Type)135*0a6a1f1dSLionel Sambuc VerifyJobAction::VerifyJobAction(ActionClass Kind, ActionList &Inputs,
136*0a6a1f1dSLionel Sambuc types::ID Type)
137*0a6a1f1dSLionel Sambuc : JobAction(Kind, Inputs, Type) {
138*0a6a1f1dSLionel Sambuc assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
139*0a6a1f1dSLionel Sambuc "ActionClass is not a valid VerifyJobAction");
140*0a6a1f1dSLionel Sambuc }
141*0a6a1f1dSLionel Sambuc
anchor()142*0a6a1f1dSLionel Sambuc void VerifyDebugInfoJobAction::anchor() {}
143*0a6a1f1dSLionel Sambuc
VerifyDebugInfoJobAction(std::unique_ptr<Action> Input,types::ID Type)144*0a6a1f1dSLionel Sambuc VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(
145*0a6a1f1dSLionel Sambuc std::unique_ptr<Action> Input, types::ID Type)
146*0a6a1f1dSLionel Sambuc : VerifyJobAction(VerifyDebugInfoJobClass, std::move(Input), Type) {}
147*0a6a1f1dSLionel Sambuc
anchor()148*0a6a1f1dSLionel Sambuc void VerifyPCHJobAction::anchor() {}
149*0a6a1f1dSLionel Sambuc
VerifyPCHJobAction(std::unique_ptr<Action> Input,types::ID Type)150*0a6a1f1dSLionel Sambuc VerifyPCHJobAction::VerifyPCHJobAction(std::unique_ptr<Action> Input,
151*0a6a1f1dSLionel Sambuc types::ID Type)
152*0a6a1f1dSLionel Sambuc : VerifyJobAction(VerifyPCHJobClass, std::move(Input), Type) {}
153