stephanemoore updated this revision to Diff 191198.
stephanemoore marked 2 inline comments as done.
stephanemoore added a comment.
Updated with changes:
• Switched to using `| count 0` instead of grep'ing for warnings.
• Merged Objective-C and Objective-C++ test cases into single file with
multiple runs.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59336/new/
https://reviews.llvm.org/D59336
Files:
clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/google-runtime-int.m
Index: clang-tools-extra/test/clang-tidy/google-runtime-int.m
===================================================================
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/google-runtime-int.m
@@ -0,0 +1,32 @@
+// RUN: clang-tidy -checks=-*,google-runtime-int %s 2>&1 -- -x objective-c |
count 0
+// RUN: clang-tidy -checks=-*,google-runtime-int %s 2>&1 -- -x objective-c++ |
count 0
+
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+
+@interface NSString
+@property(readonly) NSInteger integerValue;
+@property(readonly) long long longLongValue;
+@property(readonly) NSUInteger length;
+@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;
+}
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===================================================================
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/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: clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
+++ clang-tools-extra/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: clang-tools-extra/test/clang-tidy/google-runtime-int.m
===================================================================
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/google-runtime-int.m
@@ -0,0 +1,32 @@
+// RUN: clang-tidy -checks=-*,google-runtime-int %s 2>&1 -- -x objective-c | count 0
+// RUN: clang-tidy -checks=-*,google-runtime-int %s 2>&1 -- -x objective-c++ | count 0
+
+typedef long NSInteger;
+typedef unsigned long NSUInteger;
+
+@interface NSString
+@property(readonly) NSInteger integerValue;
+@property(readonly) long long longLongValue;
+@property(readonly) NSUInteger length;
+@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;
+}
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===================================================================
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/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: clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
+++ clang-tools-extra/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:
//
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits