[clang][Sema] check default argument promotions for printf
authorYingChi Long <me@inclyc.cn>
Fri, 26 Aug 2022 11:26:32 +0000 (19:26 +0800)
committerYingChi Long <me@inclyc.cn>
Thu, 1 Sep 2022 02:10:10 +0000 (10:10 +0800)
commite3bd67eddf65b20956513e91715b1f997dae2690
treea39dc0d846651237f962c2d3472e5d96cfff08b8
parent62454e83b04ff45dc16a37a1f63185b4affc2081
[clang][Sema] check default argument promotions for printf

The main focus of this patch is to make ArgType::matchesType check for
possible default parameter promotions when the argType is not a pointer.
If so, no warning will be given for `int`, `unsigned int` types as
corresponding arguments to %hhd and %hd. However, the usage of %hhd
corresponding to short is relatively rare, and it is more likely to be a
misuse. This patch keeps the original behavior of clang like this as
much as possible, while making it more convenient to consider the
default arguments promotion.

Fixes https://github.com/llvm/llvm-project/issues/57102

Reviewed By: aaron.ballman, nickdesaulniers, #clang-language-wg

Differential Revision: https://reviews.llvm.org/D132568
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/FormatString.h
clang/lib/AST/FormatString.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/format-strings-freebsd.c
clang/test/Sema/format-strings-scanf.c
clang/test/Sema/format-strings.c
clang/www/c_status.html