[PATCH] D93940: Add a check for blocking types and functions.
Vasily Kulikov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 30 03:44:35 PST 2020
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93940.314091.patch
Type: text/x-patch
Size: 692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201230/1e6372ce/attachment.bin>
More information about the cfe-commits
mailing list