llvm.org GIT mirror llvm / 94f8b07
[Option] Use an ArrayRef to store the Option Infos in OptTable. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250901 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 3 years ago
4 changed file(s) with 10 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
4949
5050 private:
5151 /// \brief The static option information table.
52 const Info *OptionInfos;
53 unsigned NumOptionInfos;
52 ArrayRef OptionInfos;
5453 bool IgnoreCase;
5554
5655 unsigned TheInputOptionID;
7372 }
7473
7574 protected:
76 OptTable(const Info *OptionInfos, unsigned NumOptionInfos,
77 bool IgnoreCase = false);
75 OptTable(ArrayRef OptionInfos, bool IgnoreCase = false);
7876
7977 public:
8078 ~OptTable();
8179
8280 /// \brief Return the total number of option classes.
83 unsigned getNumOptions() const { return NumOptionInfos; }
81 unsigned getNumOptions() const { return OptionInfos.size(); }
8482
8583 /// \brief Get the given Opt's Option instance, lazily creating it
8684 /// if necessary.
5050
5151 class LibOptTable : public llvm::opt::OptTable {
5252 public:
53 LibOptTable() : OptTable(infoTable, llvm::array_lengthof(infoTable), true) {}
53 LibOptTable() : OptTable(infoTable, true) {}
5454 };
5555
5656 }
8383
8484 OptSpecifier::OptSpecifier(const Option *Opt) : ID(Opt->getID()) {}
8585
86 OptTable::OptTable(const Info *OptionInfos, unsigned NumOptionInfos,
87 bool IgnoreCase)
88 : OptionInfos(OptionInfos), NumOptionInfos(NumOptionInfos),
89 IgnoreCase(IgnoreCase), TheInputOptionID(0), TheUnknownOptionID(0),
90 FirstSearchableIndex(0) {
86 OptTable::OptTable(ArrayRef OptionInfos, bool IgnoreCase)
87 : OptionInfos(OptionInfos), IgnoreCase(IgnoreCase), TheInputOptionID(0),
88 TheUnknownOptionID(0), FirstSearchableIndex(0) {
9189 // Explicitly zero initialize the error to work around a bug in array
9290 // value-initialization on MinGW with gcc 4.3.5.
9391
198196 if (isInput(PrefixesUnion, Str))
199197 return new Arg(getOption(TheInputOptionID), Str, Index++, Str);
200198
201 const Info *Start = OptionInfos + FirstSearchableIndex;
202 const Info *End = OptionInfos + getNumOptions();
199 const Info *Start = OptionInfos.begin() + FirstSearchableIndex;
200 const Info *End = OptionInfos.end();
203201 StringRef Name = StringRef(Str).ltrim(PrefixChars);
204202
205203 // Search for the first next option which could be a prefix.
4747 class TestOptTable : public OptTable {
4848 public:
4949 TestOptTable(bool IgnoreCase = false)
50 : OptTable(InfoTable, array_lengthof(InfoTable), IgnoreCase) {}
50 : OptTable(InfoTable, IgnoreCase) {}
5151 };
5252 }
5353