Skip to content

Commit 2444b6f

Browse files
authored
[llvm-objcopy] Replace custom -- parsing with DashDashParsing
The custom -- parsing from https://reviews.llvm.org/D102665 can be replaced with the generic feature from https://reviews.llvm.org/D152286 Pull Request: #116565
1 parent 4092c0d commit 2444b6f

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

llvm/tools/llvm-objcopy/ObjcopyOptions.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class ObjcopyOptTable : public opt::GenericOptTable {
5858
public:
5959
ObjcopyOptTable() : opt::GenericOptTable(objcopy_opt::ObjcopyInfoTable) {
6060
setGroupedShortOptions(true);
61+
setDashDashParsing(true);
6162
}
6263
};
6364

@@ -650,17 +651,11 @@ parseChangeSectionAddr(StringRef ArgValue, StringRef OptionName,
650651
// help flag is set then parseObjcopyOptions will print the help messege and
651652
// exit.
652653
Expected<DriverConfig>
653-
objcopy::parseObjcopyOptions(ArrayRef<const char *> RawArgsArr,
654+
objcopy::parseObjcopyOptions(ArrayRef<const char *> ArgsArr,
654655
function_ref<Error(Error)> ErrorCallback) {
655656
DriverConfig DC;
656657
ObjcopyOptTable T;
657658

658-
const char *const *DashDash =
659-
llvm::find_if(RawArgsArr, [](StringRef Str) { return Str == "--"; });
660-
ArrayRef<const char *> ArgsArr = ArrayRef(RawArgsArr.begin(), DashDash);
661-
if (DashDash != RawArgsArr.end())
662-
DashDash = std::next(DashDash);
663-
664659
unsigned MissingArgumentIndex, MissingArgumentCount;
665660
llvm::opt::InputArgList InputArgs =
666661
T.ParseArgs(ArgsArr, MissingArgumentIndex, MissingArgumentCount);
@@ -671,7 +666,7 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> RawArgsArr,
671666
"argument to '%s' is missing (expected %d value(s))",
672667
InputArgs.getArgString(MissingArgumentIndex), MissingArgumentCount);
673668

674-
if (InputArgs.size() == 0 && DashDash == RawArgsArr.end()) {
669+
if (InputArgs.size() == 0) {
675670
printHelp(T, errs(), ToolType::Objcopy);
676671
exit(1);
677672
}
@@ -695,7 +690,6 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> RawArgsArr,
695690

696691
for (auto *Arg : InputArgs.filtered(OBJCOPY_INPUT))
697692
Positional.push_back(Arg->getValue());
698-
std::copy(DashDash, RawArgsArr.end(), std::back_inserter(Positional));
699693

700694
if (Positional.empty())
701695
return createStringError(errc::invalid_argument, "no input file specified");

0 commit comments

Comments
 (0)