blob: 360dbeecabf97d08825fdcd4afbf4d90ad036db7 [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";
Bob Wilson23a55f12014-12-21 07:00:00 +000032 case BackendJobClass: return "backend";
Daniel Dunbar7326ad52009-03-13 17:52:07 +000033 case AssembleJobClass: return "assembler";
34 case LinkJobClass: return "linker";
Daniel Dunbar80665fb2009-03-13 12:17:08 +000035 case LipoJobClass: return "lipo";
Daniel Dunbar88299622010-06-04 18:28:36 +000036 case DsymutilJobClass: return "dsymutil";
Ben Langmuir9b9a8d32014-02-06 18:53:25 +000037 case VerifyDebugInfoJobClass: return "verify-debug-info";
38 case VerifyPCHJobClass: return "verify-pch";
Daniel Dunbar80665fb2009-03-13 12:17:08 +000039 }
Mike Stump11289f42009-09-09 15:08:12 +000040
David Blaikie83d382b2011-09-23 05:06:16 +000041 llvm_unreachable("invalid class");
Daniel Dunbar80665fb2009-03-13 12:17:08 +000042}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000043
David Blaikie68e081d2011-12-20 02:48:34 +000044void InputAction::anchor() {}
45
Mike Stump11289f42009-09-09 15:08:12 +000046InputAction::InputAction(const Arg &_Input, types::ID _Type)
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000047 : Action(InputClass, _Type), Input(_Input) {
48}
49
David Blaikie68e081d2011-12-20 02:48:34 +000050void BindArchAction::anchor() {}
51
David Blaikie486f4402014-08-29 07:25:23 +000052BindArchAction::BindArchAction(std::unique_ptr<Action> Input,
53 const char *_ArchName)
54 : Action(BindArchClass, std::move(Input)), ArchName(_ArchName) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000055
David Blaikie68e081d2011-12-20 02:48:34 +000056void JobAction::anchor() {}
57
David Blaikie486f4402014-08-29 07:25:23 +000058JobAction::JobAction(ActionClass Kind, std::unique_ptr<Action> Input,
59 types::ID Type)
60 : Action(Kind, std::move(Input), Type) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000061
Mike Stump11289f42009-09-09 15:08:12 +000062JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000063 : Action(Kind, Inputs, Type) {
64}
65
David Blaikie68e081d2011-12-20 02:48:34 +000066void PreprocessJobAction::anchor() {}
67
David Blaikie486f4402014-08-29 07:25:23 +000068PreprocessJobAction::PreprocessJobAction(std::unique_ptr<Action> Input,
69 types::ID OutputType)
70 : JobAction(PreprocessJobClass, std::move(Input), OutputType) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000071
David Blaikie68e081d2011-12-20 02:48:34 +000072void PrecompileJobAction::anchor() {}
73
David Blaikie486f4402014-08-29 07:25:23 +000074PrecompileJobAction::PrecompileJobAction(std::unique_ptr<Action> Input,
75 types::ID OutputType)
76 : JobAction(PrecompileJobClass, std::move(Input), OutputType) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000077
David Blaikie68e081d2011-12-20 02:48:34 +000078void AnalyzeJobAction::anchor() {}
79
David Blaikie486f4402014-08-29 07:25:23 +000080AnalyzeJobAction::AnalyzeJobAction(std::unique_ptr<Action> Input,
81 types::ID OutputType)
82 : JobAction(AnalyzeJobClass, std::move(Input), OutputType) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000083
Ted Kremenekf7639e12012-03-06 20:06:33 +000084void MigrateJobAction::anchor() {}
85
David Blaikie486f4402014-08-29 07:25:23 +000086MigrateJobAction::MigrateJobAction(std::unique_ptr<Action> Input,
87 types::ID OutputType)
88 : JobAction(MigrateJobClass, std::move(Input), OutputType) {}
Ted Kremenekf7639e12012-03-06 20:06:33 +000089
David Blaikie68e081d2011-12-20 02:48:34 +000090void CompileJobAction::anchor() {}
91
David Blaikie486f4402014-08-29 07:25:23 +000092CompileJobAction::CompileJobAction(std::unique_ptr<Action> Input,
93 types::ID OutputType)
94 : JobAction(CompileJobClass, std::move(Input), OutputType) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +000095
Bob Wilson23a55f12014-12-21 07:00:00 +000096void BackendJobAction::anchor() {}
97
98BackendJobAction::BackendJobAction(std::unique_ptr<Action> Input,
99 types::ID OutputType)
100 : JobAction(BackendJobClass, std::move(Input), OutputType) {}
101
David Blaikie68e081d2011-12-20 02:48:34 +0000102void AssembleJobAction::anchor() {}
103
David Blaikie486f4402014-08-29 07:25:23 +0000104AssembleJobAction::AssembleJobAction(std::unique_ptr<Action> Input,
105 types::ID OutputType)
106 : JobAction(AssembleJobClass, std::move(Input), OutputType) {}
Daniel Dunbar3f261ff2009-03-13 23:08:03 +0000107
David Blaikie68e081d2011-12-20 02:48:34 +0000108void LinkJobAction::anchor() {}
109
Mike Stump11289f42009-09-09 15:08:12 +0000110LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
Daniel Dunbar3f261ff2009-03-13 23:08:03 +0000111 : JobAction(LinkJobClass, Inputs, Type) {
112}
113
David Blaikie68e081d2011-12-20 02:48:34 +0000114void LipoJobAction::anchor() {}
115
Mike Stump11289f42009-09-09 15:08:12 +0000116LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
Daniel Dunbar3f261ff2009-03-13 23:08:03 +0000117 : JobAction(LipoJobClass, Inputs, Type) {
118}
Daniel Dunbar88299622010-06-04 18:28:36 +0000119
David Blaikie68e081d2011-12-20 02:48:34 +0000120void DsymutilJobAction::anchor() {}
121
Daniel Dunbar88299622010-06-04 18:28:36 +0000122DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type)
123 : JobAction(DsymutilJobClass, Inputs, Type) {
124}
Eric Christopher551ef452011-08-23 17:56:55 +0000125
David Blaikie68e081d2011-12-20 02:48:34 +0000126void VerifyJobAction::anchor() {}
127
David Blaikie486f4402014-08-29 07:25:23 +0000128VerifyJobAction::VerifyJobAction(ActionClass Kind,
129 std::unique_ptr<Action> Input, types::ID Type)
130 : JobAction(Kind, std::move(Input), Type) {
Ben Langmuir9b9a8d32014-02-06 18:53:25 +0000131 assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
132 "ActionClass is not a valid VerifyJobAction");
133}
134
135VerifyJobAction::VerifyJobAction(ActionClass Kind, ActionList &Inputs,
136 types::ID Type)
137 : JobAction(Kind, Inputs, Type) {
138 assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
139 "ActionClass is not a valid VerifyJobAction");
140}
141
142void VerifyDebugInfoJobAction::anchor() {}
143
David Blaikie486f4402014-08-29 07:25:23 +0000144VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(
145 std::unique_ptr<Action> Input, types::ID Type)
146 : VerifyJobAction(VerifyDebugInfoJobClass, std::move(Input), Type) {}
Ben Langmuir9b9a8d32014-02-06 18:53:25 +0000147
148void VerifyPCHJobAction::anchor() {}
149
David Blaikie486f4402014-08-29 07:25:23 +0000150VerifyPCHJobAction::VerifyPCHJobAction(std::unique_ptr<Action> Input,
151 types::ID Type)
152 : VerifyJobAction(VerifyPCHJobClass, std::move(Input), Type) {}