This is an archive of the discontinued LLVM Phabricator instance.

Enable -Wformat-pedantic and fix fallout.
ClosedPublic

Authored by marxin on Nov 4 2021, 1:01 AM.

Diff Detail

Event Timeline

marxin created this revision.Nov 4 2021, 1:01 AM
marxin requested review of this revision.Nov 4 2021, 1:01 AM
vitalybuka accepted this revision.Nov 4 2021, 11:38 AM
vitalybuka added inline comments.
compiler-rt/lib/xray/xray_x86_64.cpp
154

looks like xray prefers reinterpret_cast, can you fix this?

This revision is now accepted and ready to land.Nov 4 2021, 11:38 AM

LGTM. Thank you!

marxin marked an inline comment as done.Nov 5 2021, 5:11 AM
marxin added inline comments.
compiler-rt/lib/xray/xray_x86_64.cpp
154

Sure.

marxin updated this revision to Diff 385038.Nov 5 2021, 5:11 AM
marxin marked an inline comment as done.
This revision was landed with ongoing or failed builds.Nov 5 2021, 5:12 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptNov 5 2021, 5:12 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript

Hi,

Does this warn about anything other than passing T* for %p? Is this warning ever useful? I would say printf accepts any type T* for %p. It prints them perfectly well.
TSan runtime with DPrintf enabled is not clean.
Adding casts for all these cases is lots of verbosity (we prefer C++ casts now I think). And I don't see any particular value we will get for all that additional verbosity...

[543/1320] Building CXX object projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan-x86_64.dir/rtl/tsan_fd.cpp.o
compiler-rt/lib/tsan/rtl/tsan_fd.cpp:165:55: warning: format specifies type 'void *' but the argument has type '__tsan::FdSync *' [-Wformat-pedantic]
  DPrintf("#%d: FdAcquire(%d) -> %p\n", thr->tid, fd, s);
                                 ~~                   ^
compiler-rt/lib/tsan/rtl/tsan_fd.cpp:176:55: warning: format specifies type 'void *' but the argument has type '__tsan::FdSync *' [-Wformat-pedantic]
  DPrintf("#%d: FdRelease(%d) -> %p\n", thr->tid, fd, s);
                                 ~~                   ^
2 warnings generated.
[547/1320] Linking CXX shared library lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.so
/usr/bin/ld: warning: -z gnu-version-script-compat ignored
[578/1320] Building CXX object projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan-x86_64.dir/rtl/tsan_rtl.cpp.o
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:84:59: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
      DPrintf("#%d: TracePartAlloc: part=%p\n", thr->tid, part);
                                         ~~               ^~~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:818:11: warning: format specifies type 'void *' but the argument has type '__tsan::Trace *' [-Wformat-pedantic]
          trace, trace->parts.Front(), part, pos);
          ^~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:818:18: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
          trace, trace->parts.Front(), part, pos);
                 ^~~~~~~~~~~~~~~~~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:818:40: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
          trace, trace->parts.Front(), part, pos);
                                       ^~~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:818:46: warning: format specifies type 'void *' but the argument has type '__tsan::Event *' [-Wformat-pedantic]
          trace, trace->parts.Front(), part, pos);
                                             ^~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:913:11: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
          trace->parts.Front(), trace->parts.Back(),
          ^~~~~~~~~~~~~~~~~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:913:33: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
          trace->parts.Front(), trace->parts.Back(),
                                ^~~~~~~~~~~~~~~~~~~
7 warnings generated.
[579/1320] Building CXX object projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan-dynamic-x86_64.dir/rtl/tsan_fd.cpp.o
compiler-rt/lib/tsan/rtl/tsan_fd.cpp:165:55: warning: format specifies type 'void *' but the argument has type '__tsan::FdSync *' [-Wformat-pedantic]
  DPrintf("#%d: FdAcquire(%d) -> %p\n", thr->tid, fd, s);
                                 ~~                   ^
compiler-rt/lib/tsan/rtl/tsan_fd.cpp:176:55: warning: format specifies type 'void *' but the argument has type '__tsan::FdSync *' [-Wformat-pedantic]
  DPrintf("#%d: FdRelease(%d) -> %p\n", thr->tid, fd, s);
                                 ~~                   ^
2 warnings generated.
[582/1320] Building CXX object projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan-x86_64.dir/rtl/tsan_rtl_report.cpp.o
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp:468:71: warning: format specifies type 'void *' but the argument has type '__tsan::Trace *' [-Wformat-pedantic]
      DPrintf2("RestoreStack: tid=%d trace=%p no trace parts\n", tid, trace);
                                           ~~                         ^~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp:484:12: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
           trace->parts.Front(), last_part, last_pos);
           ^~~~~~~~~~~~~~~~~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp:484:34: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
           trace->parts.Front(), last_part, last_pos);
                                 ^~~~~~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp:484:45: warning: format specifies type 'void *' but the argument has type '__tsan::Event *' [-Wformat-pedantic]
           trace->parts.Front(), last_part, last_pos);
                                            ^~~~~~~~
4 warnings generated.
[610/1320] Building CXX object projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan-dynamic-x86_64.dir/rtl/tsan_rtl.cpp.o
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:84:59: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
      DPrintf("#%d: TracePartAlloc: part=%p\n", thr->tid, part);
                                         ~~               ^~~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:818:11: warning: format specifies type 'void *' but the argument has type '__tsan::Trace *' [-Wformat-pedantic]
          trace, trace->parts.Front(), part, pos);
          ^~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:818:18: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
          trace, trace->parts.Front(), part, pos);
                 ^~~~~~~~~~~~~~~~~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:818:40: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
          trace, trace->parts.Front(), part, pos);
                                       ^~~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:818:46: warning: format specifies type 'void *' but the argument has type '__tsan::Event *' [-Wformat-pedantic]
          trace, trace->parts.Front(), part, pos);
                                             ^~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:913:11: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
          trace->parts.Front(), trace->parts.Back(),
          ^~~~~~~~~~~~~~~~~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp:913:33: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
          trace->parts.Front(), trace->parts.Back(),
                                ^~~~~~~~~~~~~~~~~~~
7 warnings generated.
[615/1320] Building CXX object projects/compiler-rt/lib/tsan/CMakeFiles/clang_rt.tsan-dynamic-x86_64.dir/rtl/tsan_rtl_report.cpp.o
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp:468:71: warning: format specifies type 'void *' but the argument has type '__tsan::Trace *' [-Wformat-pedantic]
      DPrintf2("RestoreStack: tid=%d trace=%p no trace parts\n", tid, trace);
                                           ~~                         ^~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp:484:12: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
           trace->parts.Front(), last_part, last_pos);
           ^~~~~~~~~~~~~~~~~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp:484:34: warning: format specifies type 'void *' but the argument has type '__tsan::TracePart *' [-Wformat-pedantic]
           trace->parts.Front(), last_part, last_pos);
                                 ^~~~~~~~~
compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp:484:45: warning: format specifies type 'void *' but the argument has type '__tsan::Event *' [-Wformat-pedantic]
           trace->parts.Front(), last_part, last_pos);
                                            ^~~~~~~~