[clang-tidy/google-runtime-int] Allow passing non-bitwidth types to printf()-style...
authorBen Hamilton <benhamilton@google.com>
Tue, 1 May 2018 14:48:54 +0000 (14:48 +0000)
committerBen Hamilton <benhamilton@google.com>
Tue, 1 May 2018 14:48:54 +0000 (14:48 +0000)
commit969d63ea8c5820d1325ad27205fc34c4f5030a54
tree7be73f01db63180925c7ab2f17d6174318b79aa2
parentd4fb951ce35315e1a3f5d760195fe23974c5e31f
[clang-tidy/google-runtime-int] Allow passing non-bitwidth types to printf()-style APIs

Summary:
The `google-runtime-int` check currently fires on calls like:

  printf("%lu", (unsigned long)foo);

However, the style guide says:

> Where possible, avoid passing arguments of types specified by
> bitwidth typedefs to printf-based APIs.

http://google.github.io/styleguide/cppguide.html#64-bit_Portability

This diff relaxes the check to not fire on parameters to functions
with the `__format__` attribute. (I didn't specifically check
for `__printf__` since there are a few variations.)

Test Plan: New tests added. Ran tests with:
  % make -j16 check-clang-tools

Reviewers: alexfh, bkramer

Reviewed By: alexfh

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D46293

llvm-svn: 331268
clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
clang-tools-extra/test/clang-tidy/google-runtime-int.cpp