[clang-tidy] Rename objc-avoid-spinlock check to darwin-avoid-spinlock

Summary:
OSSpinLock* are Apple/Darwin functions, but were previously located with ObjC checks as those were most closely tied to Apple platforms before.

Now that there's a specific Darwin module, relocating the check there.

This change was prepared by running rename_check.py.

Contributed By: mwyman

Reviewers: stephanemoore, dmaclach

Reviewed By: stephanemoore

Subscribers: Eugene.Zelenko, mgorny, xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang, #llvm

Differential Revision: https://reviews.llvm.org/D68148

llvm-svn: 373392
This commit is contained in:
Stephane Moore 2019-10-01 21:18:40 +00:00
parent 8830975cf6
commit e4acb971f1
10 changed files with 23 additions and 20 deletions

View File

@ -14,7 +14,7 @@ using namespace clang::ast_matchers;
namespace clang { namespace clang {
namespace tidy { namespace tidy {
namespace objc { namespace darwin {
void AvoidSpinlockCheck::registerMatchers(MatchFinder *Finder) { void AvoidSpinlockCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher( Finder->addMatcher(
@ -31,6 +31,6 @@ void AvoidSpinlockCheck::check(const MatchFinder::MatchResult &Result) {
"deprecated OSSpinLock"); "deprecated OSSpinLock");
} }
} // namespace objc } // namespace darwin
} // namespace tidy } // namespace tidy
} // namespace clang } // namespace clang

View File

@ -6,20 +6,20 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef 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_OBJC_AVOID_SPINLOCK_H #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_AVOIDSPINLOCKCHECK_H
#include "../ClangTidyCheck.h" #include "../ClangTidyCheck.h"
namespace clang { namespace clang {
namespace tidy { namespace tidy {
namespace objc { namespace darwin {
/// Finds usages of OSSpinlock, which is deprecated due to potential livelock /// Finds usages of OSSpinlock, which is deprecated due to potential livelock
/// problems. /// problems.
/// ///
/// For the user-facing documentation see: /// 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 { class AvoidSpinlockCheck : public ClangTidyCheck {
public: public:
AvoidSpinlockCheck(StringRef Name, ClangTidyContext *Context) AvoidSpinlockCheck(StringRef Name, ClangTidyContext *Context)
@ -28,8 +28,8 @@ class AvoidSpinlockCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
}; };
} // namespace objc } // namespace darwin
} // namespace tidy } // namespace tidy
} // namespace clang } // namespace clang
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_AVOIDSPINLOCKCHECK_H

View File

@ -1,6 +1,7 @@
set(LLVM_LINK_COMPONENTS support) set(LLVM_LINK_COMPONENTS support)
add_clang_library(clangTidyDarwinModule add_clang_library(clangTidyDarwinModule
AvoidSpinlockCheck.cpp
DarwinTidyModule.cpp DarwinTidyModule.cpp
DispatchOnceNonstaticCheck.cpp DispatchOnceNonstaticCheck.cpp

View File

@ -9,6 +9,7 @@
#include "../ClangTidy.h" #include "../ClangTidy.h"
#include "../ClangTidyModule.h" #include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h" #include "../ClangTidyModuleRegistry.h"
#include "AvoidSpinlockCheck.h"
#include "DispatchOnceNonstaticCheck.h" #include "DispatchOnceNonstaticCheck.h"
namespace clang { namespace clang {
@ -18,6 +19,8 @@ namespace darwin {
class DarwinModule : public ClangTidyModule { class DarwinModule : public ClangTidyModule {
public: public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<AvoidSpinlockCheck>(
"darwin-avoid-spinlock");
CheckFactories.registerCheck<DispatchOnceNonstaticCheck>( CheckFactories.registerCheck<DispatchOnceNonstaticCheck>(
"darwin-dispatch-once-nonstatic"); "darwin-dispatch-once-nonstatic");
} }

View File

@ -2,7 +2,6 @@ set(LLVM_LINK_COMPONENTS support)
add_clang_library(clangTidyObjCModule add_clang_library(clangTidyObjCModule
AvoidNSErrorInitCheck.cpp AvoidNSErrorInitCheck.cpp
AvoidSpinlockCheck.cpp
ForbiddenSubclassingCheck.cpp ForbiddenSubclassingCheck.cpp
MissingHashCheck.cpp MissingHashCheck.cpp
ObjCTidyModule.cpp ObjCTidyModule.cpp

View File

@ -10,7 +10,6 @@
#include "../ClangTidyModule.h" #include "../ClangTidyModule.h"
#include "../ClangTidyModuleRegistry.h" #include "../ClangTidyModuleRegistry.h"
#include "AvoidNSErrorInitCheck.h" #include "AvoidNSErrorInitCheck.h"
#include "AvoidSpinlockCheck.h"
#include "ForbiddenSubclassingCheck.h" #include "ForbiddenSubclassingCheck.h"
#include "MissingHashCheck.h" #include "MissingHashCheck.h"
#include "PropertyDeclarationCheck.h" #include "PropertyDeclarationCheck.h"
@ -27,8 +26,6 @@ public:
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override { void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
CheckFactories.registerCheck<AvoidNSErrorInitCheck>( CheckFactories.registerCheck<AvoidNSErrorInitCheck>(
"objc-avoid-nserror-init"); "objc-avoid-nserror-init");
CheckFactories.registerCheck<AvoidSpinlockCheck>(
"objc-avoid-spinlock");
CheckFactories.registerCheck<ForbiddenSubclassingCheck>( CheckFactories.registerCheck<ForbiddenSubclassingCheck>(
"objc-forbidden-subclassing"); "objc-forbidden-subclassing");
CheckFactories.registerCheck<MissingHashCheck>( CheckFactories.registerCheck<MissingHashCheck>(

View File

@ -115,6 +115,9 @@ Improvements to clang-tidy
Now also checks if any calls to ``pthread_*`` functions expect negative return Now also checks if any calls to ``pthread_*`` functions expect negative return
values. values.
- The 'objc-avoid-spinlock' check was renamed to :doc:`darwin-avoid-spinlock
<clang-tidy/checks/darwin-avoid-spinlock>`
Improvements to include-fixer Improvements to include-fixer
----------------------------- -----------------------------

View File

@ -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 Finds usages of ``OSSpinlock``, which is deprecated due to potential livelock
problems. problems.

View File

@ -212,6 +212,7 @@ Clang-Tidy Checks
cppcoreguidelines-pro-type-vararg cppcoreguidelines-pro-type-vararg
cppcoreguidelines-slicing cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions cppcoreguidelines-special-member-functions
darwin-avoid-spinlock
darwin-dispatch-once-nonstatic darwin-dispatch-once-nonstatic
fuchsia-default-arguments-calls fuchsia-default-arguments-calls
fuchsia-default-arguments-declarations fuchsia-default-arguments-declarations
@ -325,7 +326,6 @@ Clang-Tidy Checks
mpi-buffer-deref mpi-buffer-deref
mpi-type-mismatch mpi-type-mismatch
objc-avoid-nserror-init objc-avoid-nserror-init
objc-avoid-spinlock
objc-forbidden-subclassing objc-forbidden-subclassing
objc-missing-hash objc-missing-hash
objc-property-declaration objc-property-declaration

View File

@ -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; typedef int OSSpinLock;
@ -6,10 +6,10 @@ typedef int OSSpinLock;
- (void)f { - (void)f {
int i = 1; int i = 1;
OSSpinlockLock(&i); 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); 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); 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 @end