@@ -38,7 +38,7 @@ class Action {
38
38
typedef ArrayRef<const Action *>::iterator iterator;
39
39
typedef ArrayRef<const Action *>::const_iterator const_iterator;
40
40
41
- enum ActionClass {
41
+ enum class Kind : unsigned {
42
42
Input = 0 ,
43
43
CompileJob,
44
44
InterpretJob,
@@ -52,23 +52,24 @@ class Action {
52
52
VerifyDebugInfoJob,
53
53
GeneratePCHJob,
54
54
55
- JobFirst= CompileJob,
56
- JobLast= GeneratePCHJob
55
+ JobFirst = CompileJob,
56
+ JobLast = GeneratePCHJob
57
57
};
58
58
59
- static const char *getClassName (ActionClass AC);
59
+ static const char *getClassName (Kind AC);
60
60
61
61
private:
62
- unsigned Kind : 4 ;
62
+ unsigned RawKind : 4 ;
63
63
unsigned Type : 28 ;
64
64
65
65
friend class Compilation ;
66
66
// / Actions must be created through Compilation::createAction.
67
67
void *operator new (size_t size) { return ::operator new (size); };
68
68
69
69
protected:
70
- Action (ActionClass Kind, file_types::ID Type) : Kind(Kind), Type(Type) {
71
- assert (Kind == getKind () && " not enough bits" );
70
+ Action (Kind K, file_types::ID Type)
71
+ : RawKind(unsigned (K)), Type(Type) {
72
+ assert (K == getKind () && " not enough bits" );
72
73
assert (Type == getType () && " not enough bits" );
73
74
}
74
75
@@ -77,7 +78,7 @@ class Action {
77
78
78
79
const char *getClassName () const { return Action::getClassName (getKind ()); }
79
80
80
- ActionClass getKind () const { return static_cast <ActionClass>(Kind ); }
81
+ Kind getKind () const { return static_cast <Kind>(RawKind ); }
81
82
file_types::ID getType () const { return static_cast <file_types::ID>(Type); }
82
83
};
83
84
@@ -87,19 +88,19 @@ class InputAction : public Action {
87
88
88
89
public:
89
90
InputAction (const llvm::opt::Arg &Input, file_types::ID Type)
90
- : Action(Action::Input, Type), Input(Input) {}
91
+ : Action(Action::Kind:: Input, Type), Input(Input) {}
91
92
const llvm::opt::Arg &getInputArg () const { return Input; }
92
93
93
94
static bool classof (const Action *A) {
94
- return A->getKind () == Action::Input;
95
+ return A->getKind () == Action::Kind:: Input;
95
96
}
96
97
};
97
98
98
99
class JobAction : public Action {
99
100
TinyPtrVector<const Action *> Inputs;
100
101
virtual void anchor ();
101
102
protected:
102
- JobAction (ActionClass Kind, ArrayRef<const Action *> Inputs,
103
+ JobAction (Kind Kind, ArrayRef<const Action *> Inputs,
103
104
file_types::ID Type)
104
105
: Action(Kind, Type), Inputs(Inputs) {}
105
106
@@ -120,8 +121,8 @@ class JobAction : public Action {
120
121
virtual size_t getInputIndex () const { return 0 ; }
121
122
122
123
static bool classof (const Action *A) {
123
- return (A->getKind () >= ActionClass ::JobFirst &&
124
- A->getKind () <= ActionClass ::JobLast);
124
+ return (A->getKind () >= Kind ::JobFirst &&
125
+ A->getKind () <= Kind ::JobLast);
125
126
}
126
127
};
127
128
@@ -152,17 +153,19 @@ class CompileJobAction : public JobAction {
152
153
153
154
public:
154
155
CompileJobAction (file_types::ID OutputType)
155
- : JobAction(Action::CompileJob, None, OutputType), inputInfo() {}
156
+ : JobAction(Action::Kind::CompileJob, None, OutputType),
157
+ inputInfo () {}
156
158
157
159
CompileJobAction (Action *Input, file_types::ID OutputType, InputInfo info)
158
- : JobAction(Action::CompileJob, Input, OutputType), inputInfo(info) {}
160
+ : JobAction(Action::Kind::CompileJob, Input, OutputType),
161
+ inputInfo(info) {}
159
162
160
163
InputInfo getInputInfo () const {
161
164
return inputInfo;
162
165
}
163
166
164
167
static bool classof (const Action *A) {
165
- return A->getKind () == Action::CompileJob;
168
+ return A->getKind () == Action::Kind:: CompileJob;
166
169
}
167
170
};
168
171
@@ -172,10 +175,11 @@ class InterpretJobAction : public JobAction {
172
175
173
176
public:
174
177
explicit InterpretJobAction ()
175
- : JobAction(Action::InterpretJob, llvm::None, file_types::TY_Nothing) {}
178
+ : JobAction(Action::Kind::InterpretJob, llvm::None,
179
+ file_types::TY_Nothing) {}
176
180
177
181
static bool classof (const Action *A) {
178
- return A->getKind () == Action::InterpretJob;
182
+ return A->getKind () == Action::Kind:: InterpretJob;
179
183
}
180
184
};
181
185
@@ -190,10 +194,10 @@ class BackendJobAction : public JobAction {
190
194
public:
191
195
BackendJobAction (const Action *Input, file_types::ID OutputType,
192
196
size_t InputIndex)
193
- : JobAction(Action::BackendJob, Input, OutputType),
197
+ : JobAction(Action::Kind:: BackendJob, Input, OutputType),
194
198
InputIndex (InputIndex) {}
195
199
static bool classof (const Action *A) {
196
- return A->getKind () == Action::BackendJob;
200
+ return A->getKind () == Action::Kind:: BackendJob;
197
201
}
198
202
199
203
virtual size_t getInputIndex () const { return InputIndex; }
@@ -211,70 +215,74 @@ class REPLJobAction : public JobAction {
211
215
Mode RequestedMode;
212
216
public:
213
217
REPLJobAction (Mode mode)
214
- : JobAction(Action::REPLJob, llvm::None, file_types::TY_Nothing),
218
+ : JobAction(Action::Kind::REPLJob, llvm::None,
219
+ file_types::TY_Nothing),
215
220
RequestedMode (mode) {}
216
221
217
222
Mode getRequestedMode () const { return RequestedMode; }
218
223
219
224
static bool classof (const Action *A) {
220
- return A->getKind () == Action::REPLJob;
225
+ return A->getKind () == Action::Kind:: REPLJob;
221
226
}
222
227
};
223
228
224
229
class MergeModuleJobAction : public JobAction {
225
230
virtual void anchor ();
226
231
public:
227
232
MergeModuleJobAction (ArrayRef<const Action *> Inputs)
228
- : JobAction(Action::MergeModuleJob, Inputs,
233
+ : JobAction(Action::Kind:: MergeModuleJob, Inputs,
229
234
file_types::TY_SwiftModuleFile) {}
230
235
231
236
static bool classof (const Action *A) {
232
- return A->getKind () == Action::MergeModuleJob;
237
+ return A->getKind () == Action::Kind:: MergeModuleJob;
233
238
}
234
239
};
235
240
236
241
class ModuleWrapJobAction : public JobAction {
237
242
virtual void anchor ();
238
243
public:
239
244
ModuleWrapJobAction (ArrayRef<const Action *> Inputs)
240
- : JobAction(Action::ModuleWrapJob, Inputs, file_types::TY_Object) {}
245
+ : JobAction(Action::Kind::ModuleWrapJob, Inputs,
246
+ file_types::TY_Object) {}
241
247
242
248
static bool classof (const Action *A) {
243
- return A->getKind () == Action::ModuleWrapJob;
249
+ return A->getKind () == Action::Kind:: ModuleWrapJob;
244
250
}
245
251
};
246
252
247
253
class AutolinkExtractJobAction : public JobAction {
248
254
virtual void anchor ();
249
255
public:
250
256
AutolinkExtractJobAction (ArrayRef<const Action *> Inputs)
251
- : JobAction(Action::AutolinkExtractJob, Inputs,
257
+ : JobAction(Action::Kind:: AutolinkExtractJob, Inputs,
252
258
file_types::TY_AutolinkFile) {}
253
259
254
260
static bool classof (const Action *A) {
255
- return A->getKind () == Action::AutolinkExtractJob;
261
+ return A->getKind () == Action::Kind:: AutolinkExtractJob;
256
262
}
257
263
};
258
264
259
265
class GenerateDSYMJobAction : public JobAction {
260
266
virtual void anchor ();
261
267
public:
262
268
explicit GenerateDSYMJobAction (const Action *Input)
263
- : JobAction(Action::GenerateDSYMJob, Input, file_types::TY_dSYM) {}
269
+ : JobAction(Action::Kind::GenerateDSYMJob, Input,
270
+ file_types::TY_dSYM) {}
264
271
265
272
static bool classof (const Action *A) {
266
- return A->getKind () == Action::GenerateDSYMJob;
273
+ return A->getKind () == Action::Kind:: GenerateDSYMJob;
267
274
}
268
275
};
269
276
270
277
class VerifyDebugInfoJobAction : public JobAction {
271
278
virtual void anchor ();
272
279
public:
273
280
explicit VerifyDebugInfoJobAction (const Action *Input)
274
- : JobAction(Action::VerifyDebugInfoJob, Input, file_types::TY_Nothing) {}
281
+ : JobAction(Action::Kind::VerifyDebugInfoJob, Input,
282
+ file_types::TY_Nothing) {}
275
283
276
284
static bool classof (const Action *A) {
277
- return A->getKind () == Action::VerifyDebugInfoJob;
285
+ return A->getKind () == Action::Kind:: VerifyDebugInfoJob;
278
286
}
279
287
};
280
288
@@ -284,7 +292,7 @@ class GeneratePCHJobAction : public JobAction {
284
292
virtual void anchor ();
285
293
public:
286
294
GeneratePCHJobAction (const Action *Input, StringRef persistentPCHDir)
287
- : JobAction(Action::GeneratePCHJob, Input,
295
+ : JobAction(Action::Kind:: GeneratePCHJob, Input,
288
296
persistentPCHDir.empty() ? file_types::TY_PCH
289
297
: file_types::TY_Nothing),
290
298
PersistentPCHDir (persistentPCHDir) {}
@@ -293,7 +301,7 @@ class GeneratePCHJobAction : public JobAction {
293
301
StringRef getPersistentPCHDir () const { return PersistentPCHDir; }
294
302
295
303
static bool classof (const Action *A) {
296
- return A->getKind () == Action::GeneratePCHJob;
304
+ return A->getKind () == Action::Kind:: GeneratePCHJob;
297
305
}
298
306
};
299
307
@@ -303,14 +311,15 @@ class LinkJobAction : public JobAction {
303
311
304
312
public:
305
313
LinkJobAction (ArrayRef<const Action *> Inputs, LinkKind K)
306
- : JobAction(Action::LinkJob, Inputs, file_types::TY_Image), Kind(K) {
314
+ : JobAction(Action::Kind::LinkJob, Inputs, file_types::TY_Image),
315
+ Kind (K) {
307
316
assert (Kind != LinkKind::None);
308
317
}
309
318
310
319
LinkKind getKind () const { return Kind; }
311
320
312
321
static bool classof (const Action *A) {
313
- return A->getKind () == Action::LinkJob;
322
+ return A->getKind () == Action::Kind:: LinkJob;
314
323
}
315
324
};
316
325
0 commit comments