diff options
author | Kazu Hirata <kazu@google.com> | 2024-01-31 23:54:07 -0800 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2024-01-31 23:54:07 -0800 |
commit | 39fa304866e16f1408a0cab9437e47e4ebacf206 (patch) | |
tree | 371c2aaa830ce6efdbc6e2e101ecb149aa0cfe73 | |
parent | e8512786fedbfa6ddba70ceddc29d7122173ba5e (diff) |
[llvm] Use StringRef::starts_with (NFC)
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/MC/MCContext.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Support/StringRef.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZISelLowering.cpp | 2 | ||||
-rw-r--r-- | llvm/utils/TableGen/CodeGenInstruction.cpp | 2 |
7 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 5828822e062b..03b2a66989bd 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -5547,7 +5547,7 @@ std::pair<unsigned, const TargetRegisterClass *> TargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *RI, StringRef Constraint, MVT VT) const { - if (Constraint.empty() || Constraint[0] != '{') + if (!Constraint.starts_with("{")) return std::make_pair(0u, static_cast<TargetRegisterClass *>(nullptr)); assert(*(Constraint.end() - 1) == '}' && "Not a brace enclosed constraint?"); diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index b0cdd6321a5f..2c5b0b3d0c44 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -479,7 +479,7 @@ static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) { Name == ".llvmbc" || Name == ".llvmcmd") return SectionKind::getMetadata(); - if (Name.empty() || Name[0] != '.') return K; + if (!Name.starts_with(".")) return K; // Default implementation based on some magic section names. if (Name == ".bss" || Name.starts_with(".bss.") || diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index c1db7e3943c4..ba5cefaf18c1 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -397,7 +397,7 @@ MCContext::createXCOFFSymbolImpl(const StringMapEntry<bool> *Name, // If it's an entry point symbol, we will keep the '.' // in front for the convention purpose. Otherwise, add "_Renamed.." // as prefix to signal this is an renamed symbol. - const bool IsEntryPoint = !InvalidName.empty() && InvalidName[0] == '.'; + const bool IsEntryPoint = InvalidName.starts_with("."); SmallString<128> ValidName = StringRef(IsEntryPoint ? "._Renamed.." : "_Renamed.."); diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index cb9eb9183f73..c076ae8b8431 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -422,7 +422,7 @@ void Option::removeArgument() { GlobalParser->removeOption(this); } void Option::setArgStr(StringRef S) { if (FullyInitialized) GlobalParser->updateArgStr(this, S); - assert((S.empty() || S[0] != '-') && "Option can't start with '-"); + assert(!S.starts_with("-") && "Option can't start with '-"); ArgStr = S; if (ArgStr.size() == 1) setMiscFlag(Grouping); diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp index 945ae378eb91..f1042131a89c 100644 --- a/llvm/lib/Support/StringRef.cpp +++ b/llvm/lib/Support/StringRef.cpp @@ -458,7 +458,7 @@ bool llvm::consumeSignedInteger(StringRef &Str, unsigned Radix, unsigned long long ULLVal; // Handle positive strings first. - if (Str.empty() || Str.front() != '-') { + if (!Str.starts_with("-")) { if (consumeUnsignedInteger(Str, Radix, ULLVal) || // Check for value so large it overflows a signed value. (long long)ULLVal < 0) diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp index 19a4e9b0f17c..d92586f7d05d 100644 --- a/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp +++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.cpp @@ -1302,7 +1302,7 @@ SystemZTargetLowering::getRegForInlineAsmConstraint( break; } } - if (Constraint.size() > 0 && Constraint[0] == '{') { + if (Constraint.starts_with("{")) { // A clobber constraint (e.g. ~{f0}) will have MVT::Other which is illegal // to check the size on. diff --git a/llvm/utils/TableGen/CodeGenInstruction.cpp b/llvm/utils/TableGen/CodeGenInstruction.cpp index 8662b6fb52da..5cd89417c002 100644 --- a/llvm/utils/TableGen/CodeGenInstruction.cpp +++ b/llvm/utils/TableGen/CodeGenInstruction.cpp @@ -232,7 +232,7 @@ bool CGIOperandList::hasSubOperandAlias( std::pair<unsigned,unsigned> CGIOperandList::ParseOperandName(StringRef Op, bool AllowWholeOp) { - if (Op.empty() || Op[0] != '$') + if (!Op.starts_with("$")) PrintFatalError(TheDef->getLoc(), TheDef->getName() + ": Illegal operand name: '" + Op + "'"); |