[clang-tools-extra] r373392 - [clang-tidy] Rename objc-avoid-spinlock check to darwin-avoid-spinlock
Stephane Moore via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 1 14:18:41 PDT 2019
Author: stephanemoore
Date: Tue Oct 1 14:18:40 2019
New Revision: 373392
URL: http://llvm.org/viewvc/llvm-project?rev=373392&view=rev
Log:
[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
Added:
clang-tools-extra/trunk/clang-tidy/darwin/AvoidSpinlockCheck.cpp
clang-tools-extra/trunk/clang-tidy/darwin/AvoidSpinlockCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/darwin-avoid-spinlock.rst
clang-tools-extra/trunk/test/clang-tidy/darwin-avoid-spinlock.m
Removed:
clang-tools-extra/trunk/clang-tidy/objc/AvoidSpinlockCheck.cpp
clang-tools-extra/trunk/clang-tidy/objc/AvoidSpinlockCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/objc-avoid-spinlock.rst
clang-tools-extra/trunk/test/clang-tidy/objc-avoid-spinlock.m
Modified:
clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/darwin/DarwinTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/objc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
Added: clang-tools-extra/trunk/clang-tidy/darwin/AvoidSpinlockCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/darwin/AvoidSpinlockCheck.cpp?rev=373392&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/darwin/AvoidSpinlockCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/darwin/AvoidSpinlockCheck.cpp Tue Oct 1 14:18:40 2019
@@ -0,0 +1,36 @@
+//===--- AvoidSpinlockCheck.cpp - clang-tidy-------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "AvoidSpinlockCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace darwin {
+
+void AvoidSpinlockCheck::registerMatchers(MatchFinder *Finder) {
+ Finder->addMatcher(
+ callExpr(callee((functionDecl(hasAnyName(
+ "OSSpinlockLock", "OSSpinlockUnlock", "OSSpinlockTry")))))
+ .bind("spinlock"),
+ this);
+}
+
+void AvoidSpinlockCheck::check(const MatchFinder::MatchResult &Result) {
+ const auto *MatchedExpr = Result.Nodes.getNodeAs<CallExpr>("spinlock");
+ diag(MatchedExpr->getBeginLoc(),
+ "use os_unfair_lock_lock() or dispatch queue APIs instead of the "
+ "deprecated OSSpinLock");
+}
+
+} // namespace darwin
+} // namespace tidy
+} // namespace clang
Added: clang-tools-extra/trunk/clang-tidy/darwin/AvoidSpinlockCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/darwin/AvoidSpinlockCheck.h?rev=373392&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/darwin/AvoidSpinlockCheck.h (added)
+++ clang-tools-extra/trunk/clang-tidy/darwin/AvoidSpinlockCheck.h Tue Oct 1 14:18:40 2019
@@ -0,0 +1,35 @@
+//===--- AvoidSpinlockCheck.h - clang-tidy-----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#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 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/darwin-avoid-spinlock.html
+class AvoidSpinlockCheck : public ClangTidyCheck {
+ public:
+ AvoidSpinlockCheck(StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context) {}
+ void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+ void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace darwin
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_DARWIN_AVOIDSPINLOCKCHECK_H
Modified: clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt?rev=373392&r1=373391&r2=373392&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/darwin/CMakeLists.txt Tue Oct 1 14:18:40 2019
@@ -1,6 +1,7 @@
set(LLVM_LINK_COMPONENTS support)
add_clang_library(clangTidyDarwinModule
+ AvoidSpinlockCheck.cpp
DarwinTidyModule.cpp
DispatchOnceNonstaticCheck.cpp
Modified: clang-tools-extra/trunk/clang-tidy/darwin/DarwinTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/darwin/DarwinTidyModule.cpp?rev=373392&r1=373391&r2=373392&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/darwin/DarwinTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/darwin/DarwinTidyModule.cpp Tue Oct 1 14:18:40 2019
@@ -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");
}
Removed: clang-tools-extra/trunk/clang-tidy/objc/AvoidSpinlockCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/AvoidSpinlockCheck.cpp?rev=373391&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidSpinlockCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidSpinlockCheck.cpp (removed)
@@ -1,36 +0,0 @@
-//===--- AvoidSpinlockCheck.cpp - clang-tidy-------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include "AvoidSpinlockCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace objc {
-
-void AvoidSpinlockCheck::registerMatchers(MatchFinder *Finder) {
- Finder->addMatcher(
- callExpr(callee((functionDecl(hasAnyName(
- "OSSpinlockLock", "OSSpinlockUnlock", "OSSpinlockTry")))))
- .bind("spinlock"),
- this);
-}
-
-void AvoidSpinlockCheck::check(const MatchFinder::MatchResult &Result) {
- const auto *MatchedExpr = Result.Nodes.getNodeAs<CallExpr>("spinlock");
- diag(MatchedExpr->getBeginLoc(),
- "use os_unfair_lock_lock() or dispatch queue APIs instead of the "
- "deprecated OSSpinLock");
-}
-
-} // namespace objc
-} // namespace tidy
-} // namespace clang
Removed: clang-tools-extra/trunk/clang-tidy/objc/AvoidSpinlockCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/AvoidSpinlockCheck.h?rev=373391&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/AvoidSpinlockCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/AvoidSpinlockCheck.h (removed)
@@ -1,35 +0,0 @@
-//===--- AvoidSpinlockCheck.h - clang-tidy-----------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H
-
-#include "../ClangTidyCheck.h"
-
-namespace clang {
-namespace tidy {
-namespace objc {
-
-/// 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
-class AvoidSpinlockCheck : public ClangTidyCheck {
- public:
- AvoidSpinlockCheck(StringRef Name, ClangTidyContext *Context)
- : ClangTidyCheck(Name, Context) {}
- void registerMatchers(ast_matchers::MatchFinder *Finder) override;
- void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-};
-
-} // namespace objc
-} // namespace tidy
-} // namespace clang
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_AVOID_SPINLOCK_H
Modified: clang-tools-extra/trunk/clang-tidy/objc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/CMakeLists.txt?rev=373392&r1=373391&r2=373392&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/CMakeLists.txt Tue Oct 1 14:18:40 2019
@@ -2,7 +2,6 @@ set(LLVM_LINK_COMPONENTS support)
add_clang_library(clangTidyObjCModule
AvoidNSErrorInitCheck.cpp
- AvoidSpinlockCheck.cpp
ForbiddenSubclassingCheck.cpp
MissingHashCheck.cpp
ObjCTidyModule.cpp
Modified: clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp?rev=373392&r1=373391&r2=373392&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/objc/ObjCTidyModule.cpp Tue Oct 1 14:18:40 2019
@@ -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>(
Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=373392&r1=373391&r2=373392&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Tue Oct 1 14:18:40 2019
@@ -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
-----------------------------
Added: clang-tools-extra/trunk/docs/clang-tidy/checks/darwin-avoid-spinlock.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/darwin-avoid-spinlock.rst?rev=373392&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/darwin-avoid-spinlock.rst (added)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/darwin-avoid-spinlock.rst Tue Oct 1 14:18:40 2019
@@ -0,0 +1,15 @@
+.. title:: clang-tidy - darwin-avoid-spinlock
+
+darwin-avoid-spinlock
+=====================
+
+Finds usages of ``OSSpinlock``, which is deprecated due to potential livelock
+problems.
+
+This check will detect following function invocations:
+
+- ``OSSpinlockLock``
+- ``OSSpinlockTry``
+- ``OSSpinlockUnlock``
+
+The corresponding information about the problem of ``OSSpinlock``: https://blog.postmates.com/why-spinlocks-are-bad-on-ios-b69fc5221058
Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=373392&r1=373391&r2=373392&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Tue Oct 1 14:18:40 2019
@@ -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
Removed: clang-tools-extra/trunk/docs/clang-tidy/checks/objc-avoid-spinlock.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/objc-avoid-spinlock.rst?rev=373391&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/objc-avoid-spinlock.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/objc-avoid-spinlock.rst (removed)
@@ -1,15 +0,0 @@
-.. title:: clang-tidy - objc-avoid-spinlock
-
-objc-avoid-spinlock
-===================
-
-Finds usages of ``OSSpinlock``, which is deprecated due to potential livelock
-problems.
-
-This check will detect following function invocations:
-
-- ``OSSpinlockLock``
-- ``OSSpinlockTry``
-- ``OSSpinlockUnlock``
-
-The corresponding information about the problem of ``OSSpinlock``: https://blog.postmates.com/why-spinlocks-are-bad-on-ios-b69fc5221058
Added: clang-tools-extra/trunk/test/clang-tidy/darwin-avoid-spinlock.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/darwin-avoid-spinlock.m?rev=373392&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/darwin-avoid-spinlock.m (added)
+++ clang-tools-extra/trunk/test/clang-tidy/darwin-avoid-spinlock.m Tue Oct 1 14:18:40 2019
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s darwin-avoid-spinlock %t
+
+typedef int OSSpinLock;
+
+ at implementation Foo
+- (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 [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 [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 [darwin-avoid-spinlock]
+}
+ at end
Removed: clang-tools-extra/trunk/test/clang-tidy/objc-avoid-spinlock.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-avoid-spinlock.m?rev=373391&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-avoid-spinlock.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-avoid-spinlock.m (removed)
@@ -1,15 +0,0 @@
-// RUN: %check_clang_tidy %s objc-avoid-spinlock %t
-
-typedef int OSSpinLock;
-
- at implementation Foo
-- (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]
- 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]
- 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]
-}
- at end
More information about the cfe-commits
mailing list