[clang-tools-extra] [NFC][clang-tidy] Fix potential constant overflow (PR #162647)
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 9 05:45:46 PDT 2025
https://github.com/zahiraam created https://github.com/llvm/llvm-project/pull/162647
None
>From 1d564a71e2db68ba371dbd1c91e51d1c4d038322 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat <zahira.ammarguellat at intel.com>
Date: Thu, 9 Oct 2025 05:45:01 -0700
Subject: [PATCH] [NFC][clang-tidy] Fix potential constant overflow
---
.../clang-tidy/objc/PropertyDeclarationCheck.cpp | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
index f2bc6f10b9c58..4a586c8ff0ac9 100644
--- a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -39,8 +39,11 @@ static FixItHint generateFixItHint(const ObjCPropertyDecl *Decl,
auto NewName = Decl->getName().str();
size_t Index = 0;
if (Style == CategoryProperty) {
- Index = Name.find_first_of('_') + 1;
- NewName.replace(0, Index - 1, Name.substr(0, Index - 1).lower());
+ size_t UnderScorePos = Name.find_first_of('_');
+ if (UnderScorePos != llvm::StringRef::npos) {
+ Index = UnderScorePos + 1;
+ NewName.replace(0, Index - 1, Name.substr(0, Index - 1).lower());
+ }
}
if (Index < Name.size()) {
NewName[Index] = tolower(NewName[Index]);
More information about the cfe-commits
mailing list