From 7fa27ce4a07f19b07799a767fc29416f3b625afb Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 26 Jul 2023 21:03:47 +0200 Subject: Vendor import of llvm-project main llvmorg-17-init-19304-gd0b54bb50e51, the last commit before the upstream release/17.x branch was created. --- llvm/lib/Option/OptTable.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Option/OptTable.cpp') diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp index 2e289c58b45a..3f53ac119c69 100644 --- a/llvm/lib/Option/OptTable.cpp +++ b/llvm/lib/Option/OptTable.cpp @@ -163,7 +163,7 @@ static unsigned matchOption(const OptTable::Info *I, StringRef Str, for (auto Prefix : I->Prefixes) { if (Str.startswith(Prefix)) { StringRef Rest = Str.substr(Prefix.size()); - bool Matched = IgnoreCase ? Rest.startswith_insensitive(I->Name) + bool Matched = IgnoreCase ? Rest.starts_with_insensitive(I->Name) : Rest.startswith(I->Name); if (Matched) return Prefix.size() + StringRef(I->Name).size(); @@ -468,6 +468,16 @@ InputArgList OptTable::ParseArgs(ArrayRef ArgArr, continue; } + // In DashDashParsing mode, the first "--" stops option scanning and treats + // all subsequent arguments as positional. + if (DashDashParsing && Str == "--") { + while (++Index < End) { + Args.append(new Arg(getOption(InputOptionID), Str, Index, + Args.getArgString(Index))); + } + break; + } + unsigned Prev = Index; std::unique_ptr A = GroupedShortOptions ? parseOneArgGrouped(Args, Index) -- cgit v1.3