[PATCH] D43987: Fix ar command line expansion on Windows.
Dmitry Mikulin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 5 10:57:27 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL326734: On Windows expansion of regex file name patterns is the responsibility of each (authored by dmikulin, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D43987?vs=136642&id=137044#toc
Repository:
rL LLVM
https://reviews.llvm.org/D43987
Files:
llvm/trunk/test/tools/llvm-ar/regex-cmd.test
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
Index: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
===================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp
@@ -31,6 +31,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Process.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ToolOutputFile.h"
@@ -869,27 +870,32 @@
Stem.find("lib") != StringRef::npos)
return libDriverMain(makeArrayRef(argv, argc));
- for (int i = 1; i < argc; i++) {
+ SmallVector<const char *, 256> Argv;
+ SpecificBumpPtrAllocator<char> ArgAllocator;
+ failIfError(errorCodeToError(sys::Process::GetArgumentVector(
+ Argv, makeArrayRef(argv, argc), ArgAllocator)));
+
+ for (unsigned i = 1; i < Argv.size(); i++) {
// If an argument starts with a dash and only contains chars
// that belong to the options chars set, remove the dash.
// We can't handle it after the command line options parsing
// is done, since it will error out on an unrecognized string
// starting with a dash.
// Make sure this doesn't match the actual llvm-ar specific options
// that start with a dash.
- StringRef S = argv[i];
+ StringRef S = Argv[i];
if (S.startswith("-") &&
S.find_first_not_of(OptionChars, 1) == StringRef::npos) {
- argv[i]++;
+ Argv[i]++;
break;
}
if (S == "--")
break;
}
// Have the command line options parsed and handle things
// like --help and --version.
- cl::ParseCommandLineOptions(argc, argv,
+ cl::ParseCommandLineOptions(Argv.size(), Argv.data(),
"LLVM Archiver (llvm-ar)\n\n"
" This program archives bitcode files into single libraries\n"
);
Index: llvm/trunk/test/tools/llvm-ar/regex-cmd.test
===================================================================
--- llvm/trunk/test/tools/llvm-ar/regex-cmd.test
+++ llvm/trunk/test/tools/llvm-ar/regex-cmd.test
@@ -0,0 +1,7 @@
+RUN: yaml2obj %S/Inputs/elf.yaml -o %t.o
+
+RUN: rm -f %t.ar
+RUN: llvm-ar crs %t.ar %t.*
+RUN: llvm-ar tv %t.ar | FileCheck %s
+
+CHECK: regex-cmd.test{{.*}}.o
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43987.137044.patch
Type: text/x-patch
Size: 2244 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180305/5f1e11cf/attachment.bin>
More information about the llvm-commits
mailing list