summaryrefslogtreecommitdiff
path: root/lld/Common
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2018-05-22 02:53:11 +0000
committerRui Ueyama <ruiu@google.com>2018-05-22 02:53:11 +0000
commit7ef67c5e2e896e76d90443a38741be9f30cfd26c (patch)
tree325b19137c78fdc2f0538f430e72ad8a9c8f16c1 /lld/Common
parentaed63b7c227a5cf324bc850c9b0765eaeadb927f (diff)
Handle --plugin-opt= options as alias options.
Previously, we had a loop to iterate over options starting with `--plugin-opt=` and parse them by hand. But we can make OptTable do that job for us. Differential Revision: https://reviews.llvm.org/D47167
Diffstat (limited to 'lld/Common')
-rw-r--r--lld/Common/Args.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/lld/Common/Args.cpp b/lld/Common/Args.cpp
index 680cf5bd0a6..ff77bfcc3b7 100644
--- a/lld/Common/Args.cpp
+++ b/lld/Common/Args.cpp
@@ -18,13 +18,17 @@ using namespace llvm;
using namespace lld;
int lld::args::getInteger(opt::InputArgList &Args, unsigned Key, int Default) {
- int V = Default;
- if (auto *Arg = Args.getLastArg(Key)) {
- StringRef S = Arg->getValue();
- if (!to_integer(S, V, 10))
- error(Arg->getSpelling() + ": number expected, but got '" + S + "'");
- }
- return V;
+ auto *A = Args.getLastArg(Key);
+ if (!A)
+ return Default;
+
+ int V;
+ if (to_integer(A->getValue(), V, 10))
+ return V;
+
+ StringRef Spelling = Args.getArgString(A->getIndex());
+ error(Spelling + ": number expected, but got '" + A->getValue() + "'");
+ return 0;
}
std::vector<StringRef> lld::args::getStrings(opt::InputArgList &Args, int Id) {