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

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 16 08:08:46 PDT 2015


Author: alexfh
Date: Wed Sep 16 10:08:46 2015
New Revision: 247806

URL: http://llvm.org/viewvc/llvm-project?rev=247806&view=rev
Log:
[clang-tidy] google-runtime-int: made the matcher more restricting, added a test for a false positive

This should be NFC.

Modified:
    clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.cpp
    clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.cpp?rev=247806&r1=247805&r2=247806&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.cpp Wed Sep 16 10:08:46 2015
@@ -36,7 +36,7 @@ void IntegerTypesCheck::storeOptions(Cla
 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) {

Modified: clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.cpp?rev=247806&r1=247805&r2=247806&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.cpp Wed Sep 16 10:08:46 2015
@@ -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'
+




More information about the cfe-commits mailing list