[lld] r249988 - ELF2: Remove ArgParser class and define parseArgs() function instead.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 11 11:19:02 PDT 2015


Author: ruiu
Date: Sun Oct 11 13:19:01 2015
New Revision: 249988

URL: http://llvm.org/viewvc/llvm-project?rev=249988&view=rev
Log:
ELF2: Remove ArgParser class and define parseArgs() function instead.

ArgParser was a class with only one member function, so it didn't
have to be a class.

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/Driver.h
    lld/trunk/ELF/DriverUtils.cpp

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=249988&r1=249987&r2=249988&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Sun Oct 11 13:19:01 2015
@@ -112,7 +112,7 @@ getString(opt::InputArgList &Args, unsig
 void LinkerDriver::main(ArrayRef<const char *> ArgsArr) {
   initSymbols();
 
-  opt::InputArgList Args = ArgParser(&Alloc).parse(ArgsArr);
+  opt::InputArgList Args = parseArgs(&Alloc, ArgsArr);
   createFiles(Args);
 
   switch (Config->ElfKind) {

Modified: lld/trunk/ELF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=249988&r1=249987&r2=249988&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.h (original)
+++ lld/trunk/ELF/Driver.h Sun Oct 11 13:19:01 2015
@@ -14,7 +14,6 @@
 #include "lld/Core/LLVM.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Option/ArgList.h"
-#include "llvm/Support/StringSaver.h"
 
 namespace lld {
 namespace elf2 {
@@ -24,17 +23,6 @@ extern class LinkerDriver *Driver;
 // Entry point of the ELF linker.
 void link(ArrayRef<const char *> Args);
 
-class ArgParser {
-public:
-  ArgParser(llvm::BumpPtrAllocator *A);
-
-  // Parses command line options.
-  llvm::opt::InputArgList parse(ArrayRef<const char *> Args);
-
-private:
-  llvm::StringSaver Saver;
-};
-
 class LinkerDriver {
 public:
   void main(ArrayRef<const char *> Args);
@@ -54,6 +42,10 @@ private:
   std::vector<std::unique_ptr<MemoryBuffer>> OwningMBs;
 };
 
+// Parses command line options.
+llvm::opt::InputArgList parseArgs(llvm::BumpPtrAllocator *A,
+                                  ArrayRef<const char *> Args);
+
 // Create enum with OPT_xxx values for each option in Options.td
 enum {
   OPT_INVALID = 0,

Modified: lld/trunk/ELF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/DriverUtils.cpp?rev=249988&r1=249987&r2=249988&view=diff
==============================================================================
--- lld/trunk/ELF/DriverUtils.cpp (original)
+++ lld/trunk/ELF/DriverUtils.cpp Sun Oct 11 13:19:01 2015
@@ -19,6 +19,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/StringSaver.h"
 
 using namespace llvm;
 
@@ -49,10 +50,9 @@ public:
   ELFOptTable() : OptTable(infoTable, array_lengthof(infoTable)) {}
 };
 
-ArgParser::ArgParser(BumpPtrAllocator *A) : Saver(*A) {}
-
 // Parses a given list of options.
-opt::InputArgList ArgParser::parse(ArrayRef<const char *> Argv) {
+opt::InputArgList lld::elf2::parseArgs(llvm::BumpPtrAllocator *A,
+                                       ArrayRef<const char *> Argv) {
   // Make InputArgList from string vectors.
   ELFOptTable Table;
   unsigned MissingIndex;
@@ -60,6 +60,7 @@ opt::InputArgList ArgParser::parse(Array
 
   // Expand response files. '@<filename>' is replaced by the file's contents.
   SmallVector<const char *, 256> Vec(Argv.data(), Argv.data() + Argv.size());
+  StringSaver Saver(*A);
   llvm::cl::ExpandResponseFiles(Saver, llvm::cl::TokenizeGNUCommandLine, Vec);
 
   // Parse options and then do error checking.




More information about the llvm-commits mailing list