From 6ff7a302bed4b43766a661d155368fd2bb20566f Mon Sep 17 00:00:00 2001 From: Anton Korobeynikov Date: Mon, 21 Oct 2024 22:08:09 -0700 Subject: [PATCH] Remove more instances of `.string_view()` calls Signed-off-by: Anton Korobeynikov --- backends/bmv2/common/midend.h | 2 +- backends/bmv2/pna_nic/midend.cpp | 2 +- backends/bmv2/psa_switch/midend.cpp | 2 +- .../control-plane/bfruntime_arch_handler.h | 18 ++-- backends/dpdk/dpdkAsmOpt.cpp | 4 +- backends/dpdk/dpdkHelpers.cpp | 10 +- backends/ebpf/psa/ebpfPsaDeparser.cpp | 2 +- .../targets/bmv2/p4_asserts_parser.cpp | 2 +- .../targets/bmv2/p4_refers_to_parser.cpp | 2 +- backends/tc/backend.cpp | 8 +- backends/tc/tc.def | 95 +++++++++---------- frontends/p4/staticAssert.h | 2 +- frontends/parsers/parserDriver.cpp | 2 +- lib/source_file.cpp | 2 +- midend/expr_uses.h | 4 +- midend/global_copyprop.cpp | 4 +- midend/local_copyprop.cpp | 7 +- midend/parserUnroll.h | 2 +- 18 files changed, 84 insertions(+), 86 deletions(-) diff --git a/backends/bmv2/common/midend.h b/backends/bmv2/common/midend.h index 4983c61e444..a8de8ec0416 100644 --- a/backends/bmv2/common/midend.h +++ b/backends/bmv2/common/midend.h @@ -33,7 +33,7 @@ class EnumOn32Bits : public P4::ChooseEnumRepresentation { bool convert(const IR::Type_Enum *type) const override { if (type->srcInfo.isValid()) { auto sourceFile = type->srcInfo.getSourceFile(); - if (sourceFile.endsWith(filename.string_view())) + if (sourceFile.endsWith(filename)) // Don't convert any of the standard enums return false; } diff --git a/backends/bmv2/pna_nic/midend.cpp b/backends/bmv2/pna_nic/midend.cpp index 95bf1f9b3ae..5617a509be0 100644 --- a/backends/bmv2/pna_nic/midend.cpp +++ b/backends/bmv2/pna_nic/midend.cpp @@ -78,7 +78,7 @@ class PnaEnumOn32Bits : public P4::ChooseEnumRepresentation { if (type->name == "PNA_MeterColor_t") return true; if (type->srcInfo.isValid()) { auto sourceFile = type->srcInfo.getSourceFile(); - if (sourceFile.endsWith(filename.string_view())) + if (sourceFile.endsWith(filename)) // Don't convert any of the standard enums return false; } diff --git a/backends/bmv2/psa_switch/midend.cpp b/backends/bmv2/psa_switch/midend.cpp index c92adf5eb4d..643fd878295 100644 --- a/backends/bmv2/psa_switch/midend.cpp +++ b/backends/bmv2/psa_switch/midend.cpp @@ -78,7 +78,7 @@ class PsaEnumOn32Bits : public P4::ChooseEnumRepresentation { if (type->name == "PSA_MeterColor_t") return true; if (type->srcInfo.isValid()) { auto sourceFile = type->srcInfo.getSourceFile(); - if (sourceFile.endsWith(filename.string_view())) + if (sourceFile.endsWith(filename)) // Don't convert any of the standard enums return false; } diff --git a/backends/dpdk/control-plane/bfruntime_arch_handler.h b/backends/dpdk/control-plane/bfruntime_arch_handler.h index 3a90595bc8b..a5d8190680b 100644 --- a/backends/dpdk/control-plane/bfruntime_arch_handler.h +++ b/backends/dpdk/control-plane/bfruntime_arch_handler.h @@ -147,7 +147,7 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon { } auto *externType = p4info->add_externs(); externType->set_extern_type_id(static_cast(typeId)); - externType->set_extern_type_name(typeName.string_view()); + externType->set_extern_type_name(typeName); return externType; } @@ -161,8 +161,8 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon { auto *externInstance = externType->add_instances(); auto *pre = externInstance->mutable_preamble(); pre->set_id(symbols.getId(typeId, name)); - pre->set_name(prefix(pipeName, name).string_view()); - pre->set_alias(symbols.getAlias(name).string_view()); + pre->set_name(prefix(pipeName, name)); + pre->set_alias(symbols.getAlias(name)); Helpers::addAnnotations(pre, annotations); Helpers::addDocumentation(pre, annotations); externInstance->mutable_info()->PackFrom(message); @@ -237,7 +237,7 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon { auto pipeName = getBlockNamePrefix(tableBlock); auto *pre = table->mutable_preamble(); if (pre->name() == tableDeclaration->controlPlaneName()) - pre->set_name(prefix(pipeName, pre->name()).string_view()); + pre->set_name(prefix(pipeName, pre->name())); } void addExternInstance(const P4RuntimeSymbolTableIface &symbols, p4configv1::P4Info *p4info, @@ -261,7 +261,7 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon { for (auto &extType : *p4info->mutable_action_profiles()) { auto *pre = extType.mutable_preamble(); if (pre->name() == decl->controlPlaneName()) { - pre->set_name(prefix(pipeName, pre->name()).string_view()); + pre->set_name(prefix(pipeName, pre->name())); break; } } @@ -269,7 +269,7 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon { for (auto &extType : *p4info->mutable_action_profiles()) { auto *pre = extType.mutable_preamble(); if (pre->name() == decl->controlPlaneName()) { - pre->set_name(prefix(pipeName, pre->name()).string_view()); + pre->set_name(prefix(pipeName, pre->name())); break; } } @@ -277,7 +277,7 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon { for (auto &extType : *p4info->mutable_meters()) { auto *pre = extType.mutable_preamble(); if (pre->name() == decl->controlPlaneName()) { - pre->set_name(prefix(pipeName, pre->name()).string_view()); + pre->set_name(prefix(pipeName, pre->name())); break; } } @@ -285,7 +285,7 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon { for (auto &extType : *p4info->mutable_counters()) { auto *pre = extType.mutable_preamble(); if (pre->name() == decl->controlPlaneName()) { - pre->set_name(prefix(pipeName, pre->name()).string_view()); + pre->set_name(prefix(pipeName, pre->name())); break; } } @@ -293,7 +293,7 @@ class BFRuntimeArchHandler : public P4RuntimeArchHandlerCommon { for (auto &extType : *p4info->mutable_registers()) { auto *pre = extType.mutable_preamble(); if (pre->name() == decl->controlPlaneName()) { - pre->set_name(prefix(pipeName, pre->name()).string_view()); + pre->set_name(prefix(pipeName, pre->name())); break; } } diff --git a/backends/dpdk/dpdkAsmOpt.cpp b/backends/dpdk/dpdkAsmOpt.cpp index f0c1d037fb7..5b98e5f7945 100644 --- a/backends/dpdk/dpdkAsmOpt.cpp +++ b/backends/dpdk/dpdkAsmOpt.cpp @@ -425,7 +425,7 @@ void EmitDpdkTableConfig::addAction(const IR::Expression *actionRef, P4::Referen actionName = newNameMap[actionDecl->name.name]; else actionName = actionDecl->name.name; - print(actionName.string_view(), " "); + print(actionName, " "); if (actionDecl->parameters->parameters.size() == 1) { std::vector paramNames; std::vector argVals; @@ -458,7 +458,7 @@ void EmitDpdkTableConfig::addAction(const IR::Expression *actionRef, P4::Referen } for (size_t i = 0; i < argVals.size(); i++) { - print(paramNames[i].string_view(), " "); + print(paramNames[i], " "); print(argVals[i], " "); } } diff --git a/backends/dpdk/dpdkHelpers.cpp b/backends/dpdk/dpdkHelpers.cpp index c3a1f18a7fe..3d623a8c8c5 100644 --- a/backends/dpdk/dpdkHelpers.cpp +++ b/backends/dpdk/dpdkHelpers.cpp @@ -1530,9 +1530,9 @@ void ConvertStatementToDpdk::add128bitwiseInstr(const IR::Expression *src1Op, const IR::Type_Header *Type_Header = nullptr; const IR::Type_Header *Type_Tmp = nullptr; for (auto header : structure->header_types) { - if (strcmp(header.first, "_p4c_sandbox_header_t") == 0) { + if (header.first == "_p4c_sandbox_header_t") { Type_Header = header.second; - } else if (strcmp(header.first, "_p4c_tmp128_t") == 0) { + } else if (header.first == "_p4c_tmp128_t") { Type_Tmp = header.second; } } @@ -1637,7 +1637,7 @@ void ConvertStatementToDpdk::add128ComparisonInstr(cstring true_label, const IR: } const IR::Type_Header *Type_Header = nullptr; for (auto header : structure->header_types) { - if (strcmp(header.first, "_p4c_sandbox_header_t") == 0) { + if (header.first == "_p4c_sandbox_header_t") { Type_Header = header.second; } } @@ -1700,9 +1700,9 @@ void ConvertStatementToDpdk::add128bitComplInstr(const IR::Expression *dst, const IR::Type_Header *Type_Header = nullptr; const IR::Type_Header *Type_Tmp = nullptr; for (auto header : structure->header_types) { - if (strcmp(header.first, "_p4c_sandbox_header_t") == 0) { + if (header.first == "_p4c_sandbox_header_t") { Type_Header = header.second; - } else if (strcmp(header.first, "_p4c_tmp128_t") == 0) { + } else if (header.first == "_p4c_tmp128_t") { Type_Tmp = header.second; } } diff --git a/backends/ebpf/psa/ebpfPsaDeparser.cpp b/backends/ebpf/psa/ebpfPsaDeparser.cpp index f0ca5b995c9..399f4124ba6 100644 --- a/backends/ebpf/psa/ebpfPsaDeparser.cpp +++ b/backends/ebpf/psa/ebpfPsaDeparser.cpp @@ -201,7 +201,7 @@ void XDPIngressDeparserPSA::emitPreDeparser(CodeBuilder *builder) { cstring conditionSendToTC = "if (%s->clone || %s->multicast_group != 0 ||" " (!%s->drop && %s->egress_port == 0 && !%s->resubmit && %s->multicast_group == 0)) "_cs; - conditionSendToTC = conditionSendToTC.replace("%s", istd->name.name.string_view()); + conditionSendToTC = conditionSendToTC.replace("%s", istd->name.name); builder->append(conditionSendToTC); builder->blockStart(); builder->emitIndent(); diff --git a/backends/p4tools/modules/testgen/targets/bmv2/p4_asserts_parser.cpp b/backends/p4tools/modules/testgen/targets/bmv2/p4_asserts_parser.cpp index 8996f92e1f9..ddd7562fdfc 100644 --- a/backends/p4tools/modules/testgen/targets/bmv2/p4_asserts_parser.cpp +++ b/backends/p4tools/modules/testgen/targets/bmv2/p4_asserts_parser.cpp @@ -130,7 +130,7 @@ const IR::Expression *makeConstant(Token input, const IdenitifierTypeMap &typeMa for (const auto &[identifier, keyType] : typeMap) { auto annoSize = identifier.size(); auto tokenLength = inputStr.length(); - if (inputStr.compare(tokenLength - annoSize, annoSize, identifier.string_view()) != 0) { + if (inputStr.compare(tokenLength - annoSize, annoSize, identifier) != 0) { continue; } if (const auto *bit = keyType->to()) { diff --git a/backends/p4tools/modules/testgen/targets/bmv2/p4_refers_to_parser.cpp b/backends/p4tools/modules/testgen/targets/bmv2/p4_refers_to_parser.cpp index f822dfaa802..39db90be3d0 100644 --- a/backends/p4tools/modules/testgen/targets/bmv2/p4_refers_to_parser.cpp +++ b/backends/p4tools/modules/testgen/targets/bmv2/p4_refers_to_parser.cpp @@ -110,7 +110,7 @@ const IR::SymbolicVariable *RefersToParser::getReferencedKey(const IR::P4Control const IR::IDeclaration *tableDeclaration = nullptr; for (const auto *decl : *ctrlContext.getDeclarations()) { auto declName = decl->controlPlaneName(); - if (declName.endsWith(tableReference.string_view())) { + if (declName.endsWith(tableReference)) { tableDeclaration = decl; break; } diff --git a/backends/tc/backend.cpp b/backends/tc/backend.cpp index ca7a8293696..5f149d09e7f 100644 --- a/backends/tc/backend.cpp +++ b/backends/tc/backend.cpp @@ -712,8 +712,8 @@ cstring ConvertToBackendIR::HandleTableAccessPermission(const IR::P4Table *t) { } } // FIXME: refactor not to require cstring - auto access_cp = GetAccessNumericValue(control_path.string_view()); - auto access_dp = GetAccessNumericValue(data_path.string_view()); + auto access_cp = GetAccessNumericValue(control_path); + auto access_dp = GetAccessNumericValue(data_path); auto access_permisson = (access_cp << 7) | access_dp; std::stringstream value; value << "0x" << std::hex << access_permisson; @@ -847,8 +847,8 @@ cstring ConvertToBackendIR::processExternPermission(const IR::Type_Extern *ext) if (data_path.isNullOrEmpty()) { data_path = cstring(DEFAULT_EXTERN_DATA_PATH_ACCESS); } - auto access_cp = GetAccessNumericValue(control_path.string_view()); - auto access_dp = GetAccessNumericValue(data_path.string_view()); + auto access_cp = GetAccessNumericValue(control_path); + auto access_dp = GetAccessNumericValue(data_path); auto access_permisson = (access_cp << 7) | access_dp; std::stringstream value; value << "0x" << std::hex << access_permisson; diff --git a/backends/tc/tc.def b/backends/tc/tc.def index 01e2a8ca7c7..20820e4edb2 100644 --- a/backends/tc/tc.def +++ b/backends/tc/tc.def @@ -108,7 +108,7 @@ class TCActionParam { return paramType; } toString { - std::string tcActionParam = absl::StrCat("\n\tparam ", paramName.string_view(), " type "); + std::string tcActionParam = absl::StrCat("\n\tparam ", paramName, " type "); switch(dataType) { case TC::BIT_TYPE : absl::StrAppend(&tcActionParam, "bit", bitSize); @@ -154,9 +154,9 @@ class TCDefaultActionParam { defaultValue = nullptr; } toString { - std::string tcActionParam = absl::StrCat(" ", paramDetail->paramName.string_view()); + std::string tcActionParam = absl::StrCat(" ", paramDetail->paramName); if (defaultValue != nullptr) - absl::StrAppend(&tcActionParam, " ", defaultValue.string_view()); + absl::StrAppend(&tcActionParam, " ", defaultValue); return tcActionParam; } dbprint { out << toString(); } @@ -171,8 +171,7 @@ class TCAction { if (actionName == "NoAction") { return actionName; } - std::string tcAction = absl::StrCat(pipelineName.string_view(), "/", actionName.string_view()); - return tcAction; + return absl::StrCat(pipelineName, "/", actionName); } cstring getActionName() const { return actionName; @@ -192,16 +191,16 @@ class TCAction { actId = 0; } toString { - std::string tcAction = absl::StrCat("\n$TC p4template create action/", pipelineName.string_view(), "/", actionName.string_view()); + std::string tcAction = absl::StrCat("\n$TC p4template create action/", pipelineName, "/", actionName); if (actId != 0) { absl::StrAppend(&tcAction, " actid ", actId); } if (!actionParams.empty()) { for (auto actParam : actionParams) { - absl::StrAppend(&tcAction, " \\", actParam->toString().string_view()); + absl::StrAppend(&tcAction, " \\", actParam); } } - absl::StrAppend(&tcAction, "\n$TC p4template update action/", pipelineName.string_view(), "/", actionName.string_view(), " state active"); + absl::StrAppend(&tcAction, "\n$TC p4template update action/", pipelineName, "/", actionName, " state active"); return tcAction; } @@ -216,7 +215,7 @@ class TCEntry { } toString { std::string tcEntry = ""; - for(auto k : keys) { + for (auto k : keys) { tcEntry = absl::StrJoin({tcEntry, k.first.string(), k.second.string()}, " "); } return tcEntry; @@ -347,11 +346,11 @@ class TCTable { } toString { std::string tcTable = absl::StrCat("\n$TC p4template create table/", - pipelineName.string_view(), "/", controlName.string_view(), "/", tableName.string_view(), " \\", + pipelineName, "/", controlName, "/", tableName, " \\", "\n\ttblid ", tableID, " \\", - "\n\ttype ", printMatchType(matchType).string_view(), " \\", + "\n\ttype ", printMatchType(matchType), " \\", "\n\tkeysz ", keySize, - " permissions ", permissions.string_view(), + " permissions ", permissions, " tentries ", tableEntriesCount); if (matchType == TC::EXACT_TYPE) { absl::StrAppend(&tcTable, " nummasks ", TC::DEFAULT_KEY_MASK_EXACT); @@ -363,16 +362,16 @@ class TCTable { absl::StrAppend(&tcTable, " num_timer_profiles ", timerProfiles); } if (isDirectCounter) { - absl::StrAppend(&tcTable, " \\\n\tpna_direct_counter DirectCounter/", directCounterInstance.string_view()); + absl::StrAppend(&tcTable, " \\\n\tpna_direct_counter DirectCounter/", directCounterInstance); } if (isDirectMeter) { - absl::StrAppend(&tcTable, " \\\n\tpna_direct_meter DirectMeter/", directMeterInstance.string_view()); + absl::StrAppend(&tcTable, " \\\n\tpna_direct_meter DirectMeter/", directMeterInstance); } if (!actionList.empty()) { absl::StrAppend(&tcTable, " \\", "\n\ttable_acts "); for (auto iter = actionList.begin(); iter != actionList.end(); iter++) { - absl::StrAppend(&tcTable, "act name ", iter->first->getName().string_view()); + absl::StrAppend(&tcTable, "act name ", iter->first->getName()); if (iter->second == TC::TABLEONLY) { absl::StrAppend(&tcTable, " flags tableonly"); } else if (iter->second == TC::DEFAULTONLY) { @@ -384,43 +383,43 @@ class TCTable { } } if (defaultHitAction != nullptr) { - absl::StrAppend(&tcTable, "\n$TC p4template update table/", pipelineName.string_view(), - "/", controlName.string_view(), "/", tableName.string_view(), + absl::StrAppend(&tcTable, "\n$TC p4template update table/", pipelineName, + "/", controlName, "/", tableName, " default_hit_action"); if (isDefaultHitConst) { absl::StrAppend(&tcTable, " permissions 0x1024"); } - absl::StrAppend(&tcTable, " action ", defaultHitAction->getName().string_view()); + absl::StrAppend(&tcTable, " action ", defaultHitAction->getName()); if (!defaultHitActionParams.empty()) absl::StrAppend(&tcTable, " param"); for (auto param : defaultHitActionParams) - absl::StrAppend(&tcTable, param->toString().string_view()); + absl::StrAppend(&tcTable, param); if (isTcMayOverrideHit) absl::StrAppend(&tcTable, " flags runtime"); } if (defaultMissAction != nullptr) { - absl::StrAppend(&tcTable, "\n$TC p4template update table/", pipelineName.string_view(), - "/", controlName.string_view(), "/", tableName.string_view(), + absl::StrAppend(&tcTable, "\n$TC p4template update table/", pipelineName, + "/", controlName, "/", tableName, " default_miss_action"); if (isDefaultMissConst) { absl::StrAppend(&tcTable, " permissions 0x1024"); } - absl::StrAppend(&tcTable, " action ", defaultMissAction->getName().string_view()); + absl::StrAppend(&tcTable, " action ", defaultMissAction->getName()); if (!defaultMissActionParams.empty()) absl::StrAppend(&tcTable, " param"); for (auto param : defaultMissActionParams) - absl::StrAppend(&tcTable, param->toString().string_view()); + absl::StrAppend(&tcTable, param); if (isTcMayOverrideMiss) absl::StrAppend(&tcTable, " flags runtime"); } if (const_entries.size() != 0) { for (auto entry : const_entries) { - absl::StrAppend(&tcTable, "\n$TC p4template create table/", pipelineName.string_view(), - "/", controlName.string_view(), "/", tableName.string_view(), - " entry", entry->toString().string_view(), + absl::StrAppend(&tcTable, "\n$TC p4template create table/", pipelineName, + "/", controlName, "/", tableName, + " entry", entry, " permissions 0x1024", - " action ", pipelineName.string_view(), - "/", controlName.string_view(), "/", entry->getActionName().string_view()); + " action ", pipelineName, + "/", controlName, "/", entry->getActionName()); } } return tcTable; @@ -451,7 +450,7 @@ class TCKey { emitValue = true; } toString { - std::string tckeyInstance = absl::StrCat(" ", keyAttribute.string_view(), " ", keyName.string_view(), " ptype ", type.string_view()); + std::string tckeyInstance = absl::StrCat(" ", keyAttribute, " ", keyName, " ptype ", type); if (emitID) { absl::StrAppend(&tckeyInstance, " id ", keyID); } @@ -510,7 +509,7 @@ class TCExternInstance { numelemns = ne; } toString { - std::string tcExternInstance = absl::StrCat(instanceName.string_view(), " instid ", instanceID, " \\"); + std::string tcExternInstance = absl::StrCat(instanceName, " instid ", instanceID, " \\"); if (isNumelemns) { absl::StrAppend(&tcExternInstance, "\ntc_numel ", numelemns, " \\"); } @@ -520,14 +519,14 @@ class TCExternInstance { if (isConstructorKeys) { absl::StrAppend(&tcExternInstance, "\nconstructor"); for (auto field : constructorKeys) { - absl::StrAppend(&tcExternInstance, field->toString().string_view()); + absl::StrAppend(&tcExternInstance, field); } absl::StrAppend(&tcExternInstance, " \\"); } if (isControlPath) { absl::StrAppend(&tcExternInstance, "\ncontrol_path"); for (auto field : controlKeys) { - absl::StrAppend(&tcExternInstance, field->toString().string_view()); + absl::StrAppend(&tcExternInstance, field); } } return tcExternInstance; @@ -563,16 +562,16 @@ class TCExtern { return nullptr; } toString { - std::string tcExtern = absl::StrCat("\n$TC p4template create extern/", "root/", externName.string_view(), - " extid ", externID.string_view(), " numinstances ", numinstances, " tc_acl " + acl_permisson); + std::string tcExtern = absl::StrCat("\n$TC p4template create extern/", "root/", externName, + " extid ", externID, " numinstances ", numinstances, " tc_acl " + acl_permisson); if (has_exec_method) { absl::StrAppend(&tcExtern, " has_exec_method"); } for (unsigned iter = 0; iter < numinstances; iter++) { - absl::StrAppend(&tcExtern, "\n\n$TC p4template create extern_inst/", pipelineName.string_view(), - "/", externName.string_view(), "/"); + absl::StrAppend(&tcExtern, "\n\n$TC p4template create extern_inst/", pipelineName, + "/", externName, "/"); if (externInstances.size() > iter) - absl::StrAppend(&tcExtern, externInstances[iter]->toString().string_view()); + absl::StrAppend(&tcExtern, externInstances[iter]->toString()); } return tcExtern; } @@ -628,34 +627,34 @@ class TCPipeline { toString { std::string tcCode = absl::StrCat("#!/bin/bash -x\n", "\nset -e\n", "\n: \"${TC:=\"tc\"}\"", - "\n$TC p4template create pipeline/", pipelineName.string_view(), + "\n$TC p4template create pipeline/", pipelineName, " numtables ", numTables); if (!actionDefs.empty()) { for (auto a : actionDefs) { - absl::StrAppend(&tcCode, "\n", a->toString().string_view()); + absl::StrAppend(&tcCode, "\n", a); } } if (!externDefs.empty()) { for (auto e : externDefs) { - absl::StrAppend(&tcCode, "\n", e->toString().string_view()); + absl::StrAppend(&tcCode, "\n", e); } } if (!tableDefs.empty()) { for (auto t : tableDefs) { - absl::StrAppend(&tcCode, "\n", t->toString().string_view()); + absl::StrAppend(&tcCode, "\n", t); } } if (preaction != nullptr) { - absl::StrAppend(&tcCode, "\n", preaction->toString().string_view(), - "\n$TC p4template update pipeline/", pipelineName.string_view(), - " preactions action ", pipelineName.string_view(), "/preaction"); + absl::StrAppend(&tcCode, "\n", preaction, + "\n$TC p4template update pipeline/", pipelineName, + " preactions action ", pipelineName, "/preaction"); } if (postaction != nullptr) { - absl::StrAppend(&tcCode, "\n", postaction->toString().string_view(), - "\n$TC p4template update pipeline/", pipelineName.string_view(), - " postactions action ", pipelineName.string_view(), "/postaction"); + absl::StrAppend(&tcCode, "\n", postaction, + "\n$TC p4template update pipeline/", pipelineName, + " postactions action ", pipelineName, "/postaction"); } - absl::StrAppend(&tcCode, "\n$TC p4template update pipeline/", pipelineName.string_view(), " state ready"); + absl::StrAppend(&tcCode, "\n$TC p4template update pipeline/", pipelineName, " state ready"); return tcCode; } dbprint { out << toString(); } diff --git a/frontends/p4/staticAssert.h b/frontends/p4/staticAssert.h index 7f82568c437..ed6f4cfb26f 100644 --- a/frontends/p4/staticAssert.h +++ b/frontends/p4/staticAssert.h @@ -66,7 +66,7 @@ class DoStaticAssert : public Transform, public ResolutionContext { auto msg = subst.lookup(param); CHECK_NULL(msg); if (const auto *sl = msg->expression->to()) { - message = sl->value.string_view(); + message = sl->value; } } ::P4::error(ErrorType::ERR_EXPECTED, "%1%: %2%", method, message); diff --git a/frontends/parsers/parserDriver.cpp b/frontends/parsers/parserDriver.cpp index b64ecf17b29..da0ff243491 100644 --- a/frontends/parsers/parserDriver.cpp +++ b/frontends/parsers/parserDriver.cpp @@ -181,7 +181,7 @@ const T *P4ParserDriver::parse(P4AnnotationLexer::Type type, const Util::SourceI LOG3("Parsing P4-16 annotation " << srcInfo); P4AnnotationLexer lexer(type, srcInfo, body); - if (!parse(lexer, srcInfo.getSourceFile().string_view())) { + if (!parse(lexer, srcInfo.getSourceFile())) { return nullptr; } diff --git a/lib/source_file.cpp b/lib/source_file.cpp index 0cb862dc9df..6e422de8e38 100644 --- a/lib/source_file.cpp +++ b/lib/source_file.cpp @@ -183,7 +183,7 @@ SourceFileLine InputSources::getSourceLine(unsigned line) const { // So we have to subtract one to get the real line number. const auto nominalLine = line - it->first + it->second.sourceLine; const auto realLine = nominalLine > 0 ? nominalLine - 1 : 0; - return SourceFileLine(it->second.fileName.string_view(), realLine); + return SourceFileLine(it->second.fileName, realLine); } unsigned InputSources::getCurrentLineNumber() const { return contents.size(); } diff --git a/midend/expr_uses.h b/midend/expr_uses.h index 3b227de957e..e53775e0367 100644 --- a/midend/expr_uses.h +++ b/midend/expr_uses.h @@ -31,7 +31,7 @@ class exprUses : public Inspector { const char *search_tail = nullptr; // pointer into look_for for partial match bool result = false; bool preorder(const IR::Path *p) override { - if (look_for.startsWith(p->name.name.string_view())) { + if (look_for.startsWith(p->name.name)) { search_tail = look_for.c_str() + p->name.name.size(); if (*search_tail == 0 || *search_tail == '.' || *search_tail == '[') result = true; } @@ -46,7 +46,7 @@ class exprUses : public Inspector { void postorder(const IR::Member *m) override { if (result && search_tail && *search_tail) { if (*search_tail == '.') search_tail++; - if (cstring(search_tail).startsWith(m->member.name.string_view())) { + if (cstring(search_tail).startsWith(m->member.name)) { search_tail += m->member.name.size(); if (*search_tail == 0 || *search_tail == '.' || *search_tail == '[') return; } diff --git a/midend/global_copyprop.cpp b/midend/global_copyprop.cpp index 4e46133b8e5..3644ca53549 100644 --- a/midend/global_copyprop.cpp +++ b/midend/global_copyprop.cpp @@ -28,8 +28,8 @@ static cstring lValueName(const IR::Expression *exp) { /// Test to see if names denote overlapping locations. bool names_overlap(cstring name1, cstring name2) { if (name1 == name2) return true; - if (name1.startsWith(name2.string_view()) && strchr(".[", name1.get(name2.size()))) return true; - if (name2.startsWith(name1.string_view()) && strchr(".[", name2.get(name1.size()))) return true; + if (name1.startsWith(name2) && strchr(".[", name1.get(name2.size()))) return true; + if (name2.startsWith(name1) && strchr(".[", name2.get(name1.size()))) return true; return false; } diff --git a/midend/local_copyprop.cpp b/midend/local_copyprop.cpp index c7b45ed5b97..dd8191736b3 100644 --- a/midend/local_copyprop.cpp +++ b/midend/local_copyprop.cpp @@ -234,8 +234,8 @@ bool DoLocalCopyPropagation::operator==(const ControlFlowVisitor &a_) const { /// test to see if names denote overlapping locations bool DoLocalCopyPropagation::name_overlap(cstring name1, cstring name2) { if (name1 == name2) return true; - if (name1.startsWith(name2.string_view()) && strchr(".[", name1.get(name2.size()))) return true; - if (name2.startsWith(name1.string_view()) && strchr(".[", name2.get(name1.size()))) return true; + if (name1.startsWith(name2) && strchr(".[", name1.get(name2.size()))) return true; + if (name2.startsWith(name1) && strchr(".[", name2.get(name1.size()))) return true; return false; } @@ -259,8 +259,7 @@ void DoLocalCopyPropagation::forOverlapAvail(cstring name, if (it != available.end()) fn(it->first, &it->second); } for (auto it = available.upper_bound(name); it != available.end(); ++it) { - if (!it->first.startsWith(name.string_view()) || !strchr(".[", it->first.get(name.size()))) - break; + if (!it->first.startsWith(name) || !strchr(".[", it->first.get(name.size()))) break; fn(it->first, &it->second); } } diff --git a/midend/parserUnroll.h b/midend/parserUnroll.h index 8704c5d3096..a76772ad9a6 100644 --- a/midend/parserUnroll.h +++ b/midend/parserUnroll.h @@ -151,7 +151,7 @@ class ParserStructure { std::map callsIndexes; // map for curent calls of state insite current one void setParser(const IR::P4Parser *parser) { CHECK_NULL(parser); - callGraph = new StateCallGraph(parser->name.name.string_view()); + callGraph = new StateCallGraph(parser->name.name); this->parser = parser; start = nullptr; }