• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
~Action()16 Action::~Action() {
17   if (OwnsInputs) {
18     for (iterator it = begin(), ie = end(); it != ie; ++it)
19       delete *it;
20   }
21 }
22 
getClassName(ActionClass AC)23 const char *Action::getClassName(ActionClass AC) {
24   switch (AC) {
25   case InputClass: return "input";
26   case BindArchClass: return "bind-arch";
27   case CudaDeviceClass: return "cuda-device";
28   case CudaHostClass: return "cuda-host";
29   case PreprocessJobClass: return "preprocessor";
30   case PrecompileJobClass: return "precompiler";
31   case AnalyzeJobClass: return "analyzer";
32   case MigrateJobClass: return "migrator";
33   case CompileJobClass: return "compiler";
34   case BackendJobClass: return "backend";
35   case AssembleJobClass: return "assembler";
36   case LinkJobClass: return "linker";
37   case LipoJobClass: return "lipo";
38   case DsymutilJobClass: return "dsymutil";
39   case VerifyDebugInfoJobClass: return "verify-debug-info";
40   case VerifyPCHJobClass: return "verify-pch";
41   }
42 
43   llvm_unreachable("invalid class");
44 }
45 
anchor()46 void InputAction::anchor() {}
47 
InputAction(const Arg & _Input,types::ID _Type)48 InputAction::InputAction(const Arg &_Input, types::ID _Type)
49   : Action(InputClass, _Type), Input(_Input) {
50 }
51 
anchor()52 void BindArchAction::anchor() {}
53 
BindArchAction(std::unique_ptr<Action> Input,const char * _ArchName)54 BindArchAction::BindArchAction(std::unique_ptr<Action> Input,
55                                const char *_ArchName)
56     : Action(BindArchClass, std::move(Input)), ArchName(_ArchName) {}
57 
anchor()58 void CudaDeviceAction::anchor() {}
59 
CudaDeviceAction(std::unique_ptr<Action> Input,const char * ArchName,bool AtTopLevel)60 CudaDeviceAction::CudaDeviceAction(std::unique_ptr<Action> Input,
61                                    const char *ArchName, bool AtTopLevel)
62     : Action(CudaDeviceClass, std::move(Input)), GpuArchName(ArchName),
63       AtTopLevel(AtTopLevel) {}
64 
anchor()65 void CudaHostAction::anchor() {}
66 
CudaHostAction(std::unique_ptr<Action> Input,const ActionList & DeviceActions)67 CudaHostAction::CudaHostAction(std::unique_ptr<Action> Input,
68                                const ActionList &DeviceActions)
69     : Action(CudaHostClass, std::move(Input)), DeviceActions(DeviceActions) {}
70 
~CudaHostAction()71 CudaHostAction::~CudaHostAction() {
72   for (auto &DA : DeviceActions)
73     delete DA;
74 }
75 
anchor()76 void JobAction::anchor() {}
77 
JobAction(ActionClass Kind,std::unique_ptr<Action> Input,types::ID Type)78 JobAction::JobAction(ActionClass Kind, std::unique_ptr<Action> Input,
79                      types::ID Type)
80     : Action(Kind, std::move(Input), Type) {}
81 
JobAction(ActionClass Kind,const ActionList & Inputs,types::ID Type)82 JobAction::JobAction(ActionClass Kind, const ActionList &Inputs, types::ID Type)
83   : Action(Kind, Inputs, Type) {
84 }
85 
anchor()86 void PreprocessJobAction::anchor() {}
87 
PreprocessJobAction(std::unique_ptr<Action> Input,types::ID OutputType)88 PreprocessJobAction::PreprocessJobAction(std::unique_ptr<Action> Input,
89                                          types::ID OutputType)
90     : JobAction(PreprocessJobClass, std::move(Input), OutputType) {}
91 
anchor()92 void PrecompileJobAction::anchor() {}
93 
PrecompileJobAction(std::unique_ptr<Action> Input,types::ID OutputType)94 PrecompileJobAction::PrecompileJobAction(std::unique_ptr<Action> Input,
95                                          types::ID OutputType)
96     : JobAction(PrecompileJobClass, std::move(Input), OutputType) {}
97 
anchor()98 void AnalyzeJobAction::anchor() {}
99 
AnalyzeJobAction(std::unique_ptr<Action> Input,types::ID OutputType)100 AnalyzeJobAction::AnalyzeJobAction(std::unique_ptr<Action> Input,
101                                    types::ID OutputType)
102     : JobAction(AnalyzeJobClass, std::move(Input), OutputType) {}
103 
anchor()104 void MigrateJobAction::anchor() {}
105 
MigrateJobAction(std::unique_ptr<Action> Input,types::ID OutputType)106 MigrateJobAction::MigrateJobAction(std::unique_ptr<Action> Input,
107                                    types::ID OutputType)
108     : JobAction(MigrateJobClass, std::move(Input), OutputType) {}
109 
anchor()110 void CompileJobAction::anchor() {}
111 
CompileJobAction(std::unique_ptr<Action> Input,types::ID OutputType)112 CompileJobAction::CompileJobAction(std::unique_ptr<Action> Input,
113                                    types::ID OutputType)
114     : JobAction(CompileJobClass, std::move(Input), OutputType) {}
115 
anchor()116 void BackendJobAction::anchor() {}
117 
BackendJobAction(std::unique_ptr<Action> Input,types::ID OutputType)118 BackendJobAction::BackendJobAction(std::unique_ptr<Action> Input,
119                                    types::ID OutputType)
120     : JobAction(BackendJobClass, std::move(Input), OutputType) {}
121 
anchor()122 void AssembleJobAction::anchor() {}
123 
AssembleJobAction(std::unique_ptr<Action> Input,types::ID OutputType)124 AssembleJobAction::AssembleJobAction(std::unique_ptr<Action> Input,
125                                      types::ID OutputType)
126     : JobAction(AssembleJobClass, std::move(Input), OutputType) {}
127 
anchor()128 void LinkJobAction::anchor() {}
129 
LinkJobAction(ActionList & Inputs,types::ID Type)130 LinkJobAction::LinkJobAction(ActionList &Inputs, types::ID Type)
131   : JobAction(LinkJobClass, Inputs, Type) {
132 }
133 
anchor()134 void LipoJobAction::anchor() {}
135 
LipoJobAction(ActionList & Inputs,types::ID Type)136 LipoJobAction::LipoJobAction(ActionList &Inputs, types::ID Type)
137   : JobAction(LipoJobClass, Inputs, Type) {
138 }
139 
anchor()140 void DsymutilJobAction::anchor() {}
141 
DsymutilJobAction(ActionList & Inputs,types::ID Type)142 DsymutilJobAction::DsymutilJobAction(ActionList &Inputs, types::ID Type)
143   : JobAction(DsymutilJobClass, Inputs, Type) {
144 }
145 
anchor()146 void VerifyJobAction::anchor() {}
147 
VerifyJobAction(ActionClass Kind,std::unique_ptr<Action> Input,types::ID Type)148 VerifyJobAction::VerifyJobAction(ActionClass Kind,
149                                  std::unique_ptr<Action> Input, types::ID Type)
150     : JobAction(Kind, std::move(Input), Type) {
151   assert((Kind == VerifyDebugInfoJobClass || Kind == VerifyPCHJobClass) &&
152          "ActionClass is not a valid VerifyJobAction");
153 }
154 
anchor()155 void VerifyDebugInfoJobAction::anchor() {}
156 
VerifyDebugInfoJobAction(std::unique_ptr<Action> Input,types::ID Type)157 VerifyDebugInfoJobAction::VerifyDebugInfoJobAction(
158     std::unique_ptr<Action> Input, types::ID Type)
159     : VerifyJobAction(VerifyDebugInfoJobClass, std::move(Input), Type) {}
160 
anchor()161 void VerifyPCHJobAction::anchor() {}
162 
VerifyPCHJobAction(std::unique_ptr<Action> Input,types::ID Type)163 VerifyPCHJobAction::VerifyPCHJobAction(std::unique_ptr<Action> Input,
164                                        types::ID Type)
165     : VerifyJobAction(VerifyPCHJobClass, std::move(Input), Type) {}
166