segoon created this revision.
Herald added a subscriber: jfb.
segoon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The preemptive functions/types can be separated into the following categories:

- explicit sleep(3)-like functions
- sleeping/waiting synchronization primitives

The check searches for:

- C++ synchronization primitives
- C11 synchronization primitives
- POSIX synchronization primitives
- some POSIX blocking functions
- some blocking Linux syscalls
- some Boost.Thread synchronization primitives

There are AST matchers for both sync primitives creation and blocking methods 
calls - we want
the former for user-created mutexes and the latter for mutex usage passed from 
outside (e.g. via
library global variable or function parameter).

Atomic code is WIP, will be done before the merge. TODOs in tests are marked 
with CHECKT-MESSAGES.

The check doesn't include the following:

- Io and filesystem operations. It will be included in a separate checker 
concurrency-async-fs as a user might have a different policy (e.g. no FS thread 
pool, so nothing can be done).
- Creation of new threads. Same here, will be implemented in 
concurrency-async-no-new-threads, it is OK for some projects and must be 
changed to async code in others.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93940

Files:
  clang-tools-extra/clang-tidy/concurrency/AsyncBlockingCheck.cpp


Index: clang-tools-extra/clang-tidy/concurrency/AsyncBlockingCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/concurrency/AsyncBlockingCheck.cpp
+++ clang-tools-extra/clang-tidy/concurrency/AsyncBlockingCheck.cpp
@@ -314,12 +314,6 @@
     }
   }
 
-  const auto *L = Result.Nodes.getNodeAs<NestedNameSpecifierLoc>("lock");
-  if (L) {
-    diag(L->getBeginLoc(), "type may sleep and is not coroutine-safe")
-        << SourceRange(L->getBeginLoc(), L->getEndLoc());
-  }
-
   const auto *Atomic = Result.Nodes.getNodeAs<ValueDecl>(kAtomic);
   if (Atomic) {
     const auto *Lockfree = Result.Nodes.getNodeAs<VarDecl>(kLockfree);


Index: clang-tools-extra/clang-tidy/concurrency/AsyncBlockingCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/concurrency/AsyncBlockingCheck.cpp
+++ clang-tools-extra/clang-tidy/concurrency/AsyncBlockingCheck.cpp
@@ -314,12 +314,6 @@
     }
   }
 
-  const auto *L = Result.Nodes.getNodeAs<NestedNameSpecifierLoc>("lock");
-  if (L) {
-    diag(L->getBeginLoc(), "type may sleep and is not coroutine-safe")
-        << SourceRange(L->getBeginLoc(), L->getEndLoc());
-  }
-
   const auto *Atomic = Result.Nodes.getNodeAs<ValueDecl>(kAtomic);
   if (Atomic) {
     const auto *Lockfree = Result.Nodes.getNodeAs<VarDecl>(kLockfree);
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D93940: Add a check... Vasily Kulikov via Phabricator via cfe-commits

Reply via email to