[clang] [Clang][AMDGPU] Use size_t to compare with npos (PR #132868)
Jinsong Ji via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 24 19:57:33 PDT 2025
https://github.com/jsji created https://github.com/llvm/llvm-project/pull/132868
Fix error
llvm\clang\tools\amdgpu-arch\AMDGPUArchByHIP.cpp(102,29): error: result of comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
102 | StringRef VerStr = (Pos == StringRef::npos) ? S : S.substr(Pos + 1);
>From 61cc5cd77b1e890743ad0c479e61c05112c60f90 Mon Sep 17 00:00:00 2001
From: Jinsong Ji <jinsong.ji at intel.com>
Date: Mon, 24 Mar 2025 19:53:12 -0700
Subject: [PATCH] Use size_t to compare with npos
Fix error
llvm\clang\tools\amdgpu-arch\AMDGPUArchByHIP.cpp(102,29): error: result of comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
102 | StringRef VerStr = (Pos == StringRef::npos) ? S : S.substr(Pos + 1);
---
clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp b/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
index 4803f83f55ac7..02431bf909d6d 100644
--- a/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
+++ b/clang/tools/amdgpu-arch/AMDGPUArchByHIP.cpp
@@ -98,7 +98,7 @@ static std::vector<std::string> getSearchPaths() {
// Custom comparison function for dll name
static bool compareVersions(StringRef A, StringRef B) {
auto ParseVersion = [](StringRef S) -> VersionTuple {
- unsigned Pos = S.find_last_of('_');
+ size_t Pos = S.find_last_of('_');
StringRef VerStr = (Pos == StringRef::npos) ? S : S.substr(Pos + 1);
VersionTuple Vt;
(void)Vt.tryParse(VerStr);
More information about the cfe-commits
mailing list