Files
TheRock/compiler/amd-llvm/clang-tools-extra/test/clang-tidy/checkers/bugprone/spuriously-wake-up-functions.c
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

166 lines
5.2 KiB
C

// RUN: %check_clang_tidy %s bugprone-spuriously-wake-up-functions %t -- --
#include <stddef.h>
struct Node1 {
void *Node1;
struct Node1 *next;
};
typedef struct mtx_t {
} mtx_t;
typedef struct cnd_t {
} cnd_t;
struct timespec {};
int cnd_wait(cnd_t *cond, mtx_t *mutex){ return 0; };
int cnd_timedwait(cnd_t *cond, mtx_t *mutex,
const struct timespec *time_point){ return 0; };
struct Node1 list_c;
static mtx_t lock;
static cnd_t condition_c;
struct timespec ts;
void consume_list_element(void) {
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]
}
}
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]
;
if (list_c.next == NULL && 0 != cnd_wait(&condition_c, &lock))
// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'cnd_wait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
;
while (list_c.next == NULL) {
if (0 != cnd_wait(&condition_c, &lock)) {
}
}
while (list_c.next == NULL)
if (0 != cnd_wait(&condition_c, &lock)) {
}
while (list_c.next == NULL)
if (0 != cnd_wait(&condition_c, &lock))
;
if (list_c.next == NULL) {
cnd_wait(&condition_c, &lock);
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'cnd_wait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
}
if (list_c.next == NULL)
cnd_wait(&condition_c, &lock);
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'cnd_wait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
while (list_c.next == NULL) {
cnd_wait(&condition_c, &lock);
}
while (list_c.next == NULL)
cnd_wait(&condition_c, &lock);
do {
if (0 != cnd_wait(&condition_c, &lock)) {
}
} while (list_c.next == NULL);
do
if (0 != cnd_wait(&condition_c, &lock)) {
}
while (list_c.next == NULL);
do
if (0 != cnd_wait(&condition_c, &lock))
;
while (list_c.next == NULL);
do {
cnd_wait(&condition_c, &lock);
} while (list_c.next == NULL);
do
cnd_wait(&condition_c, &lock);
while (list_c.next == NULL);
for (;; list_c.next == NULL) {
if (0 != cnd_wait(&condition_c, &lock)) {
}
}
for (;; list_c.next == NULL)
if (0 != cnd_wait(&condition_c, &lock)) {
}
for (;; list_c.next == NULL)
if (0 != cnd_wait(&condition_c, &lock))
;
for (;; list_c.next == NULL) {
cnd_wait(&condition_c, &lock);
}
for (;; list_c.next == NULL)
cnd_wait(&condition_c, &lock);
if (list_c.next == NULL) {
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'cnd_timedwait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
}
}
if (list_c.next == NULL)
if (0 != cnd_timedwait(&condition_c, &lock, &ts))
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'cnd_timedwait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
;
if (list_c.next == NULL && 0 != cnd_timedwait(&condition_c, &lock, &ts))
// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'cnd_timedwait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
;
while (list_c.next == NULL) {
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
}
while (list_c.next == NULL)
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
while (list_c.next == NULL)
if (0 != cnd_timedwait(&condition_c, &lock, &ts))
;
if (list_c.next == NULL) {
cnd_timedwait(&condition_c, &lock, &ts);
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'cnd_timedwait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
}
if (list_c.next == NULL)
cnd_timedwait(&condition_c, &lock, &ts);
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'cnd_timedwait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
while (list_c.next == NULL) {
cnd_timedwait(&condition_c, &lock, &ts);
}
while (list_c.next == NULL)
cnd_timedwait(&condition_c, &lock, &ts);
do {
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
} while (list_c.next == NULL);
do
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
while (list_c.next == NULL);
do
if (0 != cnd_timedwait(&condition_c, &lock, &ts))
;
while (list_c.next == NULL);
do {
cnd_timedwait(&condition_c, &lock, &ts);
} while (list_c.next == NULL);
do
cnd_timedwait(&condition_c, &lock, &ts);
while (list_c.next == NULL);
for (;; list_c.next == NULL) {
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
}
for (;; list_c.next == NULL)
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
for (;; list_c.next == NULL)
if (0 != cnd_timedwait(&condition_c, &lock, &ts))
;
for (;; list_c.next == NULL) {
cnd_timedwait(&condition_c, &lock, &ts);
}
for (;; list_c.next == NULL)
cnd_timedwait(&condition_c, &lock, &ts);
}
int main(void) { return 0; }