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.

llvm-svn: 249988
This commit is contained in:
Rui Ueyama 2015-10-11 18:19:01 +00:00
parent 3486fe53dd
commit c6e1b97161
3 changed files with 9 additions and 16 deletions

View File

@ -112,7 +112,7 @@ getString(opt::InputArgList &Args, unsigned Key, StringRef Default = "") {
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) {

View File

@ -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,

View File

@ -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(ArrayRef<const char *> Argv) {
// 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.