mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 19:44:38 +08:00
[flang] Use StringRef::{starts,ends}_with (NFC)
This patch replaces uses of StringRef::{starts,ends}with with
StringRef::{starts,ends}_with for consistency with
std::{string,string_view}::{starts,ends}_with in C++20.
I'm planning to deprecate and eventually remove
StringRef::{starts,ends}with.
This commit is contained in:
@@ -118,8 +118,8 @@ inline bool isa_derived(mlir::Type t) { return t.isa<fir::RecordType>(); }
|
||||
/// Is `t` type(c_ptr) or type(c_funptr)?
|
||||
inline bool isa_builtin_cptr_type(mlir::Type t) {
|
||||
if (auto recTy = t.dyn_cast_or_null<fir::RecordType>())
|
||||
return recTy.getName().endswith("T__builtin_c_ptr") ||
|
||||
recTy.getName().endswith("T__builtin_c_funptr");
|
||||
return recTy.getName().ends_with("T__builtin_c_ptr") ||
|
||||
recTy.getName().ends_with("T__builtin_c_funptr");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ getExplicitAndImplicitNVPTXTargetFeatures(clang::DiagnosticsEngine &diags,
|
||||
llvm::StringRef userKeyString(llvm::StringRef(userFeature).drop_front(1));
|
||||
implicitFeaturesMap[userKeyString.str()] = (userFeature[0] == '+');
|
||||
// Check if the user provided a PTX version
|
||||
if (userKeyString.startswith("ptx"))
|
||||
if (userKeyString.starts_with("ptx"))
|
||||
ptxVer = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ updateDiagEngineForOptRemarks(clang::DiagnosticsEngine &diagsEng,
|
||||
|
||||
// Check to see if this opt starts with "no-", if so, this is a
|
||||
// negative form of the option.
|
||||
bool isPositive = !remarkOpt.startswith("no-");
|
||||
bool isPositive = !remarkOpt.starts_with("no-");
|
||||
if (!isPositive)
|
||||
remarkOpt = remarkOpt.substr(3);
|
||||
|
||||
|
||||
@@ -149,22 +149,22 @@ public:
|
||||
// Modules IEEE_FEATURES, IEEE_EXCEPTIONS, and IEEE_ARITHMETIC get common
|
||||
// declarations from several __fortran_... support module files.
|
||||
llvm::StringRef modName = toStringRef(modSym.name());
|
||||
if (!modName.startswith("ieee_") && !modName.startswith("__fortran_"))
|
||||
if (!modName.starts_with("ieee_") && !modName.starts_with("__fortran_"))
|
||||
return;
|
||||
llvm::StringRef procName = toStringRef(procSym.name());
|
||||
if (!procName.startswith("ieee_"))
|
||||
if (!procName.starts_with("ieee_"))
|
||||
return;
|
||||
lower::pft::FunctionLikeUnit *proc =
|
||||
evaluationListStack.back()->back().getOwningProcedure();
|
||||
proc->hasIeeeAccess = true;
|
||||
if (!procName.startswith("ieee_set_"))
|
||||
if (!procName.starts_with("ieee_set_"))
|
||||
return;
|
||||
if (procName.startswith("ieee_set_modes_") ||
|
||||
procName.startswith("ieee_set_status_"))
|
||||
if (procName.starts_with("ieee_set_modes_") ||
|
||||
procName.starts_with("ieee_set_status_"))
|
||||
proc->mayModifyHaltingMode = proc->mayModifyRoundingMode = true;
|
||||
else if (procName.startswith("ieee_set_halting_mode_"))
|
||||
else if (procName.starts_with("ieee_set_halting_mode_"))
|
||||
proc->mayModifyHaltingMode = true;
|
||||
else if (procName.startswith("ieee_set_rounding_mode_"))
|
||||
else if (procName.starts_with("ieee_set_rounding_mode_"))
|
||||
proc->mayModifyRoundingMode = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1418,13 +1418,13 @@ mlir::Value toValue(const fir::ExtendedValue &val, fir::FirOpBuilder &builder,
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static bool isIntrinsicModuleProcedure(llvm::StringRef name) {
|
||||
return name.startswith("c_") || name.startswith("compiler_") ||
|
||||
name.startswith("ieee_") || name.startswith("__ppc_");
|
||||
return name.starts_with("c_") || name.starts_with("compiler_") ||
|
||||
name.starts_with("ieee_") || name.starts_with("__ppc_");
|
||||
}
|
||||
|
||||
static bool isCoarrayIntrinsic(llvm::StringRef name) {
|
||||
return name.startswith("atomic_") || name.startswith("co_") ||
|
||||
name.contains("image") || name.endswith("cobound") ||
|
||||
return name.starts_with("atomic_") || name.starts_with("co_") ||
|
||||
name.contains("image") || name.ends_with("cobound") ||
|
||||
name.equals("team_number");
|
||||
}
|
||||
|
||||
@@ -1433,7 +1433,7 @@ static bool isCoarrayIntrinsic(llvm::StringRef name) {
|
||||
/// {_[ail]?[0-9]+}*, such as _1 or _a4.
|
||||
llvm::StringRef genericName(llvm::StringRef specificName) {
|
||||
const std::string builtin = "__builtin_";
|
||||
llvm::StringRef name = specificName.startswith(builtin)
|
||||
llvm::StringRef name = specificName.starts_with(builtin)
|
||||
? specificName.drop_front(builtin.size())
|
||||
: specificName;
|
||||
size_t size = name.size();
|
||||
|
||||
@@ -180,7 +180,7 @@ static MatchResult parseInt(unsigned &result, const char *&ptr,
|
||||
static mlir::LogicalResult matchString(const char *&ptr, const char *endPtr,
|
||||
llvm::StringRef literal) {
|
||||
llvm::StringRef s(ptr, endPtr - ptr);
|
||||
if (s.startswith(literal)) {
|
||||
if (s.starts_with(literal)) {
|
||||
ptr += literal.size();
|
||||
return mlir::success();
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ llvm::StringRef fir::NameUniquer::doProgramEntry() {
|
||||
|
||||
std::pair<fir::NameUniquer::NameKind, fir::NameUniquer::DeconstructedName>
|
||||
fir::NameUniquer::deconstruct(llvm::StringRef uniq) {
|
||||
if (uniq.startswith("_Q")) {
|
||||
if (uniq.starts_with("_Q")) {
|
||||
llvm::SmallVector<std::string> modules;
|
||||
llvm::SmallVector<std::string> procs;
|
||||
std::int64_t blockId = 0;
|
||||
|
||||
@@ -1279,11 +1279,11 @@ void SimplifyIntrinsicsPass::runOnOperation() {
|
||||
// RTNAME(Sum<T>)(const Descriptor &x, const char *source, int line,
|
||||
// int dim, const Descriptor *mask)
|
||||
//
|
||||
if (funcName.startswith(RTNAME_STRING(Sum))) {
|
||||
if (funcName.starts_with(RTNAME_STRING(Sum))) {
|
||||
simplifyIntOrFloatReduction(call, kindMap, genRuntimeSumBody);
|
||||
return;
|
||||
}
|
||||
if (funcName.startswith(RTNAME_STRING(DotProduct))) {
|
||||
if (funcName.starts_with(RTNAME_STRING(DotProduct))) {
|
||||
LLVM_DEBUG(llvm::dbgs() << "Handling " << funcName << "\n");
|
||||
LLVM_DEBUG(llvm::dbgs() << "Call operation:\n"; op->dump();
|
||||
llvm::dbgs() << "\n");
|
||||
@@ -1350,23 +1350,23 @@ void SimplifyIntrinsicsPass::runOnOperation() {
|
||||
llvm::dbgs() << "\n");
|
||||
return;
|
||||
}
|
||||
if (funcName.startswith(RTNAME_STRING(Maxval))) {
|
||||
if (funcName.starts_with(RTNAME_STRING(Maxval))) {
|
||||
simplifyIntOrFloatReduction(call, kindMap, genRuntimeMaxvalBody);
|
||||
return;
|
||||
}
|
||||
if (funcName.startswith(RTNAME_STRING(Count))) {
|
||||
if (funcName.starts_with(RTNAME_STRING(Count))) {
|
||||
simplifyLogicalDim0Reduction(call, kindMap, genRuntimeCountBody);
|
||||
return;
|
||||
}
|
||||
if (funcName.startswith(RTNAME_STRING(Any))) {
|
||||
if (funcName.starts_with(RTNAME_STRING(Any))) {
|
||||
simplifyLogicalDim1Reduction(call, kindMap, genRuntimeAnyBody);
|
||||
return;
|
||||
}
|
||||
if (funcName.endswith(RTNAME_STRING(All))) {
|
||||
if (funcName.ends_with(RTNAME_STRING(All))) {
|
||||
simplifyLogicalDim1Reduction(call, kindMap, genRuntimeAllBody);
|
||||
return;
|
||||
}
|
||||
if (funcName.startswith(RTNAME_STRING(Minloc))) {
|
||||
if (funcName.starts_with(RTNAME_STRING(Minloc))) {
|
||||
simplifyMinlocReduction(call, kindMap);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ void SourceFile::RecordLineStarts() {
|
||||
void SourceFile::IdentifyPayload() {
|
||||
llvm::StringRef content{buf_->getBufferStart(), buf_->getBufferSize()};
|
||||
constexpr llvm::StringLiteral UTF8_BOM{"\xef\xbb\xbf"};
|
||||
if (content.startswith(UTF8_BOM)) {
|
||||
if (content.starts_with(UTF8_BOM)) {
|
||||
bom_end_ = UTF8_BOM.size();
|
||||
encoding_ = Encoding::UTF_8;
|
||||
}
|
||||
|
||||
@@ -99,13 +99,13 @@ int main(int argc, const char **argv) {
|
||||
auto firstArg = std::find_if(args.begin() + 1, args.end(),
|
||||
[](const char *a) { return a != nullptr; });
|
||||
if (firstArg != args.end()) {
|
||||
if (llvm::StringRef(args[1]).startswith("-cc1")) {
|
||||
if (llvm::StringRef(args[1]).starts_with("-cc1")) {
|
||||
llvm::errs() << "error: unknown integrated tool '" << args[1] << "'. "
|
||||
<< "Valid tools include '-fc1'.\n";
|
||||
return 1;
|
||||
}
|
||||
// Call flang-new frontend
|
||||
if (llvm::StringRef(args[1]).startswith("-fc1")) {
|
||||
if (llvm::StringRef(args[1]).starts_with("-fc1")) {
|
||||
return executeFC1Tool(args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ TEST(CompilerInstance, SanityCheckForFileManager) {
|
||||
llvm::ArrayRef<char> fileContent = sf->content();
|
||||
EXPECT_FALSE(fileContent.size() == 0);
|
||||
EXPECT_TRUE(
|
||||
llvm::StringRef(fileContent.data()).startswith("InputSourceFile"));
|
||||
llvm::StringRef(fileContent.data()).starts_with("InputSourceFile"));
|
||||
|
||||
// 4. Delete the test file
|
||||
ec = llvm::sys::fs::remove(inputFile);
|
||||
|
||||
@@ -112,7 +112,7 @@ TEST_F(FrontendActionTest, TestInputOutput) {
|
||||
EXPECT_TRUE(success);
|
||||
EXPECT_TRUE(!outputFileBuffer.empty());
|
||||
EXPECT_TRUE(llvm::StringRef(outputFileBuffer.data())
|
||||
.startswith("End Program arithmetic"));
|
||||
.starts_with("End Program arithmetic"));
|
||||
}
|
||||
|
||||
TEST_F(FrontendActionTest, PrintPreprocessedInput) {
|
||||
@@ -143,7 +143,7 @@ TEST_F(FrontendActionTest, PrintPreprocessedInput) {
|
||||
EXPECT_TRUE(success);
|
||||
EXPECT_TRUE(!outputFileBuffer.empty());
|
||||
EXPECT_TRUE(
|
||||
llvm::StringRef(outputFileBuffer.data()).startswith("program b\n"));
|
||||
llvm::StringRef(outputFileBuffer.data()).starts_with("program b\n"));
|
||||
}
|
||||
|
||||
TEST_F(FrontendActionTest, ParseSyntaxOnly) {
|
||||
|
||||
Reference in New Issue
Block a user