[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 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

View File

@ -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

View File

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

View File

@ -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<AvoidSpinlockCheck>(
"darwin-avoid-spinlock");
CheckFactories.registerCheck<DispatchOnceNonstaticCheck>(
"darwin-dispatch-once-nonstatic");
}

View File

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

View File

@ -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<AvoidNSErrorInitCheck>(
"objc-avoid-nserror-init");
CheckFactories.registerCheck<AvoidSpinlockCheck>(
"objc-avoid-spinlock");
CheckFactories.registerCheck<ForbiddenSubclassingCheck>(
"objc-forbidden-subclassing");
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
values.
- The 'objc-avoid-spinlock' check was renamed to :doc:`darwin-avoid-spinlock
<clang-tidy/checks/darwin-avoid-spinlock>`
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
problems.

View File

@ -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

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;
@ -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