diff --git a/clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.cpp b/clang-tools-extra/clang-tidy/darwin/AvoidSpinlockCheck.cpp similarity index 96% rename from clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.cpp rename to clang-tools-extra/clang-tidy/darwin/AvoidSpinlockCheck.cpp index ac3d2b288efa..2a52725c19c8 100644 --- a/clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.cpp +++ b/clang-tools-extra/clang-tidy/darwin/AvoidSpinlockCheck.cpp @@ -14,7 +14,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace objc { +namespace darwin { void AvoidSpinlockCheck::registerMatchers(MatchFinder *Finder) { Finder->addMatcher( @@ -31,6 +31,6 @@ void AvoidSpinlockCheck::check(const MatchFinder::MatchResult &Result) { "deprecated OSSpinLock"); } -} // namespace objc +} // namespace darwin } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.h b/clang-tools-extra/clang-tidy/darwin/AvoidSpinlockCheck.h similarity index 73% rename from clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.h rename to clang-tools-extra/clang-tidy/darwin/AvoidSpinlockCheck.h index dd409625f3a1..6ea10c550d90 100644 --- a/clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.h +++ b/clang-tools-extra/clang-tidy/darwin/AvoidSpinlockCheck.h @@ -6,20 +6,20 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_AVOIDSPINLOCKCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_AVOIDSPINLOCKCHECK_H #include "../ClangTidyCheck.h" namespace clang { namespace tidy { -namespace objc { +namespace darwin { /// Finds usages of OSSpinlock, which is deprecated due to potential livelock /// problems. /// /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/objc-avoid-spinlock.html +/// http://clang.llvm.org/extra/clang-tidy/checks/darwin-avoid-spinlock.html class AvoidSpinlockCheck : public ClangTidyCheck { public: AvoidSpinlockCheck(StringRef Name, ClangTidyContext *Context) @@ -28,8 +28,8 @@ class AvoidSpinlockCheck : public ClangTidyCheck { void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace objc +} // namespace darwin } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_AVOIDSPINLOCKCHECK_H diff --git a/clang-tools-extra/clang-tidy/darwin/CMakeLists.txt b/clang-tools-extra/clang-tidy/darwin/CMakeLists.txt index 5a34bd1ee495..c650efb2a5f2 100644 --- a/clang-tools-extra/clang-tidy/darwin/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/darwin/CMakeLists.txt @@ -1,6 +1,7 @@ set(LLVM_LINK_COMPONENTS support) add_clang_library(clangTidyDarwinModule + AvoidSpinlockCheck.cpp DarwinTidyModule.cpp DispatchOnceNonstaticCheck.cpp diff --git a/clang-tools-extra/clang-tidy/darwin/DarwinTidyModule.cpp b/clang-tools-extra/clang-tidy/darwin/DarwinTidyModule.cpp index 5c10cdfe9e6d..d11ef1fa01c9 100644 --- a/clang-tools-extra/clang-tidy/darwin/DarwinTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/darwin/DarwinTidyModule.cpp @@ -9,6 +9,7 @@ #include "../ClangTidy.h" #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" +#include "AvoidSpinlockCheck.h" #include "DispatchOnceNonstaticCheck.h" namespace clang { @@ -18,6 +19,8 @@ namespace darwin { class DarwinModule : public ClangTidyModule { public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { + CheckFactories.registerCheck( + "darwin-avoid-spinlock"); CheckFactories.registerCheck( "darwin-dispatch-once-nonstatic"); } diff --git a/clang-tools-extra/clang-tidy/objc/CMakeLists.txt b/clang-tools-extra/clang-tidy/objc/CMakeLists.txt index 0a12e4a850d5..68dda6530f7f 100644 --- a/clang-tools-extra/clang-tidy/objc/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/objc/CMakeLists.txt @@ -2,7 +2,6 @@ set(LLVM_LINK_COMPONENTS support) add_clang_library(clangTidyObjCModule AvoidNSErrorInitCheck.cpp - AvoidSpinlockCheck.cpp ForbiddenSubclassingCheck.cpp MissingHashCheck.cpp ObjCTidyModule.cpp diff --git a/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp b/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp index c9b57d5e2c81..69913125451c 100644 --- a/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp @@ -10,7 +10,6 @@ #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" #include "AvoidNSErrorInitCheck.h" -#include "AvoidSpinlockCheck.h" #include "ForbiddenSubclassingCheck.h" #include "MissingHashCheck.h" #include "PropertyDeclarationCheck.h" @@ -27,8 +26,6 @@ public: void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { CheckFactories.registerCheck( "objc-avoid-nserror-init"); - CheckFactories.registerCheck( - "objc-avoid-spinlock"); CheckFactories.registerCheck( "objc-forbidden-subclassing"); CheckFactories.registerCheck( diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index b3a245d9494e..2ba944bc7d0e 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -115,6 +115,9 @@ Improvements to clang-tidy Now also checks if any calls to ``pthread_*`` functions expect negative return values. +- The 'objc-avoid-spinlock' check was renamed to :doc:`darwin-avoid-spinlock + ` + Improvements to include-fixer ----------------------------- diff --git a/clang-tools-extra/docs/clang-tidy/checks/objc-avoid-spinlock.rst b/clang-tools-extra/docs/clang-tidy/checks/darwin-avoid-spinlock.rst similarity index 79% rename from clang-tools-extra/docs/clang-tidy/checks/objc-avoid-spinlock.rst rename to clang-tools-extra/docs/clang-tidy/checks/darwin-avoid-spinlock.rst index d1b11fcbab68..fd1f5d294a47 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/objc-avoid-spinlock.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/darwin-avoid-spinlock.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - objc-avoid-spinlock +.. title:: clang-tidy - darwin-avoid-spinlock -objc-avoid-spinlock -=================== +darwin-avoid-spinlock +===================== Finds usages of ``OSSpinlock``, which is deprecated due to potential livelock problems. diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index 36ecb0a4fb84..ae7ca492b674 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -212,6 +212,7 @@ Clang-Tidy Checks cppcoreguidelines-pro-type-vararg cppcoreguidelines-slicing cppcoreguidelines-special-member-functions + darwin-avoid-spinlock darwin-dispatch-once-nonstatic fuchsia-default-arguments-calls fuchsia-default-arguments-declarations @@ -325,7 +326,6 @@ Clang-Tidy Checks mpi-buffer-deref mpi-type-mismatch objc-avoid-nserror-init - objc-avoid-spinlock objc-forbidden-subclassing objc-missing-hash objc-property-declaration diff --git a/clang-tools-extra/test/clang-tidy/objc-avoid-spinlock.m b/clang-tools-extra/test/clang-tidy/darwin-avoid-spinlock.m similarity index 78% rename from clang-tools-extra/test/clang-tidy/objc-avoid-spinlock.m rename to clang-tools-extra/test/clang-tidy/darwin-avoid-spinlock.m index f9f05cb05a28..c870e0a0fed0 100644 --- a/clang-tools-extra/test/clang-tidy/objc-avoid-spinlock.m +++ b/clang-tools-extra/test/clang-tidy/darwin-avoid-spinlock.m @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s objc-avoid-spinlock %t +// RUN: %check_clang_tidy %s darwin-avoid-spinlock %t typedef int OSSpinLock; @@ -6,10 +6,10 @@ typedef int OSSpinLock; - (void)f { int i = 1; OSSpinlockLock(&i); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [objc-avoid-spinlock] + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [darwin-avoid-spinlock] OSSpinlockTry(&i); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [objc-avoid-spinlock] + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [darwin-avoid-spinlock] OSSpinlockUnlock(&i); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [objc-avoid-spinlock] + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [darwin-avoid-spinlock] } @end