1 //===--- Action.cpp - Abstract compilation steps --------------------------===// 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" 11 #include "llvm/Support/ErrorHandling.h" 12 #include <cassert> 13 using namespace clang::driver; 14 using namespace llvm::opt; 15 16 Action::~Action() { 17 if (OwnsInputs) { 18 for (iterator it = begin(), ie = end(); it != ie; ++it) 19 delete *it; 20 } 21 } 22 23 const char *Action::getClassName(ActionClass AC) { 24 switch (AC) { 25 case InputClass: return "input"; 26 case BindArchClass: return "bind-arch"; 27 case PreprocessJobClass: return "preprocessor"; 28 case PrecompileJobClass: return "precompiler"; 29 case AnalyzeJobClass: return "analyzer"; 30 case MigrateJobClass: return "migrator"; 31 case CompileJobClass: return "compiler"; 32 case AssembleJobClass: return "assembler"; 33 case LinkJobClass: return "linker"; 34 case LipoJobClass: return "lipo"; 35 case DsymutilJobClass: return "dsymutil"; 36 case VerifyDebugInfoJobClass: return "verify-debug-info"; 37 case VerifyPCHJobClass: return "verify-pch"; 38 } 39 40 llvm_unreachable("invalid class"); 41 } 42 43 void InputAction::anchor() {} 44 45 InputAction::InputAction(const Arg &_Input, types::ID _Type) 46 : Action(InputClass, _Type), Input(_Input) { 47 } 48 49 void BindArchAction::anchor() {} 50 51 BindArchAction::BindArchAction(Action *Input, const char *_ArchName) 52 : Action(BindArchClass, Input, Input->getType()), ArchName(_ArchName) { 53 } 54 55 void JobAction::anchor() {} 56 57 JobAction::JobAction(ActionClass Kind, Action *Input, types::ID Type) 58 : Action(Kind, Input, Type) { 59 } 60 61 JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type) 62 : Action(Kind, Inputs, Type) { 63 } 64 65 void PreprocessJobAction::anchor() {} 66 67 PreprocessJobAction::PreprocessJobAction(Action *Input, types::ID OutputType) 68 : JobAction(PreprocessJobClass, Input, OutputType) { 69 } 70 71 void PrecompileJobAction::anchor() {} 72 73 PrecompileJobAction::PrecompileJobAction(Action *Input, types::ID OutputType) 74 : JobAction(PrecompileJobClass, Input, OutputType) { 75 } 76 77 void AnalyzeJobAction::anchor() {} 78 79 AnalyzeJobAction::AnalyzeJobAction(Action *Input, types::ID OutputType) 80 : JobAction(AnalyzeJobClass, Input, OutputType) { 81 } 82 83 void MigrateJobAction::anchor() {} 84 85 MigrateJobAction::MigrateJobAction(Action *Input, types::ID OutputType) 86 : JobAction(MigrateJobClass, Input, OutputType) { 87 } 88 89 void CompileJobAction::anchor() {} 90 91 CompileJobAction::CompileJobAction(Action *Input, types::ID OutputType) 92 : JobAction(CompileJobClass, Input, OutputType) { 93 } 94 95 void AssembleJobAction::anchor() {} 96 97 AssembleJobAction::AssembleJobAction(Action *Input, types::ID OutputType) 98 : JobAction(AssembleJobClass, Input, OutputType) { 99 } 100 101 void LinkJobAction::anchor() {} 102 103 LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type) 104 : JobAction(LinkJobClass, Inputs, Type) { 105 } 106 107 void LipoJobAction::anchor() {} 108 109 LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type) 110 : JobAction(LipoJobClass, Inputs, Type) { 111 } 112 113 void DsymutilJobAction::anchor() {} 114 115 DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type) 116 : JobAction(DsymutilJobClass, Inputs, Type) { 117 } 118 119 void VerifyJobAction::anchor() {} 120 121 VerifyJobAction::VerifyJobAction(ActionClass Kind, Action *Input, 122 types::ID Type) 123 : JobAction(Kind, Input, Type) { 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 137 VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(Action *Input, 138 types::ID Type) 139 : VerifyJobAction(VerifyDebugInfoJobClass, Input, Type) { 140 } 141 142 void VerifyPCHJobAction::anchor() {} 143 144 VerifyPCHJobAction::VerifyPCHJobAction(Action *Input, types::ID Type) 145 : VerifyJobAction(VerifyPCHJobClass, Input, Type) { 146 } 147