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
95 lines
2.4 KiB
C
95 lines
2.4 KiB
C
// RUN: %check_clang_tidy -std=c23-or-later %s readability-implicit-bool-conversion %t -- \
|
|
// RUN: -config='{CheckOptions: { \
|
|
// RUN: readability-implicit-bool-conversion.AllowLogicalOperatorConversion: true \
|
|
// RUN: }}'
|
|
|
|
void function_taking_bool(bool);
|
|
bool returns_bool(void);
|
|
int returns_int(void);
|
|
|
|
void logical_or_to_bool(void) {
|
|
bool a = true, b = false;
|
|
bool c = a || b;
|
|
bool d = returns_bool() || returns_bool();
|
|
bool e = returns_bool() || (a && b);
|
|
}
|
|
|
|
void logical_and_to_bool(void) {
|
|
bool a = true, b = false;
|
|
bool c = a && b;
|
|
bool d = returns_bool() && returns_bool();
|
|
}
|
|
|
|
void logical_not_to_bool(void) {
|
|
bool a = true;
|
|
int x = 5;
|
|
bool b = !a;
|
|
bool c = !x;
|
|
}
|
|
|
|
void logical_with_literals(void) {
|
|
bool a = true, b = false;
|
|
bool c = true || b;
|
|
bool d = false || b;
|
|
bool e = a || true;
|
|
bool f = false || (a || b);
|
|
}
|
|
|
|
void nested_logical_ops(void) {
|
|
bool a = true, b = false, c = true;
|
|
bool d = (a && b) || c;
|
|
bool e = a || (b && c);
|
|
bool f = !(a || b);
|
|
}
|
|
|
|
void logical_in_function_call(void) {
|
|
bool a = true, b = false;
|
|
function_taking_bool(a || b);
|
|
function_taking_bool(a && b);
|
|
function_taking_bool(!a);
|
|
}
|
|
|
|
bool logical_in_return(void) {
|
|
bool a = true, b = false;
|
|
return a || b;
|
|
}
|
|
|
|
void still_warn_on_regular_int_to_bool(void) {
|
|
int x = 42;
|
|
bool b = x;
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
|
|
// CHECK-FIXES: bool b = x != 0;
|
|
|
|
bool c = x + 1;
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion 'int' -> 'bool'
|
|
// CHECK-FIXES: bool c = (x + 1) != 0;
|
|
|
|
bool d = returns_int();
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion 'int' -> 'bool'
|
|
// CHECK-FIXES: bool d = returns_int() != 0;
|
|
}
|
|
|
|
void still_warn_on_bitwise_ops(void) {
|
|
int x = 5, y = 3;
|
|
bool b = x | y;
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion 'int' -> 'bool'
|
|
// CHECK-FIXES: bool b = (x | y) != 0;
|
|
|
|
bool c = x & y;
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: implicit conversion 'int' -> 'bool'
|
|
// CHECK-FIXES: bool c = (x & y) != 0;
|
|
}
|
|
|
|
void cast_from_bool_still_warns(void) {
|
|
bool a = true;
|
|
int x = a;
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: implicit conversion 'bool' -> 'int'
|
|
// CHECK-FIXES: int x = (int)a;
|
|
}
|
|
|
|
void comparison_still_excluded(void) {
|
|
bool b1 = 1 > 0;
|
|
bool b2 = 1 == 0;
|
|
bool b3 = 1 < 2;
|
|
}
|