[llvm] r250901 - [Option] Use an ArrayRef to store the Option Infos in OptTable. NFC

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 09:30:42 PDT 2015


Author: ctopper
Date: Wed Oct 21 11:30:42 2015
New Revision: 250901

URL: http://llvm.org/viewvc/llvm-project?rev=250901&view=rev
Log:
[Option] Use an ArrayRef to store the Option Infos in OptTable. NFC

Modified:
    llvm/trunk/include/llvm/Option/OptTable.h
    llvm/trunk/lib/LibDriver/LibDriver.cpp
    llvm/trunk/lib/Option/OptTable.cpp
    llvm/trunk/unittests/Option/OptionParsingTest.cpp

Modified: llvm/trunk/include/llvm/Option/OptTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/OptTable.h?rev=250901&r1=250900&r2=250901&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Option/OptTable.h (original)
+++ llvm/trunk/include/llvm/Option/OptTable.h Wed Oct 21 11:30:42 2015
@@ -50,8 +50,7 @@ public:
 
 private:
   /// \brief The static option information table.
-  const Info *OptionInfos;
-  unsigned NumOptionInfos;
+  ArrayRef<Info> OptionInfos;
   bool IgnoreCase;
 
   unsigned TheInputOptionID;
@@ -74,14 +73,13 @@ private:
   }
 
 protected:
-  OptTable(const Info *OptionInfos, unsigned NumOptionInfos,
-           bool IgnoreCase = false);
+  OptTable(ArrayRef<Info> OptionInfos, bool IgnoreCase = false);
 
 public:
   ~OptTable();
 
   /// \brief Return the total number of option classes.
-  unsigned getNumOptions() const { return NumOptionInfos; }
+  unsigned getNumOptions() const { return OptionInfos.size(); }
 
   /// \brief Get the given Opt's Option instance, lazily creating it
   /// if necessary.

Modified: llvm/trunk/lib/LibDriver/LibDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LibDriver/LibDriver.cpp?rev=250901&r1=250900&r2=250901&view=diff
==============================================================================
--- llvm/trunk/lib/LibDriver/LibDriver.cpp (original)
+++ llvm/trunk/lib/LibDriver/LibDriver.cpp Wed Oct 21 11:30:42 2015
@@ -51,7 +51,7 @@ static const llvm::opt::OptTable::Info i
 
 class LibOptTable : public llvm::opt::OptTable {
 public:
-  LibOptTable() : OptTable(infoTable, llvm::array_lengthof(infoTable), true) {}
+  LibOptTable() : OptTable(infoTable, true) {}
 };
 
 }

Modified: llvm/trunk/lib/Option/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/OptTable.cpp?rev=250901&r1=250900&r2=250901&view=diff
==============================================================================
--- llvm/trunk/lib/Option/OptTable.cpp (original)
+++ llvm/trunk/lib/Option/OptTable.cpp Wed Oct 21 11:30:42 2015
@@ -84,11 +84,9 @@ static inline bool operator<(const OptTa
 
 OptSpecifier::OptSpecifier(const Option *Opt) : ID(Opt->getID()) {}
 
-OptTable::OptTable(const Info *OptionInfos, unsigned NumOptionInfos,
-                   bool IgnoreCase)
-    : OptionInfos(OptionInfos), NumOptionInfos(NumOptionInfos),
-      IgnoreCase(IgnoreCase), TheInputOptionID(0), TheUnknownOptionID(0),
-      FirstSearchableIndex(0) {
+OptTable::OptTable(ArrayRef<Info> OptionInfos, bool IgnoreCase)
+    : OptionInfos(OptionInfos), IgnoreCase(IgnoreCase), TheInputOptionID(0),
+      TheUnknownOptionID(0), FirstSearchableIndex(0) {
   // Explicitly zero initialize the error to work around a bug in array
   // value-initialization on MinGW with gcc 4.3.5.
 
@@ -199,8 +197,8 @@ Arg *OptTable::ParseOneArg(const ArgList
   if (isInput(PrefixesUnion, Str))
     return new Arg(getOption(TheInputOptionID), Str, Index++, Str);
 
-  const Info *Start = OptionInfos + FirstSearchableIndex;
-  const Info *End = OptionInfos + getNumOptions();
+  const Info *Start = OptionInfos.begin() + FirstSearchableIndex;
+  const Info *End = OptionInfos.end();
   StringRef Name = StringRef(Str).ltrim(PrefixChars);
 
   // Search for the first next option which could be a prefix.

Modified: llvm/trunk/unittests/Option/OptionParsingTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Option/OptionParsingTest.cpp?rev=250901&r1=250900&r2=250901&view=diff
==============================================================================
--- llvm/trunk/unittests/Option/OptionParsingTest.cpp (original)
+++ llvm/trunk/unittests/Option/OptionParsingTest.cpp Wed Oct 21 11:30:42 2015
@@ -48,7 +48,7 @@ namespace {
 class TestOptTable : public OptTable {
 public:
   TestOptTable(bool IgnoreCase = false)
-    : OptTable(InfoTable, array_lengthof(InfoTable), IgnoreCase) {}
+    : OptTable(InfoTable, IgnoreCase) {}
 };
 }
 




More information about the llvm-commits mailing list