Skip to content

Commit 4e3b894

Browse files
committed
Revert "[Option] Add "Visibility" field and clone the OptTable APIs to use it"
this is failing on bots, reverting to investigate. This reverts commit a16104e.
1 parent a16104e commit 4e3b894

File tree

29 files changed

+80
-337
lines changed

29 files changed

+80
-337
lines changed

clang-tools-extra/clangd/CompileCommands.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ llvm::ArrayRef<ArgStripper::Rule> ArgStripper::rulesFor(llvm::StringRef Arg) {
494494
static constexpr llvm::ArrayRef<llvm::StringLiteral> NAME( \
495495
NAME##_init, std::size(NAME##_init) - 1);
496496
#define OPTION(PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, \
497-
FLAGS, VISIBILITY, PARAM, HELP, METAVAR, VALUES) \
497+
FLAGS, PARAM, HELP, METAVAR, VALUES) \
498498
Prefixes[DriverID::OPT_##ID] = PREFIX;
499499
#include "clang/Driver/Options.inc"
500500
#undef OPTION
@@ -506,7 +506,7 @@ llvm::ArrayRef<ArgStripper::Rule> ArgStripper::rulesFor(llvm::StringRef Arg) {
506506
const void *AliasArgs;
507507
} AliasTable[] = {
508508
#define OPTION(PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, \
509-
FLAGS, VISIBILITY, PARAM, HELP, METAVAR, VALUES) \
509+
FLAGS, PARAM, HELP, METAVAR, VALUES) \
510510
{DriverID::OPT_##ID, DriverID::OPT_##ALIAS, ALIASARGS},
511511
#include "clang/Driver/Options.inc"
512512
#undef OPTION

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,9 @@ static T extractMaskValue(T KeyPath) {
423423

424424
#define PARSE_OPTION_WITH_MARSHALLING( \
425425
ARGS, DIAGS, PREFIX_TYPE, SPELLING, ID, KIND, GROUP, ALIAS, ALIASARGS, \
426-
FLAGS, VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES, SHOULD_PARSE, \
427-
ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, \
428-
NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX) \
426+
FLAGS, PARAM, HELPTEXT, METAVAR, VALUES, SHOULD_PARSE, ALWAYS_EMIT, \
427+
KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, \
428+
DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX) \
429429
if ((FLAGS)&options::CC1Option) { \
430430
KEYPATH = MERGER(KEYPATH, DEFAULT_VALUE); \
431431
if (IMPLIED_CHECK) \
@@ -440,9 +440,9 @@ static T extractMaskValue(T KeyPath) {
440440
// with lifetime extension of the reference.
441441
#define GENERATE_OPTION_WITH_MARSHALLING( \
442442
CONSUMER, PREFIX_TYPE, SPELLING, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
443-
VISIBILKITY, PARAM, HELPTEXT, METAVAR, VALUES, SHOULD_PARSE, ALWAYS_EMIT, \
444-
KEYPATH, DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, \
445-
DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX) \
443+
PARAM, HELPTEXT, METAVAR, VALUES, SHOULD_PARSE, ALWAYS_EMIT, KEYPATH, \
444+
DEFAULT_VALUE, IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, \
445+
MERGER, EXTRACTOR, TABLE_INDEX) \
446446
if ((FLAGS)&options::CC1Option) { \
447447
[&](const auto &Extracted) { \
448448
if (ALWAYS_EMIT || \

lld/MachO/DriverUtils.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,9 @@ using namespace lld::macho;
4444

4545
// Create table mapping all options defined in Options.td
4646
static constexpr OptTable::Info optInfo[] = {
47-
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
48-
VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES) \
49-
{PREFIX, NAME, HELPTEXT, \
50-
METAVAR, OPT_##ID, opt::Option::KIND##Class, \
51-
PARAM, FLAGS, VISIBILITY, \
52-
OPT_##GROUP, OPT_##ALIAS, ALIASARGS, \
53-
VALUES},
47+
#define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12) \
48+
{X1, X2, X10, X11, OPT_##ID, Option::KIND##Class, \
49+
X9, X8, OPT_##GROUP, OPT_##ALIAS, X7, X12},
5450
#include "Options.inc"
5551
#undef OPTION
5652
};

lld/MinGW/Driver.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,9 @@ enum {
7171

7272
// Create table mapping all options defined in Options.td
7373
static constexpr opt::OptTable::Info infoTable[] = {
74-
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
75-
VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES) \
76-
{PREFIX, NAME, HELPTEXT, \
77-
METAVAR, OPT_##ID, opt::Option::KIND##Class, \
78-
PARAM, FLAGS, VISIBILITY, \
79-
OPT_##GROUP, OPT_##ALIAS, ALIASARGS, \
80-
VALUES},
74+
#define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12) \
75+
{X1, X2, X10, X11, OPT_##ID, opt::Option::KIND##Class, \
76+
X9, X8, OPT_##GROUP, OPT_##ALIAS, X7, X12},
8177
#include "Options.inc"
8278
#undef OPTION
8379
};

lld/wasm/Driver.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,9 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
111111

112112
// Create table mapping all options defined in Options.td
113113
static constexpr opt::OptTable::Info optInfo[] = {
114-
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \
115-
VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES) \
116-
{PREFIX, NAME, HELPTEXT, \
117-
METAVAR, OPT_##ID, opt::Option::KIND##Class, \
118-
PARAM, FLAGS, VISIBILITY, \
119-
OPT_##GROUP, OPT_##ALIAS, ALIASARGS, \
120-
VALUES},
114+
#define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12) \
115+
{X1, X2, X10, X11, OPT_##ID, opt::Option::KIND##Class, \
116+
X9, X8, OPT_##GROUP, OPT_##ALIAS, X7, X12},
121117
#include "Options.inc"
122118
#undef OPTION
123119
};

llvm/include/llvm/Option/OptParser.td

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,6 @@ def RenderJoined : OptionFlag;
7373
// (only sensible on joined options).
7474
def RenderSeparate : OptionFlag;
7575

76-
// Define Visibility categories
77-
78-
class OptionVisibility {}
79-
80-
// Explicit specifier for default visibility
81-
def Default : OptionVisibility;
82-
8376
// Define the option group class.
8477

8578
class OptionGroup<string name> {
@@ -88,7 +81,6 @@ class OptionGroup<string name> {
8881
string HelpText = ?;
8982
OptionGroup Group = ?;
9083
list<OptionFlag> Flags = [];
91-
list<OptionVisibility> Vis = [];
9284
}
9385

9486
// Define the option class.
@@ -105,7 +97,6 @@ class Option<list<string> prefixes, string name, OptionKind kind> {
10597
string Values = ?;
10698
code ValuesCode = ?;
10799
list<OptionFlag> Flags = [];
108-
list<OptionVisibility> Vis = [Default];
109100
OptionGroup Group = ?;
110101
Option Alias = ?;
111102
list<string> AliasArgs = [];
@@ -150,7 +141,6 @@ class Alias<Option alias> { Option Alias = alias; }
150141
class AliasArgs<list<string> aliasargs> { list<string> AliasArgs = aliasargs; }
151142
class EnumName<string name> { string EnumName = name; }
152143
class Flags<list<OptionFlag> flags> { list<OptionFlag> Flags = flags; }
153-
class Vis<list<OptionVisibility> vis> { list<OptionVisibility> Vis = vis; }
154144
class Group<OptionGroup group> { OptionGroup Group = group; }
155145
class HelpText<string text> { string HelpText = text; }
156146
class MetaVarName<string name> { string MetaVarName = name; }

llvm/include/llvm/Option/OptTable.h

Lines changed: 38 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,6 @@ class ArgList;
3030
class InputArgList;
3131
class Option;
3232

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-
4533
/// Provide access to the Option info table.
4634
///
4735
/// The OptTable class provides a layer of indirection which allows Option
@@ -63,7 +51,6 @@ class OptTable {
6351
unsigned char Kind;
6452
unsigned char Param;
6553
unsigned int Flags;
66-
unsigned int Visibility;
6754
unsigned short GroupID;
6855
unsigned short AliasID;
6956
const char *AliasArgs;
@@ -193,8 +180,10 @@ class OptTable {
193180
/// string includes prefix dashes "-" as well as values "=l".
194181
/// \param [out] NearestString - The nearest option string found in the
195182
/// 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.
198187
/// \param [in] MinimumLength - Don't find options shorter than this length.
199188
/// For example, a minimum length of 3 prevents "-x" from being considered
200189
/// near to "-S".
@@ -203,29 +192,13 @@ class OptTable {
203192
///
204193
/// \return The edit distance of the nearest string found.
205194
unsigned findNearest(StringRef Option, std::string &NearestString,
206-
Visibility VisibilityMask = Visibility(),
195+
unsigned FlagsToInclude = 0, unsigned FlagsToExclude = 0,
207196
unsigned MinimumLength = 4,
208197
unsigned MaximumDistance = UINT_MAX) const;
209198

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-
227199
bool findExact(StringRef Option, std::string &ExactString,
228-
unsigned FlagsToInclude, unsigned FlagsToExclude = 0) const {
200+
unsigned FlagsToInclude = 0,
201+
unsigned FlagsToExclude = 0) const {
229202
return findNearest(Option, ExactString, FlagsToInclude, FlagsToExclude, 4,
230203
0) == 0;
231204
}
@@ -236,26 +209,18 @@ class OptTable {
236209
/// \param [in,out] Index - The current parsing position in the argument
237210
/// string list; on return this will be the index of the next argument
238211
/// 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.
241216
///
242217
/// \return The parsed argument, or 0 if the argument is missing values
243218
/// (in which case Index still points at the conceptual next argument string
244219
/// to parse).
245-
std::unique_ptr<Arg>
246-
ParseOneArg(const ArgList &Args, unsigned &Index,
247-
Visibility VisibilityMask = Visibility()) const;
248-
249220
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;
257223

258-
public:
259224
/// Parse an list of arguments into an InputArgList.
260225
///
261226
/// The resulting InputArgList will reference the strings in [\p ArgBegin,
@@ -268,25 +233,16 @@ class OptTable {
268233
/// \param MissingArgIndex - On error, the index of the option which could
269234
/// not be parsed.
270235
/// \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.
273240
/// \return An InputArgList; on error this will contain all the options
274241
/// which could be parsed.
275242
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,
281244
unsigned FlagsToExclude = 0) const;
282245

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:
290246
/// A convenience helper which handles optional initial options populated from
291247
/// an environment variable, expands response files recursively and parses
292248
/// options.
@@ -297,32 +253,26 @@ class OptTable {
297253
/// could be parsed.
298254
InputArgList parseArgs(int Argc, char *const *Argv, OptSpecifier Unknown,
299255
StringSaver &Saver,
300-
std::function<void(StringRef)> ErrorFn) const;
256+
function_ref<void(StringRef)> ErrorFn) const;
301257

302258
/// Render the help text for an option table.
303259
///
304260
/// \param OS - The stream to write the help text to.
305261
/// \param Usage - USAGE: Usage
306262
/// \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.
310266
/// \param ShowAllAliases - If true, display all options including aliases
311267
/// that don't have help texts. By default, we display
312268
/// only options that are not hidden and have help
313269
/// 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-
318270
void printHelp(raw_ostream &OS, const char *Usage, const char *Title,
319271
unsigned FlagsToInclude, unsigned FlagsToExclude,
320272
bool ShowAllAliases) const;
321273

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;
326276
};
327277

328278
/// Specialization of OptTable
@@ -355,32 +305,31 @@ class PrecomputedOptTable : public OptTable {
355305

356306
} // end namespace llvm
357307

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) \
361311
ID_PREFIX##ID
362312

363313
#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) \
366315
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)
369318

370319
#define LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX( \
371320
ID_PREFIX, PREFIX, PREFIXED_NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, \
372-
FLAGS, VISIBILITY, PARAM, HELPTEXT, METAVAR, VALUES) \
321+
FLAGS, PARAM, HELPTEXT, METAVAR, VALUES) \
373322
llvm::opt::OptTable::Info { \
374323
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 \
377326
}
378327

379328
#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)
385334

386335
#endif // LLVM_OPTION_OPTTABLE_H

llvm/include/llvm/Option/Option.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ enum DriverFlag {
3737
RenderSeparate = (1 << 3)
3838
};
3939

40-
enum DriverVisibility {
41-
Default = (1 << 0),
42-
};
43-
4440
/// Option - Abstract representation for a single form of driver
4541
/// argument.
4642
///
@@ -187,11 +183,6 @@ class Option {
187183
return Info->Flags & Val;
188184
}
189185

190-
/// Test if this option has the visibility flag \a Val.
191-
bool hasVisibilityFlag(unsigned Val) const {
192-
return Info->Visibility & Val;
193-
}
194-
195186
/// getUnaliasedOption - Return the final option this option
196187
/// aliases (itself, if the option has no alias).
197188
const Option getUnaliasedOption() const {

llvm/lib/ExecutionEngine/JITLink/COFFDirectiveParser.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ static constexpr const ArrayRef<StringLiteral>
3636
PrefixTable(PrefixTable_init, std::size(PrefixTable_init) - 1);
3737

3838
// Create table mapping all options defined in COFFOptions.td
39-
using namespace llvm::opt;
4039
static constexpr opt::OptTable::Info infoTable[] = {
4140
#define OPTION(...) \
4241
LLVM_CONSTRUCT_OPT_INFO_WITH_ID_PREFIX(COFF_OPT_, __VA_ARGS__),

0 commit comments

Comments
 (0)