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/ADT/StringSwitch.h" 12#include "llvm/Support/ErrorHandling.h" 13#include "llvm/Support/Regex.h" 14#include <cassert> 15using namespace clang::driver; 16using namespace llvm::opt; 17 18Action::~Action() {} 19 20const char *Action::getClassName(ActionClass AC) { 21 switch (AC) { 22 case InputClass: return "input"; 23 case BindArchClass: return "bind-arch"; 24 case CudaDeviceClass: return "cuda-device"; 25 case CudaHostClass: return "cuda-host"; 26 case PreprocessJobClass: return "preprocessor"; 27 case PrecompileJobClass: return "precompiler"; 28 case AnalyzeJobClass: return "analyzer"; 29 case MigrateJobClass: return "migrator"; 30 case CompileJobClass: return "compiler"; 31 case BackendJobClass: return "backend"; 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 43void InputAction::anchor() {} 44 45InputAction::InputAction(const Arg &_Input, types::ID _Type) 46 : Action(InputClass, _Type), Input(_Input) { 47} 48 49void BindArchAction::anchor() {} 50 51BindArchAction::BindArchAction(Action *Input, const char *_ArchName) 52 : Action(BindArchClass, Input), ArchName(_ArchName) {} 53 54void CudaDeviceAction::anchor() {} 55 56CudaDeviceAction::CudaDeviceAction(Action *Input, clang::CudaArch Arch, 57 bool AtTopLevel) 58 : Action(CudaDeviceClass, Input), GpuArch(Arch), AtTopLevel(AtTopLevel) {} 59 60void CudaHostAction::anchor() {} 61 62CudaHostAction::CudaHostAction(Action *Input, const ActionList &DeviceActions) 63 : Action(CudaHostClass, Input), DeviceActions(DeviceActions) {} 64 65void JobAction::anchor() {} 66 67JobAction::JobAction(ActionClass Kind, Action *Input, types::ID Type) 68 : Action(Kind, Input, Type) {} 69 70JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type) 71 : Action(Kind, Inputs, Type) { 72} 73 74void PreprocessJobAction::anchor() {} 75 76PreprocessJobAction::PreprocessJobAction(Action *Input, types::ID OutputType) 77 : JobAction(PreprocessJobClass, Input, OutputType) {} 78 79void PrecompileJobAction::anchor() {} 80 81PrecompileJobAction::PrecompileJobAction(Action *Input, types::ID OutputType) 82 : JobAction(PrecompileJobClass, Input, OutputType) {} 83 84void AnalyzeJobAction::anchor() {} 85 86AnalyzeJobAction::AnalyzeJobAction(Action *Input, types::ID OutputType) 87 : JobAction(AnalyzeJobClass, Input, OutputType) {} 88 89void MigrateJobAction::anchor() {} 90 91MigrateJobAction::MigrateJobAction(Action *Input, types::ID OutputType) 92 : JobAction(MigrateJobClass, Input, OutputType) {} 93 94void CompileJobAction::anchor() {} 95 96CompileJobAction::CompileJobAction(Action *Input, types::ID OutputType) 97 : JobAction(CompileJobClass, Input, OutputType) {} 98 99void BackendJobAction::anchor() {} 100 101BackendJobAction::BackendJobAction(Action *Input, types::ID OutputType) 102 : JobAction(BackendJobClass, Input, OutputType) {} 103 104void AssembleJobAction::anchor() {} 105 106AssembleJobAction::AssembleJobAction(Action *Input, types::ID OutputType) 107 : JobAction(AssembleJobClass, Input, OutputType) {} 108 109void LinkJobAction::anchor() {} 110 111LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type) 112 : JobAction(LinkJobClass, Inputs, Type) { 113} 114 115void LipoJobAction::anchor() {} 116 117LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type) 118 : JobAction(LipoJobClass, Inputs, Type) { 119} 120 121void DsymutilJobAction::anchor() {} 122 123DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type) 124 : JobAction(DsymutilJobClass, Inputs, Type) { 125} 126 127void VerifyJobAction::anchor() {} 128 129VerifyJobAction::VerifyJobAction(ActionClass Kind, Action *Input, 130 types::ID Type) 131 : JobAction(Kind, Input, Type) { 132 assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) && 133 "ActionClass is not a valid VerifyJobAction"); 134} 135 136void VerifyDebugInfoJobAction::anchor() {} 137 138VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(Action *Input, 139 types::ID Type) 140 : VerifyJobAction(VerifyDebugInfoJobClass, Input, Type) {} 141 142void VerifyPCHJobAction::anchor() {} 143 144VerifyPCHJobAction::VerifyPCHJobAction(Action *Input, types::ID Type) 145 : VerifyJobAction(VerifyPCHJobClass, Input, Type) {} 146