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"; |
| 32 | case AssembleJobClass: return "assembler"; |
| 33 | case LinkJobClass: return "linker"; |
Daniel Dunbar | 80665fb | 2009-03-13 12:17:08 +0000 | [diff] [blame] | 34 | case LipoJobClass: return "lipo"; |
Daniel Dunbar | 8829962 | 2010-06-04 18:28:36 +0000 | [diff] [blame] | 35 | case DsymutilJobClass: return "dsymutil"; |
Ben Langmuir | 9b9a8d3 | 2014-02-06 18:53:25 +0000 | [diff] [blame] | 36 | case VerifyDebugInfoJobClass: return "verify-debug-info"; |
| 37 | case VerifyPCHJobClass: return "verify-pch"; |
Daniel Dunbar | 80665fb | 2009-03-13 12:17:08 +0000 | [diff] [blame] | 38 | } |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 39 | |
David Blaikie | 83d382b | 2011-09-23 05:06:16 +0000 | [diff] [blame] | 40 | llvm_unreachable("invalid class"); |
Daniel Dunbar | 80665fb | 2009-03-13 12:17:08 +0000 | [diff] [blame] | 41 | } |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 42 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 43 | void InputAction::anchor() {} |
| 44 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 45 | InputAction::InputAction(const Arg &_Input, types::ID _Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 46 | : Action(InputClass, _Type), Input(_Input) { |
| 47 | } |
| 48 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 49 | void BindArchAction::anchor() {} |
| 50 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 51 | BindArchAction::BindArchAction(std::unique_ptr<Action> Input, |
| 52 | const char *_ArchName) |
| 53 | : Action(BindArchClass, std::move(Input)), ArchName(_ArchName) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 54 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 55 | void JobAction::anchor() {} |
| 56 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 57 | JobAction::JobAction(ActionClass Kind, std::unique_ptr<Action> Input, |
| 58 | types::ID Type) |
| 59 | : Action(Kind, std::move(Input), Type) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 60 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 61 | JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 62 | : Action(Kind, Inputs, Type) { |
| 63 | } |
| 64 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 65 | void PreprocessJobAction::anchor() {} |
| 66 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 67 | PreprocessJobAction::PreprocessJobAction(std::unique_ptr<Action> Input, |
| 68 | types::ID OutputType) |
| 69 | : JobAction(PreprocessJobClass, std::move(Input), OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 70 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 71 | void PrecompileJobAction::anchor() {} |
| 72 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 73 | PrecompileJobAction::PrecompileJobAction(std::unique_ptr<Action> Input, |
| 74 | types::ID OutputType) |
| 75 | : JobAction(PrecompileJobClass, std::move(Input), OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 76 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 77 | void AnalyzeJobAction::anchor() {} |
| 78 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 79 | AnalyzeJobAction::AnalyzeJobAction(std::unique_ptr<Action> Input, |
| 80 | types::ID OutputType) |
| 81 | : JobAction(AnalyzeJobClass, std::move(Input), OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 82 | |
Ted Kremenek | f7639e1 | 2012-03-06 20:06:33 +0000 | [diff] [blame] | 83 | void MigrateJobAction::anchor() {} |
| 84 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 85 | MigrateJobAction::MigrateJobAction(std::unique_ptr<Action> Input, |
| 86 | types::ID OutputType) |
| 87 | : JobAction(MigrateJobClass, std::move(Input), OutputType) {} |
Ted Kremenek | f7639e1 | 2012-03-06 20:06:33 +0000 | [diff] [blame] | 88 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 89 | void CompileJobAction::anchor() {} |
| 90 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 91 | CompileJobAction::CompileJobAction(std::unique_ptr<Action> Input, |
| 92 | types::ID OutputType) |
| 93 | : JobAction(CompileJobClass, std::move(Input), OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 94 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 95 | void AssembleJobAction::anchor() {} |
| 96 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 97 | AssembleJobAction::AssembleJobAction(std::unique_ptr<Action> Input, |
| 98 | types::ID OutputType) |
| 99 | : JobAction(AssembleJobClass, std::move(Input), OutputType) {} |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 100 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 101 | void LinkJobAction::anchor() {} |
| 102 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 103 | LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 104 | : JobAction(LinkJobClass, Inputs, Type) { |
| 105 | } |
| 106 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 107 | void LipoJobAction::anchor() {} |
| 108 | |
Mike Stump | 11289f4 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 109 | LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type) |
Daniel Dunbar | 3f261ff | 2009-03-13 23:08:03 +0000 | [diff] [blame] | 110 | : JobAction(LipoJobClass, Inputs, Type) { |
| 111 | } |
Daniel Dunbar | 8829962 | 2010-06-04 18:28:36 +0000 | [diff] [blame] | 112 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 113 | void DsymutilJobAction::anchor() {} |
| 114 | |
Daniel Dunbar | 8829962 | 2010-06-04 18:28:36 +0000 | [diff] [blame] | 115 | DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type) |
| 116 | : JobAction(DsymutilJobClass, Inputs, Type) { |
| 117 | } |
Eric Christopher | 551ef45 | 2011-08-23 17:56:55 +0000 | [diff] [blame] | 118 | |
David Blaikie | 68e081d | 2011-12-20 02:48:34 +0000 | [diff] [blame] | 119 | void VerifyJobAction::anchor() {} |
| 120 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 121 | VerifyJobAction::VerifyJobAction(ActionClass Kind, |
| 122 | std::unique_ptr<Action> Input, types::ID Type) |
| 123 | : JobAction(Kind, std::move(Input), Type) { |
Ben Langmuir | 9b9a8d3 | 2014-02-06 18:53:25 +0000 | [diff] [blame] | 124 | assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) && |
| 125 | "ActionClass is not a valid VerifyJobAction"); |
| 126 | } |
| 127 | |
| 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 | |
| 135 | void VerifyDebugInfoJobAction::anchor() {} |
| 136 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 137 | VerifyDebugInfoJobAction::VerifyDebugInfoJobAction( |
| 138 | std::unique_ptr<Action> Input, types::ID Type) |
| 139 | : VerifyJobAction(VerifyDebugInfoJobClass, std::move(Input), Type) {} |
Ben Langmuir | 9b9a8d3 | 2014-02-06 18:53:25 +0000 | [diff] [blame] | 140 | |
| 141 | void VerifyPCHJobAction::anchor() {} |
| 142 | |
David Blaikie | 486f440 | 2014-08-29 07:25:23 +0000 | [diff] [blame] | 143 | VerifyPCHJobAction::VerifyPCHJobAction(std::unique_ptr<Action> Input, |
| 144 | types::ID Type) |
| 145 | : VerifyJobAction(VerifyPCHJobClass, std::move(Input), Type) {} |