Skip to content

Commit 39fa304

Browse files
[llvm] Use StringRef::starts_with (NFC)
1 parent e851278 commit 39fa304

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5547,7 +5547,7 @@ std::pair<unsigned, const TargetRegisterClass *>
55475547
TargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *RI,
55485548
StringRef Constraint,
55495549
MVT VT) const {
5550-
if (Constraint.empty() || Constraint[0] != '{')
5550+
if (!Constraint.starts_with("{"))
55515551
return std::make_pair(0u, static_cast<TargetRegisterClass *>(nullptr));
55525552
assert(*(Constraint.end() - 1) == '}' && "Not a brace enclosed constraint?");
55535553

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) {
479479
Name == ".llvmbc" || Name == ".llvmcmd")
480480
return SectionKind::getMetadata();
481481

482-
if (Name.empty() || Name[0] != '.') return K;
482+
if (!Name.starts_with(".")) return K;
483483

484484
// Default implementation based on some magic section names.
485485
if (Name == ".bss" || Name.starts_with(".bss.") ||

llvm/lib/MC/MCContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ MCContext::createXCOFFSymbolImpl(const StringMapEntry<bool> *Name,
397397
// If it's an entry point symbol, we will keep the '.'
398398
// in front for the convention purpose. Otherwise, add "_Renamed.."
399399
// as prefix to signal this is an renamed symbol.
400-
const bool IsEntryPoint = !InvalidName.empty() && InvalidName[0] == '.';
400+
const bool IsEntryPoint = InvalidName.starts_with(".");
401401
SmallString<128> ValidName =
402402
StringRef(IsEntryPoint ? "._Renamed.." : "_Renamed..");
403403

llvm/lib/Support/CommandLine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void Option::removeArgument() { GlobalParser->removeOption(this); }
422422
void Option::setArgStr(StringRef S) {
423423
if (FullyInitialized)
424424
GlobalParser->updateArgStr(this, S);
425-
assert((S.empty() || S[0] != '-') && "Option can't start with '-");
425+
assert(!S.starts_with("-") && "Option can't start with '-");
426426
ArgStr = S;
427427
if (ArgStr.size() == 1)
428428
setMiscFlag(Grouping);

llvm/lib/Support/StringRef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ bool llvm::consumeSignedInteger(StringRef &Str, unsigned Radix,
458458
unsigned long long ULLVal;
459459

460460
// Handle positive strings first.
461-
if (Str.empty() || Str.front() != '-') {
461+
if (!Str.starts_with("-")) {
462462
if (consumeUnsignedInteger(Str, Radix, ULLVal) ||
463463
// Check for value so large it overflows a signed value.
464464
(long long)ULLVal < 0)

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ SystemZTargetLowering::getRegForInlineAsmConstraint(
13021302
break;
13031303
}
13041304
}
1305-
if (Constraint.size() > 0 && Constraint[0] == '{') {
1305+
if (Constraint.starts_with("{")) {
13061306

13071307
// A clobber constraint (e.g. ~{f0}) will have MVT::Other which is illegal
13081308
// to check the size on.

llvm/utils/TableGen/CodeGenInstruction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ bool CGIOperandList::hasSubOperandAlias(
232232

233233
std::pair<unsigned,unsigned>
234234
CGIOperandList::ParseOperandName(StringRef Op, bool AllowWholeOp) {
235-
if (Op.empty() || Op[0] != '$')
235+
if (!Op.starts_with("$"))
236236
PrintFatalError(TheDef->getLoc(),
237237
TheDef->getName() + ": Illegal operand name: '" + Op + "'");
238238

0 commit comments

Comments
 (0)