C11 standard refers to the unsigned counterpart of the type ptrdiff_t
in the paragraph 7.21.6.1p7 where it defines the format specifier %tu.
In Clang (in PrintfFormatString.cpp, lines 508-510) there is a FIXME for this case,
in particular, right now Clang doesn't diagnose %tu issues at all, i.e.
it doesn't emit any warnings on the code printf("%tu", 3.14).
In this diff we add a method getUnsignedPointerDiffType for getting the corresponding type
similarly to how it's already done in the other analogous cases (size_t, ssize_t, ptrdiff_t etc)
and fix -Wformat diagnostics for %tu plus the emitted fix-it as well.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
The code for printf diagnostics + new tests are supposed to be added by a separate diff.
I think you should combine that diff and this one into a single patch, otherwise this patch is untestable.
include/clang/AST/ASTContext.h | ||
---|---|---|
1492–1493 ↗ | (On Diff #116635) | Wrap the comment, and you might want to refer to C11 7.21.6.1p7 as a justification for why this is needed. |
test/FixIt/format.m | ||
---|---|---|
256 ↗ | (On Diff #116894) | Can you add some positive tests that show "%t" and "%tu" working properly without warnings? |