diff --git a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp --- a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp @@ -91,8 +91,8 @@ return L.empty() || R.empty() || L == R; // We allow two names if one is a prefix/suffix of the other, ignoring case. // Important special case: this is true if either parameter has no name! - return L.startswith_insensitive(R) || R.startswith_insensitive(L) || - L.endswith_insensitive(R) || R.endswith_insensitive(L); + return L.starts_with_insensitive(R) || R.starts_with_insensitive(L) || + L.ends_with_insensitive(R) || R.ends_with_insensitive(L); } DifferingParamsContainer diff --git a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp --- a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp @@ -154,7 +154,7 @@ StringRef Shorter = Arg.size() < Param.size() ? Arg : Param; StringRef Longer = Arg.size() >= Param.size() ? Arg : Param; - if (Longer.startswith_insensitive(Shorter)) + if (Longer.starts_with_insensitive(Shorter)) return percentage(Shorter.size(), Longer.size()) > Threshold; return false; @@ -166,7 +166,7 @@ StringRef Shorter = Arg.size() < Param.size() ? Arg : Param; StringRef Longer = Arg.size() >= Param.size() ? Arg : Param; - if (Longer.endswith_insensitive(Shorter)) + if (Longer.ends_with_insensitive(Shorter)) return percentage(Shorter.size(), Longer.size()) > Threshold; return false; diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp --- a/clang-tools-extra/clangd/CodeComplete.cpp +++ b/clang-tools-extra/clangd/CodeComplete.cpp @@ -1884,7 +1884,7 @@ C.SemaResult->Kind == CodeCompletionResult::RK_Macro) || (C.IndexResult && C.IndexResult->SymInfo.Kind == index::SymbolKind::Macro)) && - !C.Name.startswith_insensitive(Filter->pattern())) + !C.Name.starts_with_insensitive(Filter->pattern())) return std::nullopt; return Filter->match(C.Name); } diff --git a/clang-tools-extra/clangd/CompileCommands.cpp b/clang-tools-extra/clangd/CompileCommands.cpp --- a/clang-tools-extra/clangd/CompileCommands.cpp +++ b/clang-tools-extra/clangd/CompileCommands.cpp @@ -422,9 +422,9 @@ DriverMode getDriverMode(const std::vector &Args) { DriverMode Mode = DM_GCC; llvm::StringRef Argv0 = Args.front(); - if (Argv0.endswith_insensitive(".exe")) + if (Argv0.ends_with_insensitive(".exe")) Argv0 = Argv0.drop_back(strlen(".exe")); - if (Argv0.endswith_insensitive("cl")) + if (Argv0.ends_with_insensitive("cl")) Mode = DM_CL; for (const llvm::StringRef Arg : Args) { if (Arg == "--driver-mode=cl") { diff --git a/clang-tools-extra/clangd/InlayHints.cpp b/clang-tools-extra/clangd/InlayHints.cpp --- a/clang-tools-extra/clangd/InlayHints.cpp +++ b/clang-tools-extra/clangd/InlayHints.cpp @@ -430,7 +430,7 @@ return false; StringRef Name = getSimpleName(*Callee); - if (!Name.startswith_insensitive("set")) + if (!Name.starts_with_insensitive("set")) return false; // In addition to checking that the function has one parameter and its diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp b/clang/lib/Analysis/RetainSummaryManager.cpp --- a/clang/lib/Analysis/RetainSummaryManager.cpp +++ b/clang/lib/Analysis/RetainSummaryManager.cpp @@ -190,18 +190,18 @@ } static bool isRetain(const FunctionDecl *FD, StringRef FName) { - return FName.startswith_insensitive("retain") || - FName.endswith_insensitive("retain"); + return FName.starts_with_insensitive("retain") || + FName.ends_with_insensitive("retain"); } static bool isRelease(const FunctionDecl *FD, StringRef FName) { - return FName.startswith_insensitive("release") || - FName.endswith_insensitive("release"); + return FName.starts_with_insensitive("release") || + FName.ends_with_insensitive("release"); } static bool isAutorelease(const FunctionDecl *FD, StringRef FName) { - return FName.startswith_insensitive("autorelease") || - FName.endswith_insensitive("autorelease"); + return FName.starts_with_insensitive("autorelease") || + FName.ends_with_insensitive("autorelease"); } static bool isMakeCollectable(StringRef FName) { diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -2670,7 +2670,7 @@ bool Quote = Lib.contains(' '); std::string ArgStr = Quote ? "\"" : ""; ArgStr += Lib; - if (!Lib.endswith_insensitive(".lib") && !Lib.endswith_insensitive(".a")) + if (!Lib.ends_with_insensitive(".lib") && !Lib.ends_with_insensitive(".a")) ArgStr += ".lib"; ArgStr += Quote ? "\"" : ""; return ArgStr; diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -693,9 +693,9 @@ if (Args.hasArg(options::OPT_march_EQ) || Args.hasArg(options::OPT_mcpu_EQ)) { StringRef ArchName = tools::riscv::getRISCVArch(Args, Target); - if (ArchName.startswith_insensitive("rv32")) + if (ArchName.starts_with_insensitive("rv32")) Target.setArch(llvm::Triple::riscv32); - else if (ArchName.startswith_insensitive("rv64")) + else if (ArchName.starts_with_insensitive("rv64")) Target.setArch(llvm::Triple::riscv64); } } @@ -6166,7 +6166,7 @@ case llvm::Triple::MSVC: case llvm::Triple::UnknownEnvironment: if (Args.getLastArgValue(options::OPT_fuse_ld_EQ) - .startswith_insensitive("bfd")) + .starts_with_insensitive("bfd")) TC = std::make_unique( *this, Target, Args); else diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp --- a/clang/lib/Driver/OffloadBundler.cpp +++ b/clang/lib/Driver/OffloadBundler.cpp @@ -106,11 +106,11 @@ if (OffloadKind == TargetOffloadKind) return true; if (BundlerConfig.HipOpenmpCompatible) { - bool HIPCompatibleWithOpenMP = OffloadKind.startswith_insensitive("hip") && + bool HIPCompatibleWithOpenMP = OffloadKind.starts_with_insensitive("hip") && TargetOffloadKind == "openmp"; bool OpenMPCompatibleWithHIP = OffloadKind == "openmp" && - TargetOffloadKind.startswith_insensitive("hip"); + TargetOffloadKind.starts_with_insensitive("hip"); return HIPCompatibleWithOpenMP || OpenMPCompatibleWithHIP; } return false; diff --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp --- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp +++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp @@ -290,9 +290,9 @@ if (MABI.equals_insensitive("ilp32e")) return "rv32e"; - else if (MABI.startswith_insensitive("ilp32")) + else if (MABI.starts_with_insensitive("ilp32")) return "rv32imafdc"; - else if (MABI.startswith_insensitive("lp64")) + else if (MABI.starts_with_insensitive("lp64")) return "rv64imafdc"; } diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -8252,7 +8252,7 @@ // Extract GPUArch from -march argument in TC argument list. for (unsigned ArgIndex = 0; ArgIndex < TCArgs.size(); ArgIndex++) { auto ArchStr = StringRef(TCArgs.getArgString(ArgIndex)); - auto Arch = ArchStr.startswith_insensitive("-march="); + auto Arch = ArchStr.starts_with_insensitive("-march="); if (Arch) { GPUArchName = ArchStr.substr(7); Triples += "-"; @@ -8345,7 +8345,7 @@ // Extract GPUArch from -march argument in TC argument list. for (unsigned ArgIndex = 0; ArgIndex < TCArgs.size(); ArgIndex++) { StringRef ArchStr = StringRef(TCArgs.getArgString(ArgIndex)); - auto Arch = ArchStr.startswith_insensitive("-march="); + auto Arch = ArchStr.starts_with_insensitive("-march="); if (Arch) { GPUArchName = ArchStr.substr(7); Triples += "-"; diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -3680,33 +3680,33 @@ static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) { if (FileName.endswith(".java")) return FormatStyle::LK_Java; - if (FileName.endswith_insensitive(".js") || - FileName.endswith_insensitive(".mjs") || - FileName.endswith_insensitive(".ts")) { + if (FileName.ends_with_insensitive(".js") || + FileName.ends_with_insensitive(".mjs") || + FileName.ends_with_insensitive(".ts")) { return FormatStyle::LK_JavaScript; // (module) JavaScript or TypeScript. } if (FileName.endswith(".m") || FileName.endswith(".mm")) return FormatStyle::LK_ObjC; - if (FileName.endswith_insensitive(".proto") || - FileName.endswith_insensitive(".protodevel")) { + if (FileName.ends_with_insensitive(".proto") || + FileName.ends_with_insensitive(".protodevel")) { return FormatStyle::LK_Proto; } - if (FileName.endswith_insensitive(".textpb") || - FileName.endswith_insensitive(".pb.txt") || - FileName.endswith_insensitive(".textproto") || - FileName.endswith_insensitive(".asciipb")) { + if (FileName.ends_with_insensitive(".textpb") || + FileName.ends_with_insensitive(".pb.txt") || + FileName.ends_with_insensitive(".textproto") || + FileName.ends_with_insensitive(".asciipb")) { return FormatStyle::LK_TextProto; } - if (FileName.endswith_insensitive(".td")) + if (FileName.ends_with_insensitive(".td")) return FormatStyle::LK_TableGen; - if (FileName.endswith_insensitive(".cs")) + if (FileName.ends_with_insensitive(".cs")) return FormatStyle::LK_CSharp; - if (FileName.endswith_insensitive(".json")) + if (FileName.ends_with_insensitive(".json")) return FormatStyle::LK_Json; - if (FileName.endswith_insensitive(".sv") || - FileName.endswith_insensitive(".svh") || - FileName.endswith_insensitive(".v") || - FileName.endswith_insensitive(".vh")) { + if (FileName.ends_with_insensitive(".sv") || + FileName.ends_with_insensitive(".svh") || + FileName.ends_with_insensitive(".v") || + FileName.ends_with_insensitive(".vh")) { return FormatStyle::LK_Verilog; } return FormatStyle::LK_Cpp; @@ -3780,7 +3780,7 @@ // User provided clang-format file using -style=file:path/to/format/file. if (!Style.InheritsParentConfig && - StyleName.startswith_insensitive("file:")) { + StyleName.starts_with_insensitive("file:")) { auto ConfigFile = StyleName.substr(5); llvm::ErrorOr> Text = loadAndParseConfigFile(ConfigFile, FS, &Style, AllowUnknownOptions); diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -8490,18 +8490,18 @@ bool ValidString = true; if (IsARMBuiltin) { - ValidString &= Fields[0].startswith_insensitive("cp") || - Fields[0].startswith_insensitive("p"); + ValidString &= Fields[0].starts_with_insensitive("cp") || + Fields[0].starts_with_insensitive("p"); if (ValidString) Fields[0] = Fields[0].drop_front( - Fields[0].startswith_insensitive("cp") ? 2 : 1); + Fields[0].starts_with_insensitive("cp") ? 2 : 1); - ValidString &= Fields[2].startswith_insensitive("c"); + ValidString &= Fields[2].starts_with_insensitive("c"); if (ValidString) Fields[2] = Fields[2].drop_front(1); if (FiveFields) { - ValidString &= Fields[3].startswith_insensitive("c"); + ValidString &= Fields[3].starts_with_insensitive("c"); if (ValidString) Fields[3] = Fields[3].drop_front(1); } diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -10030,11 +10030,11 @@ break; case llvm::sys::fs::file_type::regular_file: { // Only files that really look like headers. (Except in special dirs). - const bool IsHeader = Filename.endswith_insensitive(".h") || - Filename.endswith_insensitive(".hh") || - Filename.endswith_insensitive(".hpp") || - Filename.endswith_insensitive(".hxx") || - Filename.endswith_insensitive(".inc") || + const bool IsHeader = Filename.ends_with_insensitive(".h") || + Filename.ends_with_insensitive(".hh") || + Filename.ends_with_insensitive(".hpp") || + Filename.ends_with_insensitive(".hxx") || + Filename.ends_with_insensitive(".inc") || (ExtensionlessHeaders && !Filename.contains('.')); if (!IsHeader) break; diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp --- a/clang/lib/Sema/SemaOpenMP.cpp +++ b/clang/lib/Sema/SemaOpenMP.cpp @@ -7262,7 +7262,7 @@ return Call; if (LangOpts.OpenMP >= 51 && CalleeFnDecl->getIdentifier() && - CalleeFnDecl->getName().startswith_insensitive("omp_")) { + CalleeFnDecl->getName().starts_with_insensitive("omp_")) { // checking for any calls inside an Order region if (Scope && Scope->isOpenMPOrderClauseScope()) Diag(LParenLoc, diag::err_omp_unexpected_call_to_omp_runtime_api); diff --git a/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp b/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp --- a/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp @@ -749,14 +749,14 @@ const auto *IdInfo = Func->getIdentifier(); if (!IdInfo) return false; - return IdInfo->getName().endswith_insensitive("begin"); + return IdInfo->getName().ends_with_insensitive("begin"); } bool isEndCall(const FunctionDecl *Func) { const auto *IdInfo = Func->getIdentifier(); if (!IdInfo) return false; - return IdInfo->getName().endswith_insensitive("end"); + return IdInfo->getName().ends_with_insensitive("end"); } const CXXRecordDecl *getCXXRecordDecl(ProgramStateRef State, diff --git a/clang/lib/StaticAnalyzer/Checkers/Iterator.cpp b/clang/lib/StaticAnalyzer/Checkers/Iterator.cpp --- a/clang/lib/StaticAnalyzer/Checkers/Iterator.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/Iterator.cpp @@ -29,8 +29,8 @@ return false; const auto Name = CRD->getName(); - if (!(Name.endswith_insensitive("iterator") || - Name.endswith_insensitive("iter") || Name.endswith_insensitive("it"))) + if (!(Name.ends_with_insensitive("iterator") || + Name.ends_with_insensitive("iter") || Name.ends_with_insensitive("it"))) return false; bool HasCopyCtor = false, HasCopyAssign = true, HasDtor = false, diff --git a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp --- a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp +++ b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp @@ -253,7 +253,7 @@ // 1) foo.h => bar.cc // 2) foo.proto.h => foo.cc StringRef Matching; - if (MatchingFileStem.startswith_insensitive(HeaderStem)) + if (MatchingFileStem.starts_with_insensitive(HeaderStem)) Matching = MatchingFileStem; // example 1), 2) else if (FileStem.equals_insensitive(HeaderStem)) Matching = FileStem; // example 3) diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -230,7 +230,7 @@ ctx.symtab.addFile(make(ctx, mbref)); break; } - if (filename.endswith_insensitive(".dll")) { + if (filename.ends_with_insensitive(".dll")) { error(filename + ": bad file type. Did you specify a DLL instead of an " "import library?"); break; @@ -503,7 +503,7 @@ return std::nullopt; } - if (path.endswith_insensitive(".lib")) + if (path.ends_with_insensitive(".lib")) visitedLibs.insert(std::string(sys::path::filename(path).lower())); return path; } diff --git a/lld/COFF/DriverUtils.cpp b/lld/COFF/DriverUtils.cpp --- a/lld/COFF/DriverUtils.cpp +++ b/lld/COFF/DriverUtils.cpp @@ -270,13 +270,13 @@ ctx.config.manifest = Configuration::No; return; } - if (!arg.startswith_insensitive("embed")) + if (!arg.starts_with_insensitive("embed")) fatal("invalid option " + arg); ctx.config.manifest = Configuration::Embed; arg = arg.substr(strlen("embed")); if (arg.empty()) return; - if (!arg.startswith_insensitive(",id=")) + if (!arg.starts_with_insensitive(",id=")) fatal("invalid option " + arg); arg = arg.substr(strlen(",id=")); if (arg.getAsInteger(0, ctx.config.manifestID)) @@ -294,12 +294,12 @@ arg = arg.ltrim(); if (arg.empty()) return; - if (arg.startswith_insensitive("level=")) { + if (arg.starts_with_insensitive("level=")) { arg = arg.substr(strlen("level=")); std::tie(ctx.config.manifestLevel, arg) = arg.split(" "); continue; } - if (arg.startswith_insensitive("uiaccess=")) { + if (arg.starts_with_insensitive("uiaccess=")) { arg = arg.substr(strlen("uiaccess=")); std::tie(ctx.config.manifestUIAccess, arg) = arg.split(" "); continue; @@ -904,14 +904,14 @@ SmallVector tokens; cl::TokenizeWindowsCommandLineNoCopy(s, saver(), tokens); for (StringRef tok : tokens) { - if (tok.startswith_insensitive("/export:") || - tok.startswith_insensitive("-export:")) + if (tok.starts_with_insensitive("/export:") || + tok.starts_with_insensitive("-export:")) result.exports.push_back(tok.substr(strlen("/export:"))); - else if (tok.startswith_insensitive("/include:") || - tok.startswith_insensitive("-include:")) + else if (tok.starts_with_insensitive("/include:") || + tok.starts_with_insensitive("-include:")) result.includes.push_back(tok.substr(strlen("/include:"))); - else if (tok.startswith_insensitive("/exclude-symbols:") || - tok.startswith_insensitive("-exclude-symbols:")) + else if (tok.starts_with_insensitive("/exclude-symbols:") || + tok.starts_with_insensitive("-exclude-symbols:")) result.excludes.push_back(tok.substr(strlen("/exclude-symbols:"))); else { // Copy substrings that are not valid C strings. The tokenizer may have diff --git a/lld/Common/Args.cpp b/lld/Common/Args.cpp --- a/lld/Common/Args.cpp +++ b/lld/Common/Args.cpp @@ -87,7 +87,7 @@ } StringRef lld::args::getFilenameWithoutExe(StringRef path) { - if (path.endswith_insensitive(".exe")) + if (path.ends_with_insensitive(".exe")) return sys::path::stem(path); return sys::path::filename(path); } diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -1227,24 +1227,24 @@ static std::optional parseInt(StringRef tok) { // Hexadecimal uint64_t val; - if (tok.startswith_insensitive("0x")) { + if (tok.starts_with_insensitive("0x")) { if (!to_integer(tok.substr(2), val, 16)) return std::nullopt; return val; } - if (tok.endswith_insensitive("H")) { + if (tok.ends_with_insensitive("H")) { if (!to_integer(tok.drop_back(), val, 16)) return std::nullopt; return val; } // Decimal - if (tok.endswith_insensitive("K")) { + if (tok.ends_with_insensitive("K")) { if (!to_integer(tok.drop_back(), val, 10)) return std::nullopt; return val * 1024; } - if (tok.endswith_insensitive("M")) { + if (tok.ends_with_insensitive("M")) { if (!to_integer(tok.drop_back(), val, 10)) return std::nullopt; return val * 1024 * 1024; diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp --- a/lld/MinGW/Driver.cpp +++ b/lld/MinGW/Driver.cpp @@ -437,7 +437,7 @@ for (auto *a : args) { switch (a->getOption().getID()) { case OPT_INPUT: - if (StringRef(a->getValue()).endswith_insensitive(".def")) + if (StringRef(a->getValue()).ends_with_insensitive(".def")) add("-def:" + StringRef(a->getValue())); else add(prefix + StringRef(a->getValue())); diff --git a/lld/tools/lld/lld.cpp b/lld/tools/lld/lld.cpp --- a/lld/tools/lld/lld.cpp +++ b/lld/tools/lld/lld.cpp @@ -136,7 +136,7 @@ // Deduct the flavor from argv[0]. StringRef arg0 = path::filename(v[0]); - if (arg0.endswith_insensitive(".exe")) + if (arg0.ends_with_insensitive(".exe")) arg0 = arg0.drop_back(4); return parseProgname(arg0); }