aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Option/OptTable.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2021-09-27 11:04:07 -0400
committerNico Weber <thakis@chromium.org>2021-09-27 11:05:02 -0400
commit2f955424c4a7c89c8ca1615bc40a7aa4739d3c7b (patch)
tree2dacf3e9bc6c639f19fd2f7432ecf679f520f39c /llvm/lib/Option/OptTable.cpp
parent21429cf43a41d4ff1263dd601d5e5f81a6387cd0 (diff)
downloadllvm-2f955424c4a7c89c8ca1615bc40a7aa4739d3c7b.zip
llvm-2f955424c4a7c89c8ca1615bc40a7aa4739d3c7b.tar.gz
llvm-2f955424c4a7c89c8ca1615bc40a7aa4739d3c7b.tar.bz2
[llvm] ConvertOption::accept(), acceptInternal() to std::unique_ptr<>
These functions transfer ownership to the caller. Make this clear in the type system. No behavior change.
Diffstat (limited to 'llvm/lib/Option/OptTable.cpp')
-rw-r--r--llvm/lib/Option/OptTable.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp
index 1bf63a7..b319800 100644
--- a/llvm/lib/Option/OptTable.cpp
+++ b/llvm/lib/Option/OptTable.cpp
@@ -359,9 +359,9 @@ Arg *OptTable::parseOneArgGrouped(InputArgList &Args, unsigned &Index) const {
continue;
Option Opt(Start, this);
- if (Arg *A = Opt.accept(Args, StringRef(Args.getArgString(Index), ArgSize),
- false, Index))
- return A;
+ if (std::unique_ptr<Arg> A = Opt.accept(
+ Args, StringRef(Args.getArgString(Index), ArgSize), false, Index))
+ return A.release();
// If Opt is a Flag of length 2 (e.g. "-a"), we know it is a prefix of
// the current argument (e.g. "-abc"). Match it as a fallback if no longer
@@ -379,9 +379,10 @@ Arg *OptTable::parseOneArgGrouped(InputArgList &Args, unsigned &Index) const {
if (Str[2] == '=')
return new Arg(getOption(TheUnknownOptionID), Str, Index++, CStr);
- if (Arg *A = Opt.accept(Args, Str.substr(0, 2), true, Index)) {
+ if (std::unique_ptr<Arg> A =
+ Opt.accept(Args, Str.substr(0, 2), true, Index)) {
Args.replaceArgString(Index, Twine('-') + Str.substr(2));
- return A;
+ return A.release();
}
}
@@ -439,9 +440,9 @@ Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index,
continue;
// See if this option matches.
- if (Arg *A = Opt.accept(Args, StringRef(Args.getArgString(Index), ArgSize),
- false, Index))
- return A;
+ if (std::unique_ptr<Arg> A = Opt.accept(
+ Args, StringRef(Args.getArgString(Index), ArgSize), false, Index))
+ return A.release();
// Otherwise, see if this argument was missing values.
if (Prev != Index)