blob: d4f339d376ddec549a85606e48eb15588ae444dd [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
David Blaikie486f4402014-08-29 07:25:23 +000051BindArchAction::BindArchAction(std::unique_ptr<Action> Input,
52 const char *_ArchName)
53 : Action(BindArchClass, std::move(Input)), ArchName(_ArchName) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000054
David Blaikie68e081d2011-12-20 02:48:34 +000055void JobAction::anchor() {}
56
David Blaikie486f4402014-08-29 07:25:23 +000057JobAction::JobAction(ActionClass Kind, std::unique_ptr<Action> Input,
58 types::ID Type)
59 : Action(Kind, std::move(Input), Type) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000060
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
David Blaikie486f4402014-08-29 07:25:23 +000067PreprocessJobAction::PreprocessJobAction(std::unique_ptr<Action> Input,
68 types::ID OutputType)
69 : JobAction(PreprocessJobClass, std::move(Input), OutputType) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000070
David Blaikie68e081d2011-12-20 02:48:34 +000071void PrecompileJobAction::anchor() {}
72
David Blaikie486f4402014-08-29 07:25:23 +000073PrecompileJobAction::PrecompileJobAction(std::unique_ptr<Action> Input,
74 types::ID OutputType)
75 : JobAction(PrecompileJobClass, std::move(Input), OutputType) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000076
David Blaikie68e081d2011-12-20 02:48:34 +000077void AnalyzeJobAction::anchor() {}
78
David Blaikie486f4402014-08-29 07:25:23 +000079AnalyzeJobAction::AnalyzeJobAction(std::unique_ptr<Action> Input,
80 types::ID OutputType)
81 : JobAction(AnalyzeJobClass, std::move(Input), OutputType) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000082
Ted Kremenekf7639e12012-03-06 20:06:33 +000083void MigrateJobAction::anchor() {}
84
David Blaikie486f4402014-08-29 07:25:23 +000085MigrateJobAction::MigrateJobAction(std::unique_ptr<Action> Input,
86 types::ID OutputType)
87 : JobAction(MigrateJobClass, std::move(Input), OutputType) {}
Ted Kremenekf7639e12012-03-06 20:06:33 +000088
David Blaikie68e081d2011-12-20 02:48:34 +000089void CompileJobAction::anchor() {}
90
David Blaikie486f4402014-08-29 07:25:23 +000091CompileJobAction::CompileJobAction(std::unique_ptr<Action> Input,
92 types::ID OutputType)
93 : JobAction(CompileJobClass, std::move(Input), OutputType) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000094
David Blaikie68e081d2011-12-20 02:48:34 +000095void AssembleJobAction::anchor() {}
96
David Blaikie486f4402014-08-29 07:25:23 +000097AssembleJobAction::AssembleJobAction(std::unique_ptr<Action> Input,
98 types::ID OutputType)
99 : JobAction(AssembleJobClass, std::move(Input), OutputType) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +0000100
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
David Blaikie486f4402014-08-29 07:25:23 +0000121VerifyJobAction::VerifyJobAction(ActionClass Kind,
122 std::unique_ptr<Action> Input, types::ID Type)
123 : JobAction(Kind, std::move(Input), Type) {
Ben Langmuir9b9a8d32014-02-06 18:53:25 +0000124 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
David Blaikie486f4402014-08-29 07:25:23 +0000137VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(
138 std::unique_ptr<Action> Input, types::ID Type)
139 : VerifyJobAction(VerifyDebugInfoJobClass, std::move(Input), Type) {}
Ben Langmuir9b9a8d32014-02-06 18:53:25 +0000140
141void VerifyPCHJobAction::anchor() {}
142
David Blaikie486f4402014-08-29 07:25:23 +0000143VerifyPCHJobAction::VerifyPCHJobAction(std::unique_ptr<Action> Input,
144 types::ID Type)
145 : VerifyJobAction(VerifyPCHJobClass, std::move(Input), Type) {}