[PATCH] D91968: llvm/ADT/StringExtras.h hexDigitValue - Init of integer buffer
Jerker Bäck via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 23 07:41:34 PST 2020
jerker.back created this revision.
Herald added subscribers: llvm-commits, dexonsmith.
Herald added a project: LLVM.
jerker.back requested review of this revision.
Hi,
In the header //`StringExtras.h`//, function //`hexDigitValue`//
due to the expression
LUT[i] = -1U;
my compiler gives me
error C4146: unary minus operator applied to unsigned type, result still unsigned
This is a warning turned into an error by a default compiler switch
The patch gives one solution which I believe also could be more efficient
Thanks
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D91968
Files:
llvm/include/llvm/ADT/StringExtras.h
Index: llvm/include/llvm/ADT/StringExtras.h
===================================================================
--- llvm/include/llvm/ADT/StringExtras.h
+++ llvm/include/llvm/ADT/StringExtras.h
@@ -67,11 +67,8 @@
/// If \p C is not a valid hex digit, -1U is returned.
inline unsigned hexDigitValue(char C) {
struct HexTable {
- unsigned LUT[255] = {};
+ unsigned LUT[255] = {static_cast<unsigned>(-1)};
constexpr HexTable() {
- // Default initialize everything to invalid.
- for (int i = 0; i < 255; ++i)
- LUT[i] = -1U;
// Initialize `0`-`9`.
for (int i = 0; i < 10; ++i)
LUT['0' + i] = i;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91968.307076.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201123/bc351042/attachment.bin>
More information about the llvm-commits
mailing list