[PATCH] D70876: [clang-tidy] Add spuriously-wake-up-functions check
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 12 11:28:55 PST 2020
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM aside from a test coverage request.
================
Comment at: clang-tools-extra/test/clang-tidy/bugprone-spuriously-wake-up-functions.c:26-30
+ if (list_c.next == NULL) {
+ if (0 != cnd_wait(&condition_c, &lock)) {
+ // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'cnd_wait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
+ }
+ }
----------------
Can you add a test case to demonstrate the behavior when there's not a compound statement involved? And another one for a slightly more complex if predicate? e.g.,
```
if (list_c.next == NULL)
if (0 != cnd_wait(&condition_c, &lock))
;
if (list_c.next == NULL && 0 != cnd_wait(&condition_c, &lock))
;
```
Both of these should be flagged similar to the form with the compound statement.
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70876/new/
https://reviews.llvm.org/D70876
More information about the cfe-commits
mailing list