@@ -30,18 +30,6 @@ class ArgList;
30
30
class InputArgList ;
31
31
class Option ;
32
32
33
- // / Helper for overload resolution while transitioning from
34
- // / FlagsToInclude/FlagsToExclude APIs to VisibilityMask APIs.
35
- class Visibility {
36
- unsigned Mask = ~0U ;
37
-
38
- public:
39
- explicit Visibility (unsigned Mask) : Mask(Mask) {}
40
- Visibility () = default ;
41
-
42
- operator unsigned () const { return Mask; }
43
- };
44
-
45
33
// / Provide access to the Option info table.
46
34
// /
47
35
// / The OptTable class provides a layer of indirection which allows Option
@@ -63,7 +51,6 @@ class OptTable {
63
51
unsigned char Kind;
64
52
unsigned char Param;
65
53
unsigned int Flags;
66
- unsigned int Visibility;
67
54
unsigned short GroupID;
68
55
unsigned short AliasID;
69
56
const char *AliasArgs;
@@ -193,8 +180,10 @@ class OptTable {
193
180
// / string includes prefix dashes "-" as well as values "=l".
194
181
// / \param [out] NearestString - The nearest option string found in the
195
182
// / OptTable.
196
- // / \param [in] VisibilityMask - Only include options with any of these
197
- // / visibility flags set.
183
+ // / \param [in] FlagsToInclude - Only find options with any of these flags.
184
+ // / Zero is the default, which includes all flags.
185
+ // / \param [in] FlagsToExclude - Don't find options with this flag. Zero
186
+ // / is the default, and means exclude nothing.
198
187
// / \param [in] MinimumLength - Don't find options shorter than this length.
199
188
// / For example, a minimum length of 3 prevents "-x" from being considered
200
189
// / near to "-S".
@@ -203,29 +192,13 @@ class OptTable {
203
192
// /
204
193
// / \return The edit distance of the nearest string found.
205
194
unsigned findNearest (StringRef Option, std::string &NearestString,
206
- Visibility VisibilityMask = Visibility() ,
195
+ unsigned FlagsToInclude = 0 , unsigned FlagsToExclude = 0 ,
207
196
unsigned MinimumLength = 4 ,
208
197
unsigned MaximumDistance = UINT_MAX) const ;
209
198
210
- unsigned findNearest (StringRef Option, std::string &NearestString,
211
- unsigned FlagsToInclude, unsigned FlagsToExclude = 0 ,
212
- unsigned MinimumLength = 4 ,
213
- unsigned MaximumDistance = UINT_MAX) const ;
214
-
215
- private:
216
- unsigned
217
- internalFindNearest (StringRef Option, std::string &NearestString,
218
- unsigned MinimumLength, unsigned MaximumDistance,
219
- std::function<bool (const Info &)> ExcludeOption) const ;
220
-
221
- public:
222
- bool findExact (StringRef Option, std::string &ExactString,
223
- Visibility VisibilityMask = Visibility()) const {
224
- return findNearest (Option, ExactString, VisibilityMask, 4 , 0 ) == 0 ;
225
- }
226
-
227
199
bool findExact (StringRef Option, std::string &ExactString,
228
- unsigned FlagsToInclude, unsigned FlagsToExclude = 0 ) const {
200
+ unsigned FlagsToInclude = 0 ,
201
+ unsigned FlagsToExclude = 0 ) const {
229
202
return findNearest (Option, ExactString, FlagsToInclude, FlagsToExclude, 4 ,
230
203
0 ) == 0 ;
231
204
}
@@ -236,26 +209,18 @@ class OptTable {
236
209
// / \param [in,out] Index - The current parsing position in the argument
237
210
// / string list; on return this will be the index of the next argument
238
211
// / string to parse.
239
- // / \param [in] VisibilityMask - Only include options with any of these
240
- // / visibility flags set.
212
+ // / \param [in] FlagsToInclude - Only parse options with any of these flags.
213
+ // / Zero is the default which includes all flags.
214
+ // / \param [in] FlagsToExclude - Don't parse options with this flag. Zero
215
+ // / is the default and means exclude nothing.
241
216
// /
242
217
// / \return The parsed argument, or 0 if the argument is missing values
243
218
// / (in which case Index still points at the conceptual next argument string
244
219
// / to parse).
245
- std::unique_ptr<Arg>
246
- ParseOneArg (const ArgList &Args, unsigned &Index,
247
- Visibility VisibilityMask = Visibility()) const ;
248
-
249
220
std::unique_ptr<Arg> ParseOneArg (const ArgList &Args, unsigned &Index,
250
- unsigned FlagsToInclude,
251
- unsigned FlagsToExclude) const ;
252
-
253
- private:
254
- std::unique_ptr<Arg>
255
- internalParseOneArg (const ArgList &Args, unsigned &Index,
256
- std::function<bool (const Option &)> ExcludeOption) const ;
221
+ unsigned FlagsToInclude = 0 ,
222
+ unsigned FlagsToExclude = 0 ) const ;
257
223
258
- public:
259
224
// / Parse an list of arguments into an InputArgList.
260
225
// /
261
226
// / The resulting InputArgList will reference the strings in [\p ArgBegin,
@@ -268,25 +233,16 @@ class OptTable {
268
233
// / \param MissingArgIndex - On error, the index of the option which could
269
234
// / not be parsed.
270
235
// / \param MissingArgCount - On error, the number of missing options.
271
- // / \param VisibilityMask - Only include options with any of these
272
- // / visibility flags set.
236
+ // / \param FlagsToInclude - Only parse options with any of these flags.
237
+ // / Zero is the default which includes all flags.
238
+ // / \param FlagsToExclude - Don't parse options with this flag. Zero
239
+ // / is the default and means exclude nothing.
273
240
// / \return An InputArgList; on error this will contain all the options
274
241
// / which could be parsed.
275
242
InputArgList ParseArgs (ArrayRef<const char *> Args, unsigned &MissingArgIndex,
276
- unsigned &MissingArgCount,
277
- Visibility VisibilityMask = Visibility()) const ;
278
-
279
- InputArgList ParseArgs (ArrayRef<const char *> Args, unsigned &MissingArgIndex,
280
- unsigned &MissingArgCount, unsigned FlagsToInclude,
243
+ unsigned &MissingArgCount, unsigned FlagsToInclude = 0 ,
281
244
unsigned FlagsToExclude = 0 ) const ;
282
245
283
- private:
284
- InputArgList
285
- internalParseArgs (ArrayRef<const char *> Args, unsigned &MissingArgIndex,
286
- unsigned &MissingArgCount,
287
- std::function<bool (const Option &)> ExcludeOption) const ;
288
-
289
- public:
290
246
// / A convenience helper which handles optional initial options populated from
291
247
// / an environment variable, expands response files recursively and parses
292
248
// / options.
@@ -297,32 +253,26 @@ class OptTable {
297
253
// / could be parsed.
298
254
InputArgList parseArgs (int Argc, char *const *Argv, OptSpecifier Unknown,
299
255
StringSaver &Saver,
300
- std::function <void (StringRef)> ErrorFn) const ;
256
+ function_ref <void (StringRef)> ErrorFn) const ;
301
257
302
258
// / Render the help text for an option table.
303
259
// /
304
260
// / \param OS - The stream to write the help text to.
305
261
// / \param Usage - USAGE: Usage
306
262
// / \param Title - OVERVIEW: Title
307
- // / \param VisibilityMask - Only in Visibility VisibilityMask,clude options with any of these
308
- // / visibility flags set.
309
- // / \param ShowHidden - If true, display options marked as HelpHidden
263
+ // / \param FlagsToInclude - If non-zero, only include options with any
264
+ // / of these flags set.
265
+ // / \param FlagsToExclude - Exclude options with any of these flags set.
310
266
// / \param ShowAllAliases - If true, display all options including aliases
311
267
// / that don't have help texts. By default, we display
312
268
// / only options that are not hidden and have help
313
269
// / texts.
314
- void printHelp (raw_ostream &OS, const char *Usage, const char *Title,
315
- bool ShowHidden = false , bool ShowAllAliases = false ,
316
- Visibility VisibilityMask = Visibility()) const ;
317
-
318
270
void printHelp (raw_ostream &OS, const char *Usage, const char *Title,
319
271
unsigned FlagsToInclude, unsigned FlagsToExclude,
320
272
bool ShowAllAliases) const ;
321
273
322
- private:
323
- void internalPrintHelp (raw_ostream &OS, const char *Usage, const char *Title,
324
- bool ShowHidden, bool ShowAllAliases,
325
- std::function<bool (const Info &)> ExcludeOption) const ;
274
+ void printHelp (raw_ostream &OS, const char *Usage, const char *Title,
275
+ bool ShowHidden = false , bool ShowAllAliases = false ) const ;
326
276
};
327
277
328
278
// / Specialization of OptTable
@@ -355,32 +305,31 @@ class PrecomputedOptTable : public OptTable {
355
305
356
306
} // end namespace llvm
357
307
358
- #define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX ( \
359
- ID_PREFIX, PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, \
360
- FLAGS, VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES) \
308
+ #define LLVM_MAKE_OPT_ID_WITH_ID_PREFIX (ID_PREFIX, PREFIX, PREFIXED_NAME, ID, \
309
+ KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
310
+ PARAM, HELPTEXT, METAVAR, VALUES) \
361
311
ID_PREFIX##ID
362
312
363
313
#define LLVM_MAKE_OPT_ID (PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, \
364
- ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, \
365
- METAVAR, VALUES) \
314
+ ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, VALUES) \
366
315
LLVM_MAKE_OPT_ID_WITH_ID_PREFIX (OPT_, PREFIX, PREFIXED_NAME, ID, KIND, \
367
- GROUP, ALIAS, ALIASARGS, FLAGS, VISIBILITY, \
368
- PARAM, HELPTEXT, METAVAR, VALUE)
316
+ GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
317
+ HELPTEXT, METAVAR, VALUE)
369
318
370
319
#define LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX ( \
371
320
ID_PREFIX, PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, \
372
- FLAGS, VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES) \
321
+ FLAGS, PARAM, HELPTEXT, METAVAR, VALUES) \
373
322
llvm::opt::OptTable::Info { \
374
323
PREFIX, PREFIXED_NAME, HELPTEXT, METAVAR, ID_PREFIX##ID, \
375
- llvm::opt::Option::KIND##Class, PARAM, FLAGS, VISIBILITY, \
376
- ID_PREFIX##GROUP, ID_PREFIX## ALIAS, ALIASARGS, VALUES \
324
+ llvm::opt::Option::KIND##Class, PARAM, FLAGS, ID_PREFIX##GROUP, \
325
+ ID_PREFIX##ALIAS, ALIASARGS, VALUES \
377
326
}
378
327
379
328
#define LLVM_CONSTRUCT_OPT_INFO (PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, \
380
- ALIASARGS, FLAGS, VISIBILITY, PARAM, HELPTEXT, \
381
- METAVAR, VALUES) \
382
- LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX ( \
383
- OPT_, PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
384
- VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES)
329
+ ALIASARGS, FLAGS, PARAM, HELPTEXT, METAVAR, \
330
+ VALUES) \
331
+ LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX (OPT_, PREFIX, PREFIXED_NAME, ID, \
332
+ KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
333
+ PARAM, HELPTEXT, METAVAR, VALUES)
385
334
386
335
#endif // LLVM_OPTION_OPTTABLE_H
0 commit comments