[clang] Use StringRef::consume_front (NFC) (#139472)
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index ba0d87f..40627d6 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -40,8 +40,7 @@ // Skip asm prefix, if any. 'name' is usually taken directly from // the mangled name of the enclosing function. - if (!name.empty() && name[0] == '\01') - name = name.substr(1); + name.consume_front("\01"); } // Anchor the vtable to this translation unit.
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 3513175..2a11eeb 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -4500,8 +4500,7 @@ Flags |= llvm::DINode::FlagPrototyped; } - if (Name.starts_with("\01")) - Name = Name.substr(1); + Name.consume_front("\01"); assert((!D || !isa<VarDecl>(D) || GD.getDynamicInitKind() != DynamicInitKind::NoStub) && @@ -4590,8 +4589,7 @@ } else { llvm_unreachable("not a function or ObjC method"); } - if (!Name.empty() && Name[0] == '\01') - Name = Name.substr(1); + Name.consume_front("\01"); if (D->isImplicit()) { Flags |= llvm::DINode::FlagArtificial;
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 49c2bef..0d03923 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3388,8 +3388,7 @@ auto SL = E->getFunctionName(); assert(SL != nullptr && "No StringLiteral name in PredefinedExpr"); StringRef FnName = CurFn->getName(); - if (FnName.starts_with("\01")) - FnName = FnName.substr(1); + FnName.consume_front("\01"); StringRef NameItems[] = { PredefinedExpr::getIdentKindName(E->getIdentKind()), FnName}; std::string GVName = llvm::join(NameItems, NameItems + 2, ".");
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 3469676..428a4b8 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4061,11 +4061,7 @@ return false; std::string BuiltinNameStr = BI.getName(BuiltinID); StringRef BuiltinName = BuiltinNameStr; - if (BuiltinName.starts_with("__builtin_") && - Name == BuiltinName.slice(strlen("__builtin_"), StringRef::npos)) { - return true; - } - return false; + return BuiltinName.consume_front("__builtin_") && Name == BuiltinName; } bool VisitStmt(const Stmt *S) {