[PATCH] D59336: [clang-tidy] Disable google-runtime-int in Objective-C++ 🔓

Stephane Moore via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 20 16:04:30 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE356627: [clang-tidy] Disable google-runtime-int in Objective-C++ 🔓 (authored by stephanemoore, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59336?vs=191219&id=191599#toc

Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59336/new/

https://reviews.llvm.org/D59336

Files:
  clang-tidy/google/IntegerTypesCheck.cpp
  docs/ReleaseNotes.rst
  test/clang-tidy/google-runtime-int.m


Index: clang-tidy/google/IntegerTypesCheck.cpp
===================================================================
--- clang-tidy/google/IntegerTypesCheck.cpp
+++ clang-tidy/google/IntegerTypesCheck.cpp
@@ -54,7 +54,9 @@
 
 void IntegerTypesCheck::registerMatchers(MatchFinder *Finder) {
   // Find all TypeLocs. The relevant Style Guide rule only applies to C++.
-  if (!getLangOpts().CPlusPlus)
+  // This check is also not applied in Objective-C++ sources as Objective-C
+  // often uses built-in integer types other than `int`.
+  if (!getLangOpts().CPlusPlus || getLangOpts().ObjC)
     return;
   // Match any integer types, unless they are passed to a printf-based API:
   //
Index: docs/ReleaseNotes.rst
===================================================================
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -115,6 +115,9 @@
   `CommentUserDefiniedLiterals`, `CommentStringLiterals`,
   `CommentCharacterLiterals` & `CommentNullPtrs` options.
 
+- The :doc:`google-runtime-int <clang-tidy/checks/google-runtime-int>`
+  check has been disabled in Objective-C++.
+
 - The `Acronyms` and `IncludeDefaultAcronyms` options for the
   :doc:`objc-property-declaration <clang-tidy/checks/objc-property-declaration>`
   check have been removed.
Index: test/clang-tidy/google-runtime-int.m
===================================================================
--- test/clang-tidy/google-runtime-int.m
+++ test/clang-tidy/google-runtime-int.m
@@ -0,0 +1,32 @@
+// RUN: clang-tidy -checks=-*,google-runtime-int %s 2>&1 -- | count 0
+// RUN: clang-tidy -checks=-*,google-runtime-int %s 2>&1 -- -x objective-c++ | count 0
+
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+
+ at interface NSString
+ at property(readonly) NSInteger integerValue;
+ at property(readonly) long long longLongValue;
+ at property(readonly) NSUInteger length;
+ at end
+
+NSInteger Foo(NSString *s) {
+  return [s integerValue];
+}
+
+long long Bar(NSString *s) {
+  return [s longLongValue];
+}
+
+NSUInteger Baz(NSString *s) {
+  return [s length];
+}
+
+unsigned short NSSwapShort(unsigned short inv);
+
+long DoSomeMath(long a, short b) {
+  short c = NSSwapShort(b);
+  long a2 = a * 5L;
+  return a2 + c;
+}
+


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59336.191599.patch
Type: text/x-patch
Size: 2203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190320/aa0a5ac1/attachment-0001.bin>


More information about the cfe-commits mailing list