@@ -152,8 +152,8 @@ static Optional<bool> normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned,
152
152
// / argument.
153
153
static void denormalizeSimpleFlag (SmallVectorImpl<const char *> &Args,
154
154
const char *Spelling,
155
- CompilerInvocation::StringAllocator, unsigned ,
156
- /* T*/ ...) {
155
+ CompilerInvocation::StringAllocator,
156
+ Option::OptionClass, unsigned , /* T*/ ...) {
157
157
Args.push_back (Spelling);
158
158
}
159
159
@@ -200,12 +200,41 @@ static auto makeBooleanOptionNormalizer(bool Value, bool OtherValue,
200
200
201
201
static auto makeBooleanOptionDenormalizer (bool Value) {
202
202
return [Value](SmallVectorImpl<const char *> &Args, const char *Spelling,
203
- CompilerInvocation::StringAllocator, unsigned , bool KeyPath) {
203
+ CompilerInvocation::StringAllocator, Option::OptionClass,
204
+ unsigned , bool KeyPath) {
204
205
if (KeyPath == Value)
205
206
Args.push_back (Spelling);
206
207
};
207
208
}
208
209
210
+ static void denormalizeStringImpl (SmallVectorImpl<const char *> &Args,
211
+ const char *Spelling,
212
+ CompilerInvocation::StringAllocator SA,
213
+ Option::OptionClass OptClass, unsigned ,
214
+ Twine Value) {
215
+ switch (OptClass) {
216
+ case Option::SeparateClass:
217
+ case Option::JoinedOrSeparateClass:
218
+ Args.push_back (Spelling);
219
+ Args.push_back (SA (Value));
220
+ break ;
221
+ case Option::JoinedClass:
222
+ Args.push_back (SA (Twine (Spelling) + Value));
223
+ break ;
224
+ default :
225
+ llvm_unreachable (" Cannot denormalize an option with option class "
226
+ " incompatible with string denormalization." );
227
+ }
228
+ }
229
+
230
+ template <typename T>
231
+ static void
232
+ denormalizeString (SmallVectorImpl<const char *> &Args, const char *Spelling,
233
+ CompilerInvocation::StringAllocator SA,
234
+ Option::OptionClass OptClass, unsigned TableIndex, T Value) {
235
+ denormalizeStringImpl (Args, Spelling, SA, OptClass, TableIndex, Twine (Value));
236
+ }
237
+
209
238
static Optional<SimpleEnumValue>
210
239
findValueTableByName (const SimpleEnumValueTable &Table, StringRef Name) {
211
240
for (int I = 0 , E = Table.Size ; I != E; ++I)
@@ -247,12 +276,13 @@ static llvm::Optional<unsigned> normalizeSimpleEnum(OptSpecifier Opt,
247
276
static void denormalizeSimpleEnumImpl (SmallVectorImpl<const char *> &Args,
248
277
const char *Spelling,
249
278
CompilerInvocation::StringAllocator SA,
279
+ Option::OptionClass OptClass,
250
280
unsigned TableIndex, unsigned Value) {
251
281
assert (TableIndex < SimpleEnumValueTablesSize);
252
282
const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
253
283
if (auto MaybeEnumVal = findValueTableByValue (Table, Value)) {
254
- Args. push_back ( Spelling);
255
- Args. push_back ( MaybeEnumVal->Name );
284
+ denormalizeString (Args, Spelling, SA, OptClass, TableIndex,
285
+ MaybeEnumVal->Name );
256
286
} else {
257
287
llvm_unreachable (" The simple enum value was not correctly defined in "
258
288
" the tablegen option description" );
@@ -263,24 +293,12 @@ template <typename T>
263
293
static void denormalizeSimpleEnum (SmallVectorImpl<const char *> &Args,
264
294
const char *Spelling,
265
295
CompilerInvocation::StringAllocator SA,
296
+ Option::OptionClass OptClass,
266
297
unsigned TableIndex, T Value) {
267
- return denormalizeSimpleEnumImpl (Args, Spelling, SA, TableIndex,
298
+ return denormalizeSimpleEnumImpl (Args, Spelling, SA, OptClass, TableIndex,
268
299
static_cast <unsigned >(Value));
269
300
}
270
301
271
- static void denormalizeSimpleEnumJoined (SmallVectorImpl<const char *> &Args,
272
- const char *Spelling,
273
- CompilerInvocation::StringAllocator SA,
274
- unsigned TableIndex, unsigned Value) {
275
- assert (TableIndex < SimpleEnumValueTablesSize);
276
- const SimpleEnumValueTable &Table = SimpleEnumValueTables[TableIndex];
277
- if (auto MaybeEnumVal = findValueTableByValue (Table, Value))
278
- Args.push_back (SA (Twine (Spelling) + MaybeEnumVal->Name ));
279
- else
280
- llvm_unreachable (" The simple enum value was not correctly defined in "
281
- " the tablegen option description" );
282
- }
283
-
284
302
static Optional<std::string> normalizeString (OptSpecifier Opt, int TableIndex,
285
303
const ArgList &Args,
286
304
DiagnosticsEngine &Diags) {
@@ -290,25 +308,6 @@ static Optional<std::string> normalizeString(OptSpecifier Opt, int TableIndex,
290
308
return std::string (Arg->getValue ());
291
309
}
292
310
293
- static void denormalizeString (SmallVectorImpl<const char *> &Args,
294
- const char *Spelling,
295
- CompilerInvocation::StringAllocator SA, unsigned ,
296
- Twine Value) {
297
- Args.push_back (Spelling);
298
- Args.push_back (SA (Value));
299
- }
300
-
301
- template <typename T,
302
- std::enable_if_t <!std::is_convertible<T, Twine>::value &&
303
- std::is_constructible<Twine, T>::value,
304
- bool > = false >
305
- static void denormalizeString (SmallVectorImpl<const char *> &Args,
306
- const char *Spelling,
307
- CompilerInvocation::StringAllocator SA,
308
- unsigned TableIndex, T Value) {
309
- denormalizeString (Args, Spelling, SA, TableIndex, Twine (Value));
310
- }
311
-
312
311
template <typename IntTy>
313
312
static Optional<IntTy> normalizeStringIntegral (OptSpecifier Opt, int ,
314
313
const ArgList &Args,
@@ -3267,7 +3266,8 @@ void CompilerInvocation::generateCC1CommandLine(
3267
3266
(Extracted != \
3268
3267
static_cast <decltype (this ->KEYPATH )>( \
3269
3268
(IMPLIED_CHECK) ? (IMPLIED_VALUE) : (DEFAULT_VALUE)))) \
3270
- DENORMALIZER (Args, SPELLING, SA, TABLE_INDEX, Extracted); \
3269
+ DENORMALIZER (Args, SPELLING, SA, Option::KIND##Class, TABLE_INDEX, \
3270
+ Extracted); \
3271
3271
}(EXTRACTOR (this ->KEYPATH )); \
3272
3272
}
3273
3273
0 commit comments