[clang-tools-extra] r223651 - [clang-tidy] google-runtime-int: Don't check C code.

Alexander Kornienko alexfh at google.com
Mon Dec 8 03:17:29 PST 2014


Author: alexfh
Date: Mon Dec  8 05:17:25 2014
New Revision: 223651

URL: http://llvm.org/viewvc/llvm-project?rev=223651&view=rev
Log:
[clang-tidy] google-runtime-int: Don't check C code.

Added:
    clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.c
Modified:
    clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.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=223651&r1=223650&r2=223651&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/google/IntegerTypesCheck.cpp Mon Dec  8 05:17:25 2014
@@ -26,6 +26,10 @@ void IntegerTypesCheck::registerMatchers
 }
 
 void IntegerTypesCheck::check(const MatchFinder::MatchResult &Result) {
+  // The relevant Style Guide rule only applies to C++.
+  if (!Result.Context->getLangOpts().CPlusPlus)
+    return;
+
   auto TL = *Result.Nodes.getNodeAs<TypeLoc>("tl");
   SourceLocation Loc = TL.getLocStart();
 

Added: clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.c
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.c?rev=223651&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.c (added)
+++ clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.c Mon Dec  8 05:17:25 2014
@@ -0,0 +1,27 @@
+// RUN: clang-tidy -checks=-*,google-runtime-int %s -- -x c 2>&1 | not grep 'warning:\|error:'
+
+long a();
+
+long b(long x);
+
+short bar(const short q, unsigned short w) {
+  long double foo;
+  unsigned short port;
+
+  const unsigned short bar;
+  long long *baar;
+  const unsigned short bara;
+  long const long moo;
+  long volatile long wat;
+  unsigned long y;
+  unsigned long long **const *tmp;
+  unsigned short porthole;
+
+  unsigned cast;
+  cast = (short)42;
+  return q;
+}
+
+void qux() {
+  short port;
+}





More information about the cfe-commits mailing list