Skip to content

Commit e4acb97

Browse files
committed
[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
1 parent 8830975 commit e4acb97

File tree

10 files changed

+23
-20
lines changed

10 files changed

+23
-20
lines changed

clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.cpp renamed to clang-tools-extra/clang-tidy/darwin/AvoidSpinlockCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using namespace clang::ast_matchers;
1414

1515
namespace clang {
1616
namespace tidy {
17-
namespace objc {
17+
namespace darwin {
1818

1919
void AvoidSpinlockCheck::registerMatchers(MatchFinder *Finder) {
2020
Finder->addMatcher(
@@ -31,6 +31,6 @@ void AvoidSpinlockCheck::check(const MatchFinder::MatchResult &Result) {
3131
"deprecated OSSpinLock");
3232
}
3333

34-
} // namespace objc
34+
} // namespace darwin
3535
} // namespace tidy
3636
} // namespace clang

clang-tools-extra/clang-tidy/objc/AvoidSpinlockCheck.h renamed to clang-tools-extra/clang-tidy/darwin/AvoidSpinlockCheck.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H
10-
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H
9+
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_AVOIDSPINLOCKCHECK_H
10+
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_AVOIDSPINLOCKCHECK_H
1111

1212
#include "../ClangTidyCheck.h"
1313

1414
namespace clang {
1515
namespace tidy {
16-
namespace objc {
16+
namespace darwin {
1717

1818
/// Finds usages of OSSpinlock, which is deprecated due to potential livelock
1919
/// problems.
2020
///
2121
/// For the user-facing documentation see:
22-
/// http://clang.llvm.org/extra/clang-tidy/checks/objc-avoid-spinlock.html
22+
/// http://clang.llvm.org/extra/clang-tidy/checks/darwin-avoid-spinlock.html
2323
class AvoidSpinlockCheck : public ClangTidyCheck {
2424
public:
2525
AvoidSpinlockCheck(StringRef Name, ClangTidyContext *Context)
@@ -28,8 +28,8 @@ class AvoidSpinlockCheck : public ClangTidyCheck {
2828
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
2929
};
3030

31-
} // namespace objc
31+
} // namespace darwin
3232
} // namespace tidy
3333
} // namespace clang
3434

35-
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H
35+
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_AVOIDSPINLOCKCHECK_H

clang-tools-extra/clang-tidy/darwin/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set(LLVM_LINK_COMPONENTS support)
22

33
add_clang_library(clangTidyDarwinModule
4+
AvoidSpinlockCheck.cpp
45
DarwinTidyModule.cpp
56
DispatchOnceNonstaticCheck.cpp
67

clang-tools-extra/clang-tidy/darwin/DarwinTidyModule.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "../ClangTidy.h"
1010
#include "../ClangTidyModule.h"
1111
#include "../ClangTidyModuleRegistry.h"
12+
#include "AvoidSpinlockCheck.h"
1213
#include "DispatchOnceNonstaticCheck.h"
1314

1415
namespace clang {
@@ -18,6 +19,8 @@ namespace darwin {
1819
class DarwinModule : public ClangTidyModule {
1920
public:
2021
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
22+
CheckFactories.registerCheck<AvoidSpinlockCheck>(
23+
"darwin-avoid-spinlock");
2124
CheckFactories.registerCheck<DispatchOnceNonstaticCheck>(
2225
"darwin-dispatch-once-nonstatic");
2326
}

clang-tools-extra/clang-tidy/objc/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ set(LLVM_LINK_COMPONENTS support)
22

33
add_clang_library(clangTidyObjCModule
44
AvoidNSErrorInitCheck.cpp
5-
AvoidSpinlockCheck.cpp
65
ForbiddenSubclassingCheck.cpp
76
MissingHashCheck.cpp
87
ObjCTidyModule.cpp

clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "../ClangTidyModule.h"
1111
#include "../ClangTidyModuleRegistry.h"
1212
#include "AvoidNSErrorInitCheck.h"
13-
#include "AvoidSpinlockCheck.h"
1413
#include "ForbiddenSubclassingCheck.h"
1514
#include "MissingHashCheck.h"
1615
#include "PropertyDeclarationCheck.h"
@@ -27,8 +26,6 @@ class ObjCModule : public ClangTidyModule {
2726
void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
2827
CheckFactories.registerCheck<AvoidNSErrorInitCheck>(
2928
"objc-avoid-nserror-init");
30-
CheckFactories.registerCheck<AvoidSpinlockCheck>(
31-
"objc-avoid-spinlock");
3229
CheckFactories.registerCheck<ForbiddenSubclassingCheck>(
3330
"objc-forbidden-subclassing");
3431
CheckFactories.registerCheck<MissingHashCheck>(

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ Improvements to clang-tidy
115115
Now also checks if any calls to ``pthread_*`` functions expect negative return
116116
values.
117117

118+
- The 'objc-avoid-spinlock' check was renamed to :doc:`darwin-avoid-spinlock
119+
<clang-tidy/checks/darwin-avoid-spinlock>`
120+
118121
Improvements to include-fixer
119122
-----------------------------
120123

clang-tools-extra/docs/clang-tidy/checks/objc-avoid-spinlock.rst renamed to clang-tools-extra/docs/clang-tidy/checks/darwin-avoid-spinlock.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.. title:: clang-tidy - objc-avoid-spinlock
1+
.. title:: clang-tidy - darwin-avoid-spinlock
22

3-
objc-avoid-spinlock
4-
===================
3+
darwin-avoid-spinlock
4+
=====================
55

66
Finds usages of ``OSSpinlock``, which is deprecated due to potential livelock
77
problems.

clang-tools-extra/docs/clang-tidy/checks/list.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ Clang-Tidy Checks
212212
cppcoreguidelines-pro-type-vararg
213213
cppcoreguidelines-slicing
214214
cppcoreguidelines-special-member-functions
215+
darwin-avoid-spinlock
215216
darwin-dispatch-once-nonstatic
216217
fuchsia-default-arguments-calls
217218
fuchsia-default-arguments-declarations
@@ -325,7 +326,6 @@ Clang-Tidy Checks
325326
mpi-buffer-deref
326327
mpi-type-mismatch
327328
objc-avoid-nserror-init
328-
objc-avoid-spinlock
329329
objc-forbidden-subclassing
330330
objc-missing-hash
331331
objc-property-declaration
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// RUN: %check_clang_tidy %s objc-avoid-spinlock %t
1+
// RUN: %check_clang_tidy %s darwin-avoid-spinlock %t
22

33
typedef int OSSpinLock;
44

55
@implementation Foo
66
- (void)f {
77
int i = 1;
88
OSSpinlockLock(&i);
9-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [objc-avoid-spinlock]
9+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [darwin-avoid-spinlock]
1010
OSSpinlockTry(&i);
11-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [objc-avoid-spinlock]
11+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [darwin-avoid-spinlock]
1212
OSSpinlockUnlock(&i);
13-
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [objc-avoid-spinlock]
13+
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use os_unfair_lock_lock() or dispatch queue APIs instead of the deprecated OSSpinLock [darwin-avoid-spinlock]
1414
}
1515
@end

0 commit comments

Comments
 (0)