[PATCH] D58818: [clang-tidy] added cppcoreguidelines-use-raii-locks check
Lewis Clark via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 2 12:06:21 PST 2019
lewmpk marked 7 inline comments as done.
lewmpk added inline comments.
================
Comment at: test/clang-tidy/cppcoreguidelines-use-raii-locks.cpp:4
+// Mock implementation of std::mutex
+namespace std {
+struct mutex {
----------------
JonasToth wrote:
> Please add more tests
>
> What happens for this?
> ```
> void foo() {
> std::mutex m;
> m.lock();
> m.unlock();
> m.lock();
> m.unlock();
> m.try_lock();
> m.lock();
> m.unlock();
> }
> ```
>
> - Please add tests for templates, where the lock-type is a template parameter
> - please add tests where the locking happens within macros
> - please add tests for usage within loops
> - where cases like `std::mutex m1; std::mutex &m2 = m1; // usage`. This should not be diagnosed, right?
I've added a test case for your example, templates, macros and loops.
I can't catch the case `std::mutex m1; std::mutex &m2 = m1; // usage`, but i can catch trivial cases.
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58818/new/
https://reviews.llvm.org/D58818
More information about the cfe-commits
mailing list