[PATCH] D88065: [lld-macho] Make lld::getInteger() tolerate leading "0x"/"0X" when base is 16
Greg McGary via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 19:34:08 PDT 2020
gkm updated this revision to Diff 293321.
gkm added a comment.
- add a test case
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88065/new/
https://reviews.llvm.org/D88065
Files:
lld/Common/Args.cpp
lld/test/MachO/headerpad.s
Index: lld/test/MachO/headerpad.s
===================================================================
--- lld/test/MachO/headerpad.s
+++ lld/test/MachO/headerpad.s
@@ -32,6 +32,8 @@
# RUN: lld -flavor darwinnew -o %t %t.o -headerpad 11
# RUN: llvm-objdump --macho --all-headers %t | FileCheck %s --check-prefix=PAD11
+# RUN: lld -flavor darwinnew -o %t %t.o -headerpad 0x11
+# RUN: llvm-objdump --macho --all-headers %t | FileCheck %s --check-prefix=PAD11
# PAD11: magic cputype cpusubtype caps filetype ncmds sizeofcmds flags
# PAD11-NEXT: MH_MAGIC_64 X86_64 ALL LIB64 EXECUTE 9 [[#%u, CMDSIZE:]] {{.*}}
# PAD11: sectname __text
Index: lld/Common/Args.cpp
===================================================================
--- lld/Common/Args.cpp
+++ lld/Common/Args.cpp
@@ -33,7 +33,10 @@
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());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88065.293321.patch
Type: text/x-patch
Size: 1162 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200922/88616e34/attachment.bin>
More information about the llvm-commits
mailing list