Nick Lewycky | 6da9077 | 2010-12-31 17:31:54 +0000 | [diff] [blame] | 1 | //===--- Action.cpp - Abstract compilation steps --------------------------===// |
Daniel Dunbar | f479c12 | 2009-03-12 18:40:18 +0000 | [diff] [blame] | 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" |
David Blaikie | 7900020 | 2011-09-23 05:57:42 +0000 | [diff] [blame] | 11 | #include "llvm/Support/ErrorHandling.h" |
Daniel Dunbar | f479c12 | 2009-03-12 18:40:18 +0000 | [diff] [blame] | 12 | #include <cassert> |
| 13 | using namespace clang::driver; |
Reid Kleckner | 898229a | 2013-06-14 17:17:23 +0000 | [diff] [blame] | 14 | using namespace llvm::opt; |
Daniel Dunbar | f479c12 | 2009-03-12 18:40:18 +0000 | [diff] [blame] | 15 | |
Daniel Dunbar | f0eddb8 | 2009-03-18 02:55:38 +0000 | [diff] [blame] | 16 | Action::~Action() { |
Daniel Dunbar | 66187b3 | 2010-03-11 18:04:58 +0000 | [diff] [blame] | 17 | if (OwnsInputs) { |
| 18 | for (iterator it = begin(), ie = end(); it != ie; ++it) |
| 19 | delete *it; |
| 20 | } |
Daniel Dunbar | f0eddb8 | 2009-03-18 02:55:38 +0000 | [diff] [blame] | 21 | } |
Daniel Dunbar | 80665fb | 2009-03-13 12:17:08 +0000 | [diff] [blame] | 22 | |
| 23 | const char *Action::getClassName(ActionClass AC) { |
| 24 | switch (AC) { |
| 25 | case InputClass: return "input"; |
| 26 | case BindArchClass: return "bind-arch"; |
Daniel Dunbar | 7326ad5 | 2009-03-13 17:52:07 +0000 | [diff] [blame] | 27 | case PreprocessJobClass: return "preprocessor"; |
| 28 | case PrecompileJobClass: return "precompiler"; |
| 29 | case AnalyzeJobClass: return "analyzer"; |
Ted Kremenek | f7639e1 | 2012-03-06 20:06:33 +0000 | [diff] [blame] | 30 | case MigrateJobClass: return "migrator"; |
Daniel Dunbar | 7326ad5 | 2009-03-13 17:52:07 +0000 | [diff] [blame] | 31 | case CompileJobClass: return "compiler"; |
Bob Wilson | 23a55f1 | 2014-12-21 07:00:00 +0000 | [diff] [blame] | 32 | case BackendJobClass: return "backend"; |
Daniel Dunbar | 7326ad5 | 2009-03-13 17:52:07 +0000 | [diff] [blame] | 33 | case AssembleJobClass: return "assembler"; |
| 34 | case LinkJobClass: return "linker"; |
Daniel Dunbar | 80665fb | 2009-03-13 12:17:08 +0000 | [diff] [blame] | 35 | case LipoJobClass: return "lipo"; |
Daniel Dunbar | 8829962 | 2010-06-04 18:28:36 +0000 | [diff] [blame] | 36 | case DsymutilJobClass: return "dsymutil"; |
Ben Langmuir | 9b9a8d3 | 2014-02-06 18:53:25 +0000 | [diff] [blame] | 37 | case VerifyDebugInfoJobClass: return "verify-debug-info"; |
| 38 | case VerifyPCHJobClass: return "verify-pch"; |
Daniel Dunbar | 80665fb | 2009-03-13 12:17:08 +0000 | [diff] [blame] | 39 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 40 | |
David Blaikie | 83d382b | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 41 | llvm_unreachable("invalid class"); |
Daniel Dunbar | 80665fb | 2009-03-13 12:17:08 +0000 | [diff] [blame] | 42 | } |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 43 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 44 | void InputAction::anchor() {} |
| 45 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 46 | InputAction::InputAction(const Arg &_Input, types::ID _Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 47 | : Action(InputClass, _Type), Input(_Input) { |
| 48 | } |
| 49 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 50 | void BindArchAction::anchor() {} |
| 51 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 52 | BindArchAction::BindArchAction(std::unique_ptr<Action> Input, |
| 53 | const char *_ArchName) |
| 54 | : Action(BindArchClass, std::move(Input)), ArchName(_ArchName) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 55 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 56 | void JobAction::anchor() {} |
| 57 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 58 | JobAction::JobAction(ActionClass Kind, std::unique_ptr<Action> Input, |
| 59 | types::ID Type) |
| 60 | : Action(Kind, std::move(Input), Type) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 61 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 62 | JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 63 | : Action(Kind, Inputs, Type) { |
| 64 | } |
| 65 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 66 | void PreprocessJobAction::anchor() {} |
| 67 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 68 | PreprocessJobAction::PreprocessJobAction(std::unique_ptr<Action> Input, |
| 69 | types::ID OutputType) |
| 70 | : JobAction(PreprocessJobClass, std::move(Input), OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 71 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 72 | void PrecompileJobAction::anchor() {} |
| 73 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 74 | PrecompileJobAction::PrecompileJobAction(std::unique_ptr<Action> Input, |
| 75 | types::ID OutputType) |
| 76 | : JobAction(PrecompileJobClass, std::move(Input), OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 77 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 78 | void AnalyzeJobAction::anchor() {} |
| 79 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 80 | AnalyzeJobAction::AnalyzeJobAction(std::unique_ptr<Action> Input, |
| 81 | types::ID OutputType) |
| 82 | : JobAction(AnalyzeJobClass, std::move(Input), OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 83 | |
Ted Kremenek | f7639e1 | 2012-03-06 20:06:33 +0000 | [diff] [blame] | 84 | void MigrateJobAction::anchor() {} |
| 85 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 86 | MigrateJobAction::MigrateJobAction(std::unique_ptr<Action> Input, |
| 87 | types::ID OutputType) |
| 88 | : JobAction(MigrateJobClass, std::move(Input), OutputType) {} |
Ted Kremenek | f7639e1 | 2012-03-06 20:06:33 +0000 | [diff] [blame] | 89 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 90 | void CompileJobAction::anchor() {} |
| 91 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 92 | CompileJobAction::CompileJobAction(std::unique_ptr<Action> Input, |
| 93 | types::ID OutputType) |
| 94 | : JobAction(CompileJobClass, std::move(Input), OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 95 | |
Bob Wilson | 23a55f1 | 2014-12-21 07:00:00 +0000 | [diff] [blame] | 96 | void BackendJobAction::anchor() {} |
| 97 | |
| 98 | BackendJobAction::BackendJobAction(std::unique_ptr<Action> Input, |
| 99 | types::ID OutputType) |
| 100 | : JobAction(BackendJobClass, std::move(Input), OutputType) {} |
| 101 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 102 | void AssembleJobAction::anchor() {} |
| 103 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 104 | AssembleJobAction::AssembleJobAction(std::unique_ptr<Action> Input, |
| 105 | types::ID OutputType) |
| 106 | : JobAction(AssembleJobClass, std::move(Input), OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 107 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 108 | void LinkJobAction::anchor() {} |
| 109 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 110 | LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 111 | : JobAction(LinkJobClass, Inputs, Type) { |
| 112 | } |
| 113 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 114 | void LipoJobAction::anchor() {} |
| 115 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 116 | LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 117 | : JobAction(LipoJobClass, Inputs, Type) { |
| 118 | } |
Daniel Dunbar | 8829962 | 2010-06-04 18:28:36 +0000 | [diff] [blame] | 119 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 120 | void DsymutilJobAction::anchor() {} |
| 121 | |
Daniel Dunbar | 8829962 | 2010-06-04 18:28:36 +0000 | [diff] [blame] | 122 | DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type) |
| 123 | : JobAction(DsymutilJobClass, Inputs, Type) { |
| 124 | } |
Eric Christopher | 551ef45 | 2011-08-23 17:56:55 +0000 | [diff] [blame] | 125 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 126 | void VerifyJobAction::anchor() {} |
| 127 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 128 | VerifyJobAction::VerifyJobAction(ActionClass Kind, |
| 129 | std::unique_ptr<Action> Input, types::ID Type) |
| 130 | : JobAction(Kind, std::move(Input), Type) { |
Ben Langmuir | 9b9a8d3 | 2014-02-06 18:53:25 +0000 | [diff] [blame] | 131 | assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) && |
| 132 | "ActionClass is not a valid VerifyJobAction"); |
| 133 | } |
| 134 | |
| 135 | VerifyJobAction::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 | |
| 142 | void VerifyDebugInfoJobAction::anchor() {} |
| 143 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 144 | VerifyDebugInfoJobAction::VerifyDebugInfoJobAction( |
| 145 | std::unique_ptr<Action> Input, types::ID Type) |
| 146 | : VerifyJobAction(VerifyDebugInfoJobClass, std::move(Input), Type) {} |
Ben Langmuir | 9b9a8d3 | 2014-02-06 18:53:25 +0000 | [diff] [blame] | 147 | |
| 148 | void VerifyPCHJobAction::anchor() {} |
| 149 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 150 | VerifyPCHJobAction::VerifyPCHJobAction(std::unique_ptr<Action> Input, |
| 151 | types::ID Type) |
| 152 | : VerifyJobAction(VerifyPCHJobClass, std::move(Input), Type) {} |