llvm.org GIT mirror llvm / fa6a5de
ArrayRef-ify libDriverMain git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240234 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 4 years ago
4 changed file(s) with 16 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
285285 return MutableArrayRef(data()+N, M);
286286 }
287287
288 MutableArrayRef drop_back(unsigned N) const {
289 assert(this->size() >= N && "Dropping more elements than exist");
290 return slice(0, this->size() - N);
291 }
292
288293 /// @}
289294 /// @name Operator Overloads
290295 /// @{
1414 #ifndef LLVM_LIBDRIVER_LIBDRIVER_H
1515 #define LLVM_LIBDRIVER_LIBDRIVER_H
1616
17 #include "llvm/ADT/ArrayRef.h"
18
1719 namespace llvm {
1820
19 int libDriverMain(int argc, const char **argv);
21 int libDriverMain(llvm::ArrayRef ARgs);
2022
2123 }
2224
102102 return Optional();
103103 }
104104
105 int llvm::libDriverMain(int Argc, const char **Argv) {
106 SmallVector NewArgv(Argv, Argv + Argc);
105 int llvm::libDriverMain(llvm::ArrayRef ArgsArr) {
106 SmallVector NewArgs(ArgsArr.begin(), ArgsArr.end());
107107 BumpPtrAllocator Alloc;
108108 BumpPtrStringSaver Saver(Alloc);
109 cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgv);
110 Argv = &NewArgv[0];
111 Argc = static_cast(NewArgv.size());
109 cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgs);
110 ArgsArr = NewArgs;
112111
113112 LibOptTable Table;
114113 unsigned MissingIndex;
115114 unsigned MissingCount;
116 std::unique_ptr Args(Table.ParseArgs(
117 makeArrayRef(Argv, Argc).slice(1), MissingIndex, MissingCount));
115 std::unique_ptr Args(
116 Table.ParseArgs(ArgsArr.slice(1), MissingIndex, MissingCount));
118117 if (MissingCount) {
119118 llvm::errs() << "missing arg value for \""
120119 << Args->getArgString(MissingIndex)
147146 getOutputPath(Args.get()), Members, /*WriteSymtab=*/true);
148147 if (Result.second) {
149148 if (Result.first.empty())
150 Result.first = Argv[0];
149 Result.first = ArgsArr[0];
151150 llvm::errs() << Result.first << ": " << Result.second.message() << "\n";
152151 return 1;
153152 }
723723 StringRef Stem = sys::path::stem(ToolName);
724724 if (Stem.find("ranlib") == StringRef::npos &&
725725 Stem.find("lib") != StringRef::npos)
726 return libDriverMain(argc, const_cast(argv));
726 return libDriverMain(makeArrayRef(argv, argc));
727727
728728 // Have the command line options parsed and handle things
729729 // like --help and --version.