mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-09 13:21:30 +00:00
ArrayRef-ify libDriverMain
llvm-svn: 240234
This commit is contained in:
parent
e3a1c91588
commit
fadceb8c9d
@ -286,6 +286,11 @@ namespace llvm {
|
||||
return MutableArrayRef<T>(data()+N, M);
|
||||
}
|
||||
|
||||
MutableArrayRef<T> drop_back(unsigned N) const {
|
||||
assert(this->size() >= N && "Dropping more elements than exist");
|
||||
return slice(0, this->size() - N);
|
||||
}
|
||||
|
||||
/// @}
|
||||
/// @name Operator Overloads
|
||||
/// @{
|
||||
|
@ -15,9 +15,11 @@
|
||||
#ifndef LLVM_LIBDRIVER_LIBDRIVER_H
|
||||
#define LLVM_LIBDRIVER_LIBDRIVER_H
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
int libDriverMain(int argc, const char **argv);
|
||||
int libDriverMain(llvm::ArrayRef<const char*> ARgs);
|
||||
|
||||
}
|
||||
|
||||
|
@ -103,19 +103,18 @@ static Optional<std::string> findInputFile(StringRef File,
|
||||
return Optional<std::string>();
|
||||
}
|
||||
|
||||
int llvm::libDriverMain(int Argc, const char **Argv) {
|
||||
SmallVector<const char *, 20> NewArgv(Argv, Argv + Argc);
|
||||
int llvm::libDriverMain(llvm::ArrayRef<const char*> ArgsArr) {
|
||||
SmallVector<const char *, 20> NewArgs(ArgsArr.begin(), ArgsArr.end());
|
||||
BumpPtrAllocator Alloc;
|
||||
BumpPtrStringSaver Saver(Alloc);
|
||||
cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgv);
|
||||
Argv = &NewArgv[0];
|
||||
Argc = static_cast<int>(NewArgv.size());
|
||||
cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgs);
|
||||
ArgsArr = NewArgs;
|
||||
|
||||
LibOptTable Table;
|
||||
unsigned MissingIndex;
|
||||
unsigned MissingCount;
|
||||
std::unique_ptr<llvm::opt::InputArgList> Args(Table.ParseArgs(
|
||||
makeArrayRef(Argv, Argc).slice(1), MissingIndex, MissingCount));
|
||||
std::unique_ptr<llvm::opt::InputArgList> Args(
|
||||
Table.ParseArgs(ArgsArr.slice(1), MissingIndex, MissingCount));
|
||||
if (MissingCount) {
|
||||
llvm::errs() << "missing arg value for \""
|
||||
<< Args->getArgString(MissingIndex)
|
||||
@ -148,7 +147,7 @@ int llvm::libDriverMain(int Argc, const char **Argv) {
|
||||
getOutputPath(Args.get()), Members, /*WriteSymtab=*/true);
|
||||
if (Result.second) {
|
||||
if (Result.first.empty())
|
||||
Result.first = Argv[0];
|
||||
Result.first = ArgsArr[0];
|
||||
llvm::errs() << Result.first << ": " << Result.second.message() << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
@ -724,7 +724,7 @@ int main(int argc, char **argv) {
|
||||
StringRef Stem = sys::path::stem(ToolName);
|
||||
if (Stem.find("ranlib") == StringRef::npos &&
|
||||
Stem.find("lib") != StringRef::npos)
|
||||
return libDriverMain(argc, const_cast<const char **>(argv));
|
||||
return libDriverMain(makeArrayRef(argv, argc));
|
||||
|
||||
// Have the command line options parsed and handle things
|
||||
// like --help and --version.
|
||||
|
Loading…
Reference in New Issue
Block a user