[compiler-rt] d26d5a0 - msan: clean up and enable format string checking
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 13 04:45:07 PDT 2021
Author: Dmitry Vyukov
Date: 2021-08-13T13:45:02+02:00
New Revision: d26d5a0a3dcaea5ef7b17073c3a4d436b29c2866
URL: https://github.com/llvm/llvm-project/commit/d26d5a0a3dcaea5ef7b17073c3a4d436b29c2866
DIFF: https://github.com/llvm/llvm-project/commit/d26d5a0a3dcaea5ef7b17073c3a4d436b29c2866.diff
LOG: msan: clean up and enable format string checking
Depends on D107981.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D107982
Added:
Modified:
compiler-rt/lib/msan/CMakeLists.txt
compiler-rt/lib/msan/msan.cpp
compiler-rt/lib/msan/msan_linux.cpp
compiler-rt/lib/msan/msan_report.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/msan/CMakeLists.txt b/compiler-rt/lib/msan/CMakeLists.txt
index d6523d412aff3..b115f68db3e2f 100644
--- a/compiler-rt/lib/msan/CMakeLists.txt
+++ b/compiler-rt/lib/msan/CMakeLists.txt
@@ -40,9 +40,6 @@ endif()
# Prevent clang from generating libc calls.
append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding MSAN_RTL_CFLAGS)
-# Too many existing bugs, needs cleanup.
-append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format MSAN_RTL_CFLAGS)
-
set(MSAN_RUNTIME_LIBRARIES)
# Static runtime library.
diff --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp
index 4fa772fdcb6e4..3c1ae17c7bb34 100644
--- a/compiler-rt/lib/msan/msan.cpp
+++ b/compiler-rt/lib/msan/msan.cpp
@@ -604,7 +604,7 @@ void __msan_set_alloca_origin4(void *a, uptr size, char *descr, uptr pc) {
id = Origin::CreateStackOrigin(idx).raw_id();
*id_ptr = id;
if (print)
- Printf("First time: idx=%d id=%d %s %p \n", idx, id, descr + 4, pc);
+ Printf("First time: idx=%d id=%d %s 0x%zx \n", idx, id, descr + 4, pc);
}
if (print)
Printf("__msan_set_alloca_origin: descr=%s id=%x\n", descr + 4, id);
diff --git a/compiler-rt/lib/msan/msan_linux.cpp b/compiler-rt/lib/msan/msan_linux.cpp
index d5baee38e7102..c27e66661d222 100644
--- a/compiler-rt/lib/msan/msan_linux.cpp
+++ b/compiler-rt/lib/msan/msan_linux.cpp
@@ -37,7 +37,7 @@ namespace __msan {
void ReportMapRange(const char *descr, uptr beg, uptr size) {
if (size > 0) {
uptr end = beg + size - 1;
- VPrintf(1, "%s : %p - %p\n", descr, beg, end);
+ VPrintf(1, "%s : 0x%zx - 0x%zx\n", descr, beg, end);
}
}
@@ -45,7 +45,7 @@ static bool CheckMemoryRangeAvailability(uptr beg, uptr size) {
if (size > 0) {
uptr end = beg + size - 1;
if (!MemoryRangeIsAvailable(beg, end)) {
- Printf("FATAL: Memory range %p - %p is not available.\n", beg, end);
+ Printf("FATAL: Memory range 0x%zx - 0x%zx is not available.\n", beg, end);
return false;
}
}
@@ -65,8 +65,8 @@ static bool ProtectMemoryRange(uptr beg, uptr size, const char *name) {
}
if ((uptr)addr != beg) {
uptr end = beg + size - 1;
- Printf("FATAL: Cannot protect memory range %p - %p (%s).\n", beg, end,
- name);
+ Printf("FATAL: Cannot protect memory range 0x%zx - 0x%zx (%s).\n", beg,
+ end, name);
return false;
}
}
@@ -115,7 +115,7 @@ bool InitShadow(bool init_origins) {
if (!MEM_IS_APP(&__msan_init)) {
Printf("FATAL: Code %p is out of application range. Non-PIE build?\n",
- (uptr)&__msan_init);
+ &__msan_init);
return false;
}
diff --git a/compiler-rt/lib/msan/msan_report.cpp b/compiler-rt/lib/msan/msan_report.cpp
index e10d9eb622314..ea8608e569e79 100644
--- a/compiler-rt/lib/msan/msan_report.cpp
+++ b/compiler-rt/lib/msan/msan_report.cpp
@@ -201,13 +201,15 @@ void DescribeMemoryRange(const void *x, uptr size) {
Decorator d;
Printf("%s", d.Warning());
- Printf("Shadow map of [%p, %p), %zu bytes:\n", start, end, end - start);
+ Printf("Shadow map of [%p, %p), %zu bytes:\n",
+ reinterpret_cast<void *>(start), reinterpret_cast<void *>(end),
+ end - start);
Printf("%s", d.Default());
while (s < e) {
// Line start.
if (pos % 16 == 0) {
for (int i = 0; i < 4; ++i) origin_ids[i] = -1;
- Printf("%p:", s);
+ Printf("%p:", reinterpret_cast<void *>(s));
}
// Group start.
if (pos % 4 == 0) {
More information about the llvm-commits
mailing list