[PATCH] D155093: [DWARF] Fix undefined behaviour in dwarf type printer
Maurice Heumann via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 12 08:23:37 PDT 2023
momo5502 created this revision.
momo5502 added reviewers: efriedma, DavidSpickett.
Herald added a subscriber: hiraditya.
Herald added a project: All.
momo5502 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The value to be formatted here, `Val`, is an `int64_t` which can not be formatted using `%x`.
This commit adjusts all misuses I was able to find in the llvm-dwarfdump project.
Failing tests in https://reviews.llvm.org/D153800 lead to the discovery and analysis of this issue.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155093
Files:
llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
Index: llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
@@ -424,11 +424,11 @@
OS << (char)Val;
OS << "'";
} else if (Val < 256)
- OS << to_string(llvm::format("'\\x%02x'", Val));
+ OS << to_string(llvm::format("'\\x%02" PRIx64 "'", Val));
else if (Val <= 0xFFFF)
- OS << to_string(llvm::format("'\\u%04x'", Val));
+ OS << to_string(llvm::format("'\\u%04" PRIx64 "'", Val));
else
- OS << to_string(llvm::format("'\\U%08x'", Val));
+ OS << to_string(llvm::format("'\\U%08" PRIx64 "'", Val));
}
}
continue;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155093.539573.patch
Type: text/x-patch
Size: 817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230712/8b0a74d3/attachment.bin>
More information about the llvm-commits
mailing list