summaryrefslogtreecommitdiff
path: root/lld/Common
diff options
context:
space:
mode:
authorGreg McGary <gkm@fb.com>2020-09-21 19:02:12 -0700
committerGreg McGary <gkm@fb.com>2020-09-22 08:56:20 -0700
commit703d3f25976c98bcf0e4717087c5a51b92c5f51a (patch)
tree286c770dc71a67fb23c95455d25a8fd3870c6753 /lld/Common
parentbd31abc1d0f17536fcd85f4dfcc79d37834aac20 (diff)
downloadllvm-703d3f25976c98bcf0e4717087c5a51b92c5f51a.tar.gz
[lld-macho] Make lld::getInteger() tolerate leading "0x"/"0X" when base is 16
ld64 is cool with leading `0x` for hex command-line args, and we should be also. Reviewed By: #lld-macho, int3 Differential Revision: https://reviews.llvm.org/D88065
Diffstat (limited to 'lld/Common')
-rw-r--r--lld/Common/Args.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lld/Common/Args.cpp b/lld/Common/Args.cpp
index 507830f9da34..afc57822c5c3 100644
--- a/lld/Common/Args.cpp
+++ b/lld/Common/Args.cpp
@@ -33,7 +33,10 @@ static int64_t getInteger(opt::InputArgList &args, unsigned key,
return Default;
int64_t v;
- if (to_integer(a->getValue(), v, base))
+ StringRef s = a->getValue();
+ if (base == 16 && (s.startswith("0x") || s.startswith("0X")))
+ s = s.drop_front(2);
+ if (to_integer(s, v, base))
return v;
StringRef spelling = args.getArgString(a->getIndex());