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
129 lines
4.4 KiB
C++
129 lines
4.4 KiB
C++
// RUN: %check_clang_tidy -std=c++20-or-later %s modernize-use-integer-sign-comparison %t
|
|
|
|
// CHECK-FIXES: #include <utility>
|
|
|
|
// The code that triggers the check
|
|
#define MAX_MACRO(a, b) (a < b) ? b : a
|
|
|
|
unsigned int FuncParameters(int bla) {
|
|
unsigned int result = 0;
|
|
if (result == bla)
|
|
return 0;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: if (std::cmp_equal(result , bla))
|
|
|
|
return 1;
|
|
}
|
|
|
|
template <typename T>
|
|
void TemplateFuncParameter(T val) {
|
|
unsigned long uL = 0;
|
|
if (val >= uL)
|
|
return;
|
|
// CHECK-MESSAGES-NOT: warning:
|
|
}
|
|
|
|
template <typename T1, typename T2>
|
|
int TemplateFuncParameters(T1 val1, T2 val2) {
|
|
if (val1 >= val2)
|
|
return 0;
|
|
// CHECK-MESSAGES-NOT: warning:
|
|
return 1;
|
|
}
|
|
|
|
int AllComparisons() {
|
|
unsigned int uVar = 42;
|
|
unsigned short uArray[7] = {0, 1, 2, 3, 9, 7, 9};
|
|
|
|
int sVar = -42;
|
|
short sArray[7] = {-1, -2, -8, -94, -5, -4, -6};
|
|
|
|
enum INT_TEST {
|
|
VAL1 = 0,
|
|
VAL2 = -1
|
|
};
|
|
|
|
char ch = 'a';
|
|
unsigned char uCh = 'a';
|
|
signed char sCh = 'a';
|
|
bool bln = false;
|
|
|
|
if (bln == sVar)
|
|
return 0;
|
|
// CHECK-MESSAGES-NOT: warning:
|
|
|
|
if (ch > uCh)
|
|
return 0;
|
|
// CHECK-MESSAGES-NOT: warning:
|
|
|
|
if (sVar <= INT_TEST::VAL2)
|
|
return 0;
|
|
// CHECK-MESSAGES-NOT: warning:
|
|
|
|
if (uCh < sCh)
|
|
return -1;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: if (std::cmp_less(uCh , sCh))
|
|
|
|
if ((int)uVar < sVar)
|
|
return 0;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: if (std::cmp_less(uVar, sVar))
|
|
|
|
(uVar != sVar) ? uVar = sVar
|
|
: sVar = uVar;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:6: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: (std::cmp_not_equal(uVar , sVar)) ? uVar = sVar
|
|
|
|
while (uArray[0] <= sArray[0])
|
|
return 0;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:12: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: while (std::cmp_less_equal(uArray[0] , sArray[0]))
|
|
|
|
if (uArray[1] > sArray[1])
|
|
return 0;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: if (std::cmp_greater(uArray[1] , sArray[1]))
|
|
|
|
MAX_MACRO(uVar, sArray[0]);
|
|
// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
|
|
if (static_cast<unsigned int>(uArray[2]) < static_cast<int>(sArray[2]))
|
|
return 0;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: if (std::cmp_less(uArray[2],sArray[2]))
|
|
|
|
if ((unsigned int)uArray[3] < (int)sArray[3])
|
|
return 0;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: if (std::cmp_less(uArray[3],sArray[3]))
|
|
|
|
if ((unsigned int)(uArray[4]) < (int)(sArray[4]))
|
|
return 0;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: if (std::cmp_less((uArray[4]),(sArray[4])))
|
|
|
|
if (uArray[5] > sArray[5])
|
|
return 0;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: if (std::cmp_greater(uArray[5] , sArray[5]))
|
|
|
|
#define VALUE sArray[6]
|
|
if (uArray[6] > VALUE)
|
|
return 0;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: if (std::cmp_greater(uArray[6] , VALUE))
|
|
|
|
if (unsigned(uArray[7]) >= int(sArray[7]))
|
|
return 0;
|
|
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
|
|
// CHECK-FIXES: if (std::cmp_greater_equal(uArray[7],sArray[7]))
|
|
|
|
|
|
FuncParameters(uVar);
|
|
TemplateFuncParameter(sVar);
|
|
TemplateFuncParameters(uVar, sVar);
|
|
|
|
return 0;
|
|
}
|