[PATCH] D85984: [analyzer] Add a new checker alpha.cplusplus.CPlusPlus11Lock

Denys Petrov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 8 05:49:26 PDT 2020


ASDenysPetrov added a comment.

@steakhal

> the readability of the reports should be improved.

Absolutely agree. Let's do this in the next patches :)

@NoQ 
You've recommended to extend PthreadLockChecker with STL mutexes. I think I've done. Could you make a quick look, please?



================
Comment at: clang/test/Analysis/Checkers/CPlusPlus11LockChecker.cpp:379-382
+void rm_bad1() {
+  rm1.lock(); // no-warning
+  rm1.lock(); // expected-warning{{This lock has already been acquired}}
+}
----------------
NoQ wrote:
> I repeat, this is a false positive. Recursive mutexes can be locked twice, that's the whole point.
Yes, I remember. I think you've mixed up with my previous attempts of introducting a new checks for recursive mutexes.
This is not this case. This kind of checks already exists in PthreadLockChecker before.
I've just reused this check for all kind of STL mutexes.

If you look at `void bad1()` in clang\test\Analysis\pthreadlock.c you can find the same case.


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

https://reviews.llvm.org/D85984



More information about the cfe-commits mailing list