[llvm] d3c304f - [DWARF] Fix undefined behaviour in dwarf type printer
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 14 12:54:31 PDT 2023
Author: Maurice Heumann
Date: 2023-07-14T12:54:18-07:00
New Revision: d3c304fd637f1e1d9e311066a299839ace1c9344
URL: https://github.com/llvm/llvm-project/commit/d3c304fd637f1e1d9e311066a299839ace1c9344
DIFF: https://github.com/llvm/llvm-project/commit/d3c304fd637f1e1d9e311066a299839ace1c9344.diff
LOG: [DWARF] Fix undefined behaviour in dwarf type printer
The value to be formatted here, Val, is an int64_t which cannot 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.
Differential Revision: https://reviews.llvm.org/D155093
Added:
Modified:
llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp b/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
index 6a1423d37d9f27..c474de60762653 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
@@ -424,11 +424,11 @@ bool DWARFTypePrinter::appendTemplateParameters(DWARFDie D,
OS << (char)Val;
OS << "'";
} else if (Val < 256)
- OS << to_string(llvm::format("'\\x%02x'", Val));
+ OS << llvm::format("'\\x%02" PRIx64 "'", Val);
else if (Val <= 0xFFFF)
- OS << to_string(llvm::format("'\\u%04x'", Val));
+ OS << llvm::format("'\\u%04" PRIx64 "'", Val);
else
- OS << to_string(llvm::format("'\\U%08x'", Val));
+ OS << llvm::format("'\\U%08" PRIx64 "'", Val);
}
}
continue;
More information about the llvm-commits
mailing list