const Option OptTable::getOption(OptSpecifier Opt) const { unsigned id = Opt.getID(); if (id == 0) return Option(nullptr, nullptr); assert((unsigned) (id - 1) < getNumOptions() && "Invalid ID."); return Option(&getInfo(id), this); }
void ArgList::eraseArg(OptSpecifier Id) { // Zero out the removed entries but keep them around so that we don't // need to invalidate OptRanges. for (Arg *const &A : filtered(Id)) { // Avoid the need for a non-const filtered iterator variant. Arg **ArgsBegin = Args.data(); ArgsBegin[&A - ArgsBegin] = nullptr; } OptRanges.erase(Id.getID()); }
bool Option::matches(OptSpecifier Opt) const { // Aliases are never considered in matching, look through them. const Option Alias = getAlias(); if (Alias.isValid()) return Alias.matches(Opt); // Check exact match. if (getID() == Opt.getID()) return true; const Option Group = getGroup(); if (Group.isValid()) return Group.matches(Opt); return false; }
Option::Option(OptionClass _Kind, OptSpecifier _ID, const char *_Name, const OptionGroup *_Group, const Option *_Alias) : Kind(_Kind), ID(_ID.getID()), Name(_Name), Group(_Group), Alias(_Alias), Unsupported(false), LinkerInput(false), NoOptAsInput(false), DriverOption(false), NoArgumentUnused(false), NoForward(false) { // Multi-level aliases are not supported, and alias options cannot // have groups. This just simplifies option tracking, it is not an // inherent limitation. assert((!Alias || (!Alias->Alias && !Group)) && "Multi-level aliases and aliases with groups are unsupported."); // Initialize rendering options based on the class. switch (Kind) { case GroupClass: case InputClass: case UnknownClass: RenderStyle = RenderValuesStyle; break; case JoinedClass: case JoinedAndSeparateClass: RenderStyle = RenderJoinedStyle; break; case CommaJoinedClass: RenderStyle = RenderCommaJoinedStyle; break; case FlagClass: case SeparateClass: case MultiArgClass: case JoinedOrSeparateClass: RenderStyle = RenderSeparateStyle; break; } }