Skip to content

Commit 13a442c

Browse files
committed
Enable -Wformat-pedantic and fix fallout.
Differential Revision: https://reviews.llvm.org/D113172
1 parent c1e7911 commit 13a442c

File tree

12 files changed

+26
-22
lines changed

12 files changed

+26
-22
lines changed

compiler-rt/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ append_list_if(COMPILER_RT_HAS_WGNU_FLAG -Wno-gnu SANITIZER_COMMON_CFLAGS)
443443
append_list_if(COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros SANITIZER_COMMON_CFLAGS)
444444
append_list_if(COMPILER_RT_HAS_WC99_EXTENSIONS_FLAG -Wno-c99-extensions SANITIZER_COMMON_CFLAGS)
445445
# format-pedantic warns about passing T* for %p, which is not useful.
446-
append_list_if(COMPILER_RT_HAS_WNO_FORMAT_PEDANTIC -Wno-format-pedantic SANITIZER_COMMON_CFLAGS)
447446
append_list_if(COMPILER_RT_HAS_WD4146_FLAG /wd4146 SANITIZER_COMMON_CFLAGS)
448447
append_list_if(COMPILER_RT_HAS_WD4291_FLAG /wd4291 SANITIZER_COMMON_CFLAGS)
449448
append_list_if(COMPILER_RT_HAS_WD4391_FLAG /wd4391 SANITIZER_COMMON_CFLAGS)

compiler-rt/lib/asan/asan_errors.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,8 @@ static void PrintLegend(InternalScopedString *str) {
538538
static void PrintShadowBytes(InternalScopedString *str, const char *before,
539539
u8 *bytes, u8 *guilty, uptr n) {
540540
Decorator d;
541-
if (before) str->append("%s%p:", before, bytes);
541+
if (before)
542+
str->append("%s%p:", before, (void *)bytes);
542543
for (uptr i = 0; i < n; i++) {
543544
u8 *p = bytes + i;
544545
const char *before =

compiler-rt/lib/asan/asan_fake_stack.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ FakeStack *FakeStack::Create(uptr stack_size_log) {
5454
: MmapOrDie(size, "FakeStack"));
5555
res->stack_size_log_ = stack_size_log;
5656
u8 *p = reinterpret_cast<u8 *>(res);
57-
VReport(1, "T%d: FakeStack created: %p -- %p stack_size_log: %zd; "
57+
VReport(1,
58+
"T%d: FakeStack created: %p -- %p stack_size_log: %zd; "
5859
"mmapped %zdK, noreserve=%d \n",
59-
GetCurrentTidOrInvalid(), p,
60-
p + FakeStack::RequiredSize(stack_size_log), stack_size_log,
60+
GetCurrentTidOrInvalid(), (void *)p,
61+
(void *)(p + FakeStack::RequiredSize(stack_size_log)), stack_size_log,
6162
size >> 10, flags()->uar_noreserve);
6263
return res;
6364
}

compiler-rt/lib/asan/asan_globals.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ static void ReportGlobal(const Global &g, const char *prefix) {
8989
g.module_name, g.has_dynamic_init, (void *)g.odr_indicator);
9090
if (g.location) {
9191
Report(" location (%p): name=%s[%p], %d %d\n", (void *)g.location,
92-
g.location->filename, g.location->filename, g.location->line_no,
93-
g.location->column_no);
92+
g.location->filename, (void *)g.location->filename,
93+
g.location->line_no, g.location->column_no);
9494
}
9595
}
9696

compiler-rt/lib/cfi/cfi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ ALWAYS_INLINE void CfiSlowPathCommon(u64 CallSiteTypeId, void *Ptr,
359359
return;
360360
}
361361
CFICheckFn cfi_check = sv.get_cfi_check();
362-
VReport(2, "__cfi_check at %p\n", cfi_check);
362+
VReport(2, "__cfi_check at %p\n", (void *)cfi_check);
363363
cfi_check(CallSiteTypeId, Ptr, DiagData);
364364
}
365365

compiler-rt/lib/dfsan/dfsan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ static bool ProtectMemoryRange(uptr beg, uptr size, const char *name) {
916916
// Consider refactoring these into a shared implementation.
917917
bool InitShadow(bool init_origins) {
918918
// Let user know mapping parameters first.
919-
VPrintf(1, "dfsan_init %p\n", &__dfsan::dfsan_init);
919+
VPrintf(1, "dfsan_init %p\n", (void *)&__dfsan::dfsan_init);
920920
for (unsigned i = 0; i < kMemoryLayoutSize; ++i)
921921
VPrintf(1, "%s: %zx - %zx\n", kMemoryLayout[i].name, kMemoryLayout[i].start,
922922
kMemoryLayout[i].end - 1);

compiler-rt/lib/hwasan/hwasan_report.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ static void PrintTagInfoAroundAddr(tag_t *tag_ptr, uptr num_rows,
518518
InternalScopedString s;
519519
for (tag_t *row = beg_row; row < end_row; row += row_len) {
520520
s.append("%s", row == center_row_beg ? "=>" : " ");
521-
s.append("%p:", row);
521+
s.append("%p:", (void *)row);
522522
for (uptr i = 0; i < row_len; i++) {
523523
s.append("%s", row + i == tag_ptr ? "[" : " ");
524524
print_tag(s, &row[i]);

compiler-rt/lib/hwasan/hwasan_thread.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ void Thread::Destroy() {
108108
}
109109

110110
void Thread::Print(const char *Prefix) {
111-
Printf("%sT%zd %p stack: [%p,%p) sz: %zd tls: [%p,%p)\n", Prefix,
112-
unique_id_, this, stack_bottom(), stack_top(),
113-
stack_top() - stack_bottom(),
114-
tls_begin(), tls_end());
111+
Printf("%sT%zd %p stack: [%p,%p) sz: %zd tls: [%p,%p)\n", Prefix, unique_id_,
112+
(void *)this, stack_bottom(), stack_top(),
113+
stack_top() - stack_bottom(), tls_begin(), tls_end());
115114
}
116115

117116
static u32 xorshift(u32 state) {

compiler-rt/lib/memprof/memprof_thread.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void MemprofThread::Init(const InitOptions *options) {
131131
int local = 0;
132132
VReport(1, "T%d: stack [%p,%p) size 0x%zx; local=%p\n", tid(),
133133
(void *)stack_bottom_, (void *)stack_top_, stack_top_ - stack_bottom_,
134-
&local);
134+
(void *)&local);
135135
}
136136

137137
thread_return_t
@@ -198,7 +198,7 @@ MemprofThread *GetCurrentThread() {
198198

199199
void SetCurrentThread(MemprofThread *t) {
200200
CHECK(t->context());
201-
VReport(2, "SetCurrentThread: %p for thread %p\n", t->context(),
201+
VReport(2, "SetCurrentThread: %p for thread %p\n", (void *)t->context(),
202202
(void *)GetThreadSelf());
203203
// Make sure we do not reset the current MemprofThread.
204204
CHECK_EQ(0, TSDGet());

compiler-rt/lib/msan/msan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ void __msan_dump_shadow(const void *x, uptr size) {
515515
}
516516

517517
unsigned char *s = (unsigned char*)MEM_TO_SHADOW(x);
518-
Printf("%p[%p] ", s, x);
518+
Printf("%p[%p] ", (void *)s, x);
519519
for (uptr i = 0; i < size; i++)
520520
Printf("%x%x ", s[i] >> 4, s[i] & 0xf);
521521
Printf("\n");

compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ void RenderFrame(InternalScopedString *buffer, const char *format, int frame_no,
198198
}
199199
break;
200200
default:
201-
Report("Unsupported specifier in stack frame format: %c (%p)!\n", *p, p);
201+
Report("Unsupported specifier in stack frame format: %c (%p)!\n", *p,
202+
(void *)p);
202203
Die();
203204
}
204205
}
@@ -250,7 +251,7 @@ void RenderData(InternalScopedString *buffer, const char *format,
250251
break;
251252
default:
252253
Report("Unsupported specifier in stack frame format: %c (%p)!\n", *p,
253-
p);
254+
(void *)p);
254255
Die();
255256
}
256257
}

compiler-rt/lib/xray/xray_x86_64.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ bool patchFunctionEntry(const bool Enable, const uint32_t FuncId,
148148
int64_t TrampolineOffset = reinterpret_cast<int64_t>(Trampoline) -
149149
(static_cast<int64_t>(Address) + 11);
150150
if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) {
151-
Report("XRay Entry trampoline (%p) too far from sled (%p)\n", Trampoline,
151+
Report("XRay Entry trampoline (%p) too far from sled (%p)\n",
152+
reinterpret_cast<void *>(Trampoline),
152153
reinterpret_cast<void *>(Address));
153154
return false;
154155
}
@@ -195,7 +196,8 @@ bool patchFunctionExit(const bool Enable, const uint32_t FuncId,
195196
(static_cast<int64_t>(Address) + 11);
196197
if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) {
197198
Report("XRay Exit trampoline (%p) too far from sled (%p)\n",
198-
__xray_FunctionExit, reinterpret_cast<void *>(Address));
199+
reinterpret_cast<void *>(__xray_FunctionExit),
200+
reinterpret_cast<void *>(Address));
199201
return false;
200202
}
201203
if (Enable) {
@@ -224,7 +226,8 @@ bool patchFunctionTailExit(const bool Enable, const uint32_t FuncId,
224226
(static_cast<int64_t>(Address) + 11);
225227
if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) {
226228
Report("XRay Tail Exit trampoline (%p) too far from sled (%p)\n",
227-
__xray_FunctionTailExit, reinterpret_cast<void *>(Address));
229+
reinterpret_cast<void *>(__xray_FunctionTailExit),
230+
reinterpret_cast<void *>(Address));
228231
return false;
229232
}
230233
if (Enable) {

0 commit comments

Comments
 (0)