Skip to content

Commit

Permalink
Fix startswith and endswith deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
Zentrik committed Jun 20, 2024
1 parent 0ae4445 commit 4863e3c
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/clangsa/GCChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ bool GCChecker::isFDAnnotatedNotSafepoint(const clang::FunctionDecl *FD, const S
SourceLocation Loc = FD->getLocation();
StringRef Name = SM.getFilename(Loc);
Name = llvm::sys::path::filename(Name);
if (Name.startswith("llvm-"))
if (Name.starts_with("llvm-"))
return true;
return false;
}
Expand Down Expand Up @@ -911,9 +911,9 @@ bool GCChecker::isSafepoint(const CallEvent &Call, CheckerContext &C) const {
if (FD->getBuiltinID() != 0 || FD->isTrivial())
isCalleeSafepoint = false;
else if (FD->getDeclName().isIdentifier() &&
(FD->getName().startswith("uv_") ||
FD->getName().startswith("unw_") ||
FD->getName().startswith("_U")) &&
(FD->getName().starts_with("uv_") ||
FD->getName().starts_with("unw_") ||
FD->getName().starts_with("_U")) &&
FD->getName() != "uv_run")
isCalleeSafepoint = false;
else
Expand Down Expand Up @@ -1050,13 +1050,13 @@ bool GCChecker::processAllocationOfResult(const CallEvent &Call,
// global roots.
StringRef FDName =
FD->getDeclName().isIdentifier() ? FD->getName() : "";
if (FDName.startswith("jl_box_") || FDName.startswith("ijl_box_")) {
if (FDName.starts_with("jl_box_") || FDName.starts_with("ijl_box_")) {
SVal Arg = Call.getArgSVal(0);
if (auto CI = Arg.getAs<nonloc::ConcreteInt>()) {
const llvm::APSInt &Value = CI->getValue();
bool GloballyRooted = false;
const int64_t NBOX_C = 1024;
if (FDName.startswith("jl_box_u") || FDName.startswith("ijl_box_u")) {
if (FDName.starts_with("jl_box_u") || FDName.starts_with("ijl_box_u")) {
if (Value < NBOX_C) {
GloballyRooted = true;
}
Expand Down
6 changes: 3 additions & 3 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,7 @@ static GlobalVariable *get_pointer_to_constant(jl_codegen_params_t &emission_con
gv = get_gv(gvname);
}
}
assert(gv->getName().startswith(name.str()));
assert(gv->getName().starts_with(name.str()));
assert(val == gv->getInitializer());
return gv;
}
Expand Down Expand Up @@ -8866,7 +8866,7 @@ static jl_llvm_functions_t
!jl_is_submodule(mod, jl_core_module));
};
auto in_tracked_path = [] (StringRef file) { // falls within an explicitly set file or directory
return jl_options.tracked_path != NULL && file.startswith(jl_options.tracked_path);
return jl_options.tracked_path != NULL && file.starts_with(jl_options.tracked_path);
};
bool mod_is_user_mod = in_user_mod(ctx.module);
bool mod_is_tracked = in_tracked_path(ctx.file);
Expand Down Expand Up @@ -9661,7 +9661,7 @@ static jl_llvm_functions_t
// make sure that anything we attempt to call has some inlining info, just in case optimization messed up
// (except if we know that it is an intrinsic used in our prologue, which should never have its own debug subprogram)
Function *F = call->getCalledFunction();
if (!in_prologue || !F || !(F->isIntrinsic() || F->getName().startswith("julia.") || &I == restTuple)) {
if (!in_prologue || !F || !(F->isIntrinsic() || F->getName().starts_with("julia.") || &I == restTuple)) {
I.setDebugLoc(topdebugloc);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/coverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ extern "C" JL_DLLEXPORT void jl_write_coverage_data(const char *output)
{
if (output) {
StringRef output_pattern(output);
if (output_pattern.endswith(".info"))
if (output_pattern.ends_with(".info"))
write_lcov_data(coverageData, jl_format_filename(output_pattern.str().c_str()));
}
else {
Expand Down
10 changes: 5 additions & 5 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ static Expected<orc::ThreadSafeModule> validateExternRelocations(orc::ThreadSafe
auto F = dyn_cast<Function>(&GO);
if (!F)
return false;
return F->isIntrinsic() || F->getName().startswith("julia.");
return F->isIntrinsic() || F->getName().starts_with("julia.");
};
// validate the relocations for M (only for RuntimeDyld, JITLink performs its own symbol validation)
auto Err = TSM.withModuleDo([isIntrinsicFunction](Module &M) JL_NOTSAFEPOINT {
Expand Down Expand Up @@ -1209,7 +1209,7 @@ namespace {
{
if (*jl_ExecutionEngine->get_dump_llvm_opt_stream()) {
for (auto &F : M.functions()) {
if (F.isDeclaration() || F.getName().startswith("jfptr_")) {
if (F.isDeclaration() || F.getName().starts_with("jfptr_")) {
continue;
}
// Each function is printed as a YAML object with several attributes
Expand Down Expand Up @@ -1262,7 +1262,7 @@ namespace {
// Print LLVM function statistics _after_ optimization
ios_printf(stream, " after: \n");
for (auto &F : M.functions()) {
if (F.isDeclaration() || F.getName().startswith("jfptr_")) {
if (F.isDeclaration() || F.getName().starts_with("jfptr_")) {
continue;
}
Stat(F).dump(stream);
Expand Down Expand Up @@ -1449,7 +1449,7 @@ struct JuliaOJIT::DLSymOptimizer {
void operator()(Module &M) {
for (auto &GV : M.globals()) {
auto Name = GV.getName();
if (Name.startswith("jlplt") && Name.endswith("got")) {
if (Name.starts_with("jlplt") && Name.ends_with("got")) {
auto fname = GV.getAttribute("julia.fname").getValueAsString().str();
void *addr;
if (GV.hasAttribute("julia.libname")) {
Expand Down Expand Up @@ -1702,7 +1702,7 @@ JuliaOJIT::JuliaOJIT()
DL.getGlobalPrefix(),
[&](const orc::SymbolStringPtr &S) {
const char *const atomic_prefix = "__atomic_";
return (*S).startswith(atomic_prefix);
return (*S).starts_with(atomic_prefix);
})));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-cpufeatures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ bool lowerCPUFeatures(Module &M) JL_NOTSAFEPOINT
for (auto &F: M.functions()) {
auto FN = F.getName();

if (FN.startswith("julia.cpu.have_fma.")) {
if (FN.starts_with("julia.cpu.have_fma.")) {
for (Use &U: F.uses()) {
User *RU = U.getUser();
CallInst *I = cast<CallInst>(RU);
Expand Down
6 changes: 3 additions & 3 deletions src/llvm-multiversioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ static uint32_t collect_func_info(Function &F, const Triple &TT, bool &has_vecca
}
if (auto callee = call->getCalledFunction()) {
auto name = callee->getName();
if (name.startswith("llvm.muladd.") || name.startswith("llvm.fma.")) {
if (name.starts_with("llvm.muladd.") || name.starts_with("llvm.fma.")) {
flag |= JL_TARGET_CLONE_MATH;
}
else if (name.startswith("julia.cpu.")) {
if (name.startswith("julia.cpu.have_fma.")) {
else if (name.starts_with("julia.cpu.")) {
if (name.starts_with("julia.cpu.have_fma.")) {
// for some platforms we know they always do (or don't) support
// FMA. in those cases we don't need to clone the function.
// always_have_fma returns an optional<bool>
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-simdloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static bool processLoop(Loop &L, OptimizationRemarkEmitter &ORE, ScalarEvolution
const MDString *S = dyn_cast<MDString>(Op);
if (S) {
LLVM_DEBUG(dbgs() << "LSL: found " << S->getString() << "\n");
if (S->getString().startswith("julia")) {
if (S->getString().starts_with("julia")) {
if (S->getString().equals("julia.simdloop"))
simd = true;
if (S->getString().equals("julia.ivdep"))
Expand Down
2 changes: 1 addition & 1 deletion src/processor_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ template<typename T, typename F>
static inline bool try_read_procfs_line(llvm::StringRef line, const char *prefix, T &out,
bool &flag, F &&reset)
{
if (!line.startswith(prefix))
if (!line.starts_with(prefix))
return false;
if (flag)
reset();
Expand Down

0 comments on commit 4863e3c

Please sign in to comment.