[clang-tidy] google-runtime-int: made the matcher more restricting, added a test for a false positive

This should be NFC.

llvm-svn: 247806
This commit is contained in:
Alexander Kornienko 2015-09-16 15:08:46 +00:00
parent 5ef13dc8bd
commit 4d48e1e85b
2 changed files with 9 additions and 1 deletions

View File

@ -36,7 +36,7 @@ void IntegerTypesCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
void IntegerTypesCheck::registerMatchers(MatchFinder *Finder) {
// Find all TypeLocs. The relevant Style Guide rule only applies to C++.
if (getLangOpts().CPlusPlus)
Finder->addMatcher(typeLoc().bind("tl"), this);
Finder->addMatcher(typeLoc(loc(isInteger())).bind("tl"), this);
}
void IntegerTypesCheck::check(const MatchFinder::MatchResult &Result) {

View File

@ -49,6 +49,7 @@ short bar(const short, unsigned short) {
tmpl<short>();
// CHECK-MESSAGES: [[@LINE-1]]:8: warning: consider replacing 'short' with 'int16'
return 0;
}
void p(unsigned short port);
@ -57,3 +58,10 @@ void qux() {
short port;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'short' with 'int16'
}
// FIXME: This shouldn't warn, as UD-literal operators require one of a handful
// of types as an argument.
struct some_value {};
constexpr some_value operator"" _some_literal(unsigned long long int i);
// CHECK-MESSAGES: [[@LINE-1]]:47: warning: consider replacing 'unsigned long long'