summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rc/llvm-rc.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2019-01-16 08:09:22 +0000
committerMartin Storsjo <martin@martin.st>2019-01-16 08:09:22 +0000
commit58bb0e47dcd4e0b47a037093382db098bafa528c (patch)
treec9c27627fd0b86606516eb6a2274e8df937bad1c /llvm/tools/llvm-rc/llvm-rc.cpp
parent851aec455bbc3c723b27cadfd06f0dfca60b344a (diff)
downloadbcm5719-llvm-58bb0e47dcd4e0b47a037093382db098bafa528c.tar.gz
bcm5719-llvm-58bb0e47dcd4e0b47a037093382db098bafa528c.zip
[llvm-rc] Support '--' for delimiting options from input paths
This allows avoiding conflicts between paths that begin with the same chars as some llvm-rc options (which can be used with either slashes or dashes). Differential Revision: https://reviews.llvm.org/D56743 llvm-svn: 351305
Diffstat (limited to 'llvm/tools/llvm-rc/llvm-rc.cpp')
-rw-r--r--llvm/tools/llvm-rc/llvm-rc.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp
index 4511c5c3128..54997e900a2 100644
--- a/llvm/tools/llvm-rc/llvm-rc.cpp
+++ b/llvm/tools/llvm-rc/llvm-rc.cpp
@@ -31,6 +31,7 @@
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
#include <system_error>
using namespace llvm;
@@ -85,7 +86,10 @@ int main(int Argc, const char **Argv) {
RcOptTable T;
unsigned MAI, MAC;
- ArrayRef<const char *> ArgsArr = makeArrayRef(Argv + 1, Argc - 1);
+ const char **DashDash = std::find_if(
+ Argv + 1, Argv + Argc, [](StringRef Str) { return Str == "--"; });
+ ArrayRef<const char *> ArgsArr = makeArrayRef(Argv + 1, DashDash);
+
opt::InputArgList InputArgs = T.ParseArgs(ArgsArr, MAI, MAC);
// The tool prints nothing when invoked with no command-line arguments.
@@ -97,6 +101,8 @@ int main(int Argc, const char **Argv) {
const bool BeVerbose = InputArgs.hasArg(OPT_VERBOSE);
std::vector<std::string> InArgsInfo = InputArgs.getAllArgValues(OPT_INPUT);
+ if (DashDash != Argv + Argc)
+ InArgsInfo.insert(InArgsInfo.end(), DashDash + 1, Argv + Argc);
if (InArgsInfo.size() != 1) {
fatalError("Exactly one input file should be provided.");
}
OpenPOWER on IntegriCloud