Skip to content

Commit

Permalink
Merge pull request #271 from hvdijk/starts_with
Browse files Browse the repository at this point in the history
[NFC] Change startswith/endswith to starts_with/ends_with.
  • Loading branch information
hvdijk authored Jan 2, 2024
2 parents 2d186ab + 281f8a6 commit 687d418
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ PreservedAnalyses compiler::CheckForExtFuncsPass::run(Module &M,
for (const auto &F : M) {
auto FName = F.getName();
if (F.isDeclaration() && !F.isIntrinsic() && !FName.equals("printf") &&
!FName.startswith("_Z") && !FName.startswith("__")) {
!FName.starts_with("_Z") && !FName.starts_with("__")) {
M.getContext().diagnose(DiagnosticInfoExternalFunc(FName));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ PreservedAnalyses compiler::PrintfReplacementPass::run(
auto to_be_cloned_func = [&funcs_calling_printf](const Function &func,
bool &ClonedWithBody,
bool &ClonedNoBody) {
ClonedWithBody = !func.getName().startswith("__llvm") &&
ClonedWithBody = !func.getName().starts_with("__llvm") &&
funcs_calling_printf.count(&func);
ClonedNoBody = false;
};
Expand Down
4 changes: 2 additions & 2 deletions modules/compiler/source/base/source/program_metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ bool isImageType(llvm::StringRef type_name, const char *const compare) {
}

llvm::StringRef ro = "__read_only ";
if (type_name.startswith(ro) && type_name.substr(ro.size()) == compare) {
if (type_name.starts_with(ro) && type_name.substr(ro.size()) == compare) {
return true;
}

llvm::StringRef wo = "__write_only ";
if (type_name.startswith(wo) && type_name.substr(wo.size()) == compare) {
if (type_name.starts_with(wo) && type_name.substr(wo.size()) == compare) {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions modules/compiler/tools/muxc/muxc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ Expected<std::unique_ptr<Module>> driver::convertInputToIR() {
// Assume that .bc and .ll files are already IR unless told otherwise.
if (InputLanguage == "ir" ||
(InputLanguage.empty() &&
(IFN.endswith(".bc") || IFN.endswith(".bc32") || IFN.endswith(".bc64") ||
IFN.endswith(".ll")))) {
(IFN.ends_with(".bc") || IFN.ends_with(".bc32") ||
IFN.ends_with(".bc64") || IFN.ends_with(".ll")))) {
return parseIRFileToModule(*LLVMContextToUse);
}
// Assume that stdin is IR unless told otherwise
Expand Down
2 changes: 1 addition & 1 deletion modules/compiler/utils/source/mangling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ bool Lexer::Consume(unsigned Size) {
bool Lexer::Consume(StringRef Pattern) {
if (Left() < Pattern.size()) {
return false;
} else if (!TextLeft().startswith(Pattern)) {
} else if (!TextLeft().starts_with(Pattern)) {
return false;
}
Pos += Pattern.size();
Expand Down
2 changes: 1 addition & 1 deletion modules/compiler/utils/source/pass_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ bool addParamToAllFunctions(llvm::Module &module,
// don't clone and add arg to special functions starting with __llvm.
// These are reserved for clang generated functions such as profile
// related ones
ClonedWithBody = !func.getName().startswith("__llvm");
ClonedWithBody = !func.getName().starts_with("__llvm");
ClonedNoBody = false;
},
updateMetaDataCallback);
Expand Down
2 changes: 1 addition & 1 deletion modules/compiler/utils/source/rename_builtins_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ llvm::PreservedAnalyses compiler::utils::RenameBuiltinsPass::run(
constexpr llvm::StringLiteral MuxFnPrefix = "__mux";

for (auto &fn : M.functions()) {
if (!fn.getName().startswith(MuxFnPrefix)) {
if (!fn.getName().starts_with(MuxFnPrefix)) {
continue;
}
Changed = true;
Expand Down
2 changes: 1 addition & 1 deletion modules/compiler/vecz/source/vectorization_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ VectorizationResult VectorizationContext::getVectorizedFunction(
}

bool VectorizationContext::isInternalBuiltin(const Function *F) {
return F->getName().startswith(VectorizationContext::InternalBuiltinPrefix);
return F->getName().starts_with(VectorizationContext::InternalBuiltinPrefix);
}

Function *VectorizationContext::getOrCreateInternalBuiltin(StringRef Name,
Expand Down
2 changes: 1 addition & 1 deletion modules/compiler/vecz/source/vectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void collectStatistics(VectorizationUnit &VU, Function *Scalar,
// Detect vector splats
// Count insert/extractelement instructions
if (isa<InsertElementInst>(I) || isa<ExtractElementInst>(I)) {
if (I.getName().startswith(".splatinsert")) {
if (I.getName().starts_with(".splatinsert")) {
++VeczSplats;
}
++VeczInsertExtract;
Expand Down

0 comments on commit 687d418

Please sign in to comment.