[PATCH] D157057: [clang-tidy] Implement cppcoreguidelines CP.52

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 4 13:42:42 PDT 2023


PiotrZSL added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp:24-26
+                              hasType(recordDecl(hasAnyName(
+                                  "::std::unique_lock", "::std::lock_guard",
+                                  "::std::scoped_lock", "::std::shared_lock"))))
----------------
add configuration option for lock types, many big project got own types or wrappers.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/no-suspend-with-lock.rst:13
+Instead, locks should be released before suspending a coroutine.
+
+Examples:
----------------
add info to documentation that manual locking/unlocking is not supported.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/no-suspend-with-lock.cpp:189
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: coroutine suspended with lock 'lock' held [cppcoreguidelines-no-suspend-with-lock]
+}
----------------
add test with lambda, something like:
```
std::unique_lock<std::mutex> lock(mtx);

auto lambda = [] { co_yeld 0; }
```

And add test with class defined in function with co_yeld in class, and lock in function.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157057/new/

https://reviews.llvm.org/D157057



More information about the cfe-commits mailing list