[llvm] [llvm] Use StringRef::contains (NFC) (PR #165397)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 28 07:10:47 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/165397
Identified with readability-container-contains
>From c5ee112a4a2bf4a9e3cd320ca2e1875479315862 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 26 Oct 2025 22:52:36 -0700
Subject: [PATCH] [llvm] Use StringRef::contains (NFC)
Identified with readability-container-contains
---
llvm/include/llvm/IR/Mangler.h | 3 +--
llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp | 2 +-
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp | 3 +--
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/llvm/include/llvm/IR/Mangler.h b/llvm/include/llvm/IR/Mangler.h
index 232101a8926b7..4d387ba73127d 100644
--- a/llvm/include/llvm/IR/Mangler.h
+++ b/llvm/include/llvm/IR/Mangler.h
@@ -80,8 +80,7 @@ getArm64ECDemangledFunctionName(StringRef Name);
/// Check if an ARM64EC function name is mangled.
bool inline isArm64ECMangledFunctionName(StringRef Name) {
- return Name[0] == '#' ||
- (Name[0] == '?' && Name.find("@$$h") != StringRef::npos);
+ return Name[0] == '#' || (Name[0] == '?' && Name.contains("@$$h"));
}
} // End llvm namespace
diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
index 4029e143ae2a4..729c077884f3a 100644
--- a/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
@@ -493,7 +493,7 @@ NVPTXTTIImpl::getInstructionCost(const User *U,
// predicate ("@").
return !AsmInst.empty() &&
(AsmInst[0] == '@' || isAlpha(AsmInst[0]) ||
- AsmInst.find(".pragma") != StringRef::npos);
+ AsmInst.contains(".pragma"));
});
return InstCount * TargetTransformInfo::TCC_Basic;
}
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
index 3da720f54e6ab..58109acc92015 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -8973,8 +8973,7 @@ SystemZTargetLowering::getJumpConditionMergingParams(Instruction::BinaryOps Opc,
if (const auto *CB = dyn_cast<CallBase>(RHSVal)) {
if (CB->isInlineAsm()) {
const InlineAsm *IA = cast<InlineAsm>(CB->getCalledOperand());
- return IA &&
- IA->getConstraintString().find("{@cc}") != std::string::npos;
+ return IA && IA->getConstraintString().contains("{@cc}");
}
}
}
More information about the llvm-commits
mailing list