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
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;
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;
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);
}
DriverMode getDriverMode(const std::vector<std::string> &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") {
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
}
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) {
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;
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);
}
}
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<toolchains::CrossWindowsToolChain>(
*this, Target, Args);
else
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;
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";
}
// 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 += "-";
// 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 += "-";
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;
// 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<std::unique_ptr<llvm::MemoryBuffer>> Text =
loadAndParseConfigFile(ConfigFile, FS, &Style, AllowUnknownOptions);
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);
}
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;
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);
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,
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,
// 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)
ctx.symtab.addFile(make<DLLFile>(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;
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;
}
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))
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;
SmallVector<StringRef, 16> 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
}
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);
}
static std::optional<uint64_t> 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;
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()));
// 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);
}