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
149 lines
6.4 KiB
C
149 lines
6.4 KiB
C
// RUN: %check_clang_tidy %s android-comparison-in-temp-failure-retry %t
|
|
|
|
#define TEMP_FAILURE_RETRY(x) \
|
|
({ \
|
|
__typeof__(x) __z; \
|
|
do \
|
|
__z = (x); \
|
|
while (__z == -1); \
|
|
__z; \
|
|
})
|
|
|
|
int foo(void);
|
|
int bar(int a);
|
|
|
|
void test(void) {
|
|
int i;
|
|
TEMP_FAILURE_RETRY((i = foo()));
|
|
TEMP_FAILURE_RETRY(foo());
|
|
TEMP_FAILURE_RETRY((foo()));
|
|
|
|
TEMP_FAILURE_RETRY(foo() == 1);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: top-level comparison in TEMP_FAILURE_RETRY [android-comparison-in-temp-failure-retry]
|
|
TEMP_FAILURE_RETRY((foo() == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
TEMP_FAILURE_RETRY((int)(foo() == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
|
|
TEMP_FAILURE_RETRY(bar(foo() == 1));
|
|
TEMP_FAILURE_RETRY((bar(foo() == 1)));
|
|
TEMP_FAILURE_RETRY((bar(foo() == 1)) == 1);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
TEMP_FAILURE_RETRY(((bar(foo() == 1)) == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:41: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
TEMP_FAILURE_RETRY((int)((bar(foo() == 1)) == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
|
|
#define INDIRECT TEMP_FAILURE_RETRY
|
|
INDIRECT(foo());
|
|
INDIRECT((foo() == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
INDIRECT(bar(foo() == 1));
|
|
INDIRECT((int)((bar(foo() == 1)) == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
|
|
#define TFR(x) TEMP_FAILURE_RETRY(x)
|
|
TFR(foo());
|
|
TFR((foo() == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
TFR(bar(foo() == 1));
|
|
TFR((int)((bar(foo() == 1)) == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
|
|
#define ADD_TFR(x) (1 + TEMP_FAILURE_RETRY(x) + 1)
|
|
ADD_TFR(foo());
|
|
ADD_TFR(foo() == 1);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
|
|
ADD_TFR(bar(foo() == 1));
|
|
ADD_TFR((int)((bar(foo() == 1)) == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
|
|
#define ADDP_TFR(x) (1 + TEMP_FAILURE_RETRY((x)) + 1)
|
|
ADDP_TFR(foo());
|
|
ADDP_TFR((foo() == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
|
|
ADDP_TFR(bar(foo() == 1));
|
|
ADDP_TFR((int)((bar(foo() == 1)) == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
|
|
#define MACRO TEMP_FAILURE_RETRY(foo() == 1)
|
|
MACRO;
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
|
|
// Be sure that being a macro arg doesn't mess with this.
|
|
#define ID(x) (x)
|
|
ID(ADDP_TFR(bar(foo() == 1)));
|
|
ID(ADDP_TFR(bar(foo() == 1) == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
ID(MACRO);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
|
|
#define CMP(x) x == 1
|
|
TEMP_FAILURE_RETRY(CMP(foo()));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
}
|
|
|
|
// Be sure that it works inside of things like loops, if statements, etc.
|
|
void control_flow(void) {
|
|
do {
|
|
if (TEMP_FAILURE_RETRY(foo())) {
|
|
}
|
|
|
|
if (TEMP_FAILURE_RETRY(foo() == 1)) {
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
}
|
|
|
|
if (TEMP_FAILURE_RETRY(bar(foo() == 1))) {
|
|
}
|
|
|
|
if (TEMP_FAILURE_RETRY(bar(foo() == 1) == 1)) {
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
}
|
|
} while (TEMP_FAILURE_RETRY(foo() == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
}
|
|
|
|
void with_nondependent_variable_type(void) {
|
|
#undef TEMP_FAILURE_RETRY
|
|
#define TEMP_FAILURE_RETRY(x) \
|
|
({ \
|
|
long int __z; \
|
|
do \
|
|
__z = (x); \
|
|
while (__z == -1); \
|
|
__z; \
|
|
})
|
|
|
|
TEMP_FAILURE_RETRY((foo()));
|
|
TEMP_FAILURE_RETRY((int)(foo() == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
TEMP_FAILURE_RETRY((bar(foo() == 1)));
|
|
TEMP_FAILURE_RETRY((int)((bar(foo() == 1)) == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
}
|
|
|
|
// I can't find a case where TEMP_FAILURE_RETRY is implemented like this, but if
|
|
// we can cheaply support it, I don't see why not.
|
|
void obscured_temp_failure_retry(void) {
|
|
#undef TEMP_FAILURE_RETRY
|
|
#define IMPL(x) \
|
|
({ \
|
|
__typeof__(x) __z; \
|
|
do \
|
|
__z = (x); \
|
|
while (__z == -1); \
|
|
__z; \
|
|
})
|
|
|
|
#define IMPL2(x) IMPL(x)
|
|
#define TEMP_FAILURE_RETRY(x) IMPL2(x)
|
|
TEMP_FAILURE_RETRY((foo()));
|
|
TEMP_FAILURE_RETRY((int)(foo() == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
TEMP_FAILURE_RETRY((bar(foo() == 1)));
|
|
TEMP_FAILURE_RETRY((int)((bar(foo() == 1)) == 1));
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: top-level comparison in TEMP_FAILURE_RETRY
|
|
}
|