diff options
author | Vy Nguyen <vyng@google.com> | 2021-12-02 15:22:43 -0500 |
---|---|---|
committer | Vy Nguyen <vyng@google.com> | 2021-12-02 18:32:16 -0500 |
commit | aba8f320cc139a177ba5f549d7e7bf9a6350aa58 (patch) | |
tree | 02917b19316efb31c2c84572d2994d5208341919 /clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp | |
parent | 9c4d194f44c4f74826b98f2efaa5e8a356650491 (diff) | |
download | llvm-aba8f320cc139a177ba5f549d7e7bf9a6350aa58.zip llvm-aba8f320cc139a177ba5f549d7e7bf9a6350aa58.tar.gz llvm-aba8f320cc139a177ba5f549d7e7bf9a6350aa58.tar.bz2 |
[clang-tidy][objc] Finds and fixes improper usages of XCTAssertEquals and XCTAssertNotEquals.
Using XCTAssertEqual on NSString* objects is almost always wrong.
Unfortunately, we have seen a lot of tests doing this and reyling on pointer equality for strings with the same values (which happens to work sometimes - depending on the linker, but this assumption is not guaranteed by the language)
These fixes would make tests less brittle.
Differential Revision: https://reviews.llvm.org/D114975
Diffstat (limited to 'clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp b/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp index 56ab0ab..3a5bf7d 100644 --- a/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp @@ -9,6 +9,7 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" +#include "AssertEquals.h" #include "AvoidNSErrorInitCheck.h" #include "DeallocInCategoryCheck.h" #include "ForbiddenSubclassingCheck.h" @@ -28,6 +29,8 @@ public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFactories.registerCheck<AvoidNSErrorInitCheck>( "objc-avoid-nserror-init"); + CheckFactories.registerCheck<AssertEquals>("objc-assert-equals"); + CheckFactories.registerCheck<DeallocInCategoryCheck>( "objc-dealloc-in-category"); CheckFactories.registerCheck<ForbiddenSubclassingCheck>( |