aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/lld/Common/Args.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/lld/Common/Args.cpp')
-rw-r--r--contrib/llvm-project/lld/Common/Args.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/contrib/llvm-project/lld/Common/Args.cpp b/contrib/llvm-project/lld/Common/Args.cpp
index 4ea3a435c7ae..afc57822c5c3 100644
--- a/contrib/llvm-project/lld/Common/Args.cpp
+++ b/contrib/llvm-project/lld/Common/Args.cpp
@@ -26,14 +26,17 @@ CodeGenOpt::Level lld::args::getCGOptLevel(int optLevelLTO) {
return CodeGenOpt::Default;
}
-int64_t lld::args::getInteger(opt::InputArgList &args, unsigned key,
- int64_t Default) {
+static int64_t getInteger(opt::InputArgList &args, unsigned key,
+ int64_t Default, unsigned base) {
auto *a = args.getLastArg(key);
if (!a)
return Default;
int64_t v;
- if (to_integer(a->getValue(), v, 10))
+ 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());
@@ -41,6 +44,16 @@ int64_t lld::args::getInteger(opt::InputArgList &args, unsigned key,
return 0;
}
+int64_t lld::args::getInteger(opt::InputArgList &args, unsigned key,
+ int64_t Default) {
+ return ::getInteger(args, key, Default, 10);
+}
+
+int64_t lld::args::getHex(opt::InputArgList &args, unsigned key,
+ int64_t Default) {
+ return ::getInteger(args, key, Default, 16);
+}
+
std::vector<StringRef> lld::args::getStrings(opt::InputArgList &args, int id) {
std::vector<StringRef> v;
for (auto *arg : args.filtered(id))