]> granicus.if.org Git - clang/commit
Make -Wformat walk the typedef chain when looking for size_t, etc.
authorHans Wennborg <hans@hanshq.net>
Fri, 27 Jul 2012 19:17:46 +0000 (19:17 +0000)
committerHans Wennborg <hans@hanshq.net>
Fri, 27 Jul 2012 19:17:46 +0000 (19:17 +0000)
commit4684778993c667246039b4664acbce59dc99440c
tree58ef4c76c3fa9b9e318c27634a3eae94cdadd0fb
parente61354b274ec5aa6acf3d15271896ce7596bb123
Make -Wformat walk the typedef chain when looking for size_t, etc.

Clang's -Wformat fix-its currently suggest using "%zu" for values of
type size_t (in C99 or C++11 mode). However, for a type such as
std::vector<T>::size_type, it does not notice that type is actually
typedeffed to size_t, and instead suggests a format for the underlying
type, such as "%lu" or "%u".

This commit makes the format string fix mechanism walk the typedef chain
so that it notices if the type is size_t, even if that isn't "at the
top".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160886 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Analysis/Analyses/FormatString.h
lib/Analysis/FormatString.cpp
lib/Analysis/PrintfFormatString.cpp
lib/Analysis/ScanfFormatString.cpp
test/Sema/format-strings-fixit.c