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
/// @{
#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);
}
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)
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;
}
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.