From ad42fa659fa4b64ca7d031f999bc881b5ecc3381 Mon Sep 17 00:00:00 2001 From: verios-google Date: Tue, 22 Sep 2026 20:09:23 +0000 Subject: [PATCH] Replace absl::nullopt with std::nullopt in p4-constraints absl::optional is an alias for std::optional in C++17, and using std::nullopt directly aligns with standard library best practices. * ast.cc: Use std::nullopt in TypeBitwidth. * backend/constraint_info.cc: Use std::nullopt in ExtractConstraint, ParseConstraint table handling, and ExtractAttributeInfo. * backend/type_checker.cc: Use std::nullopt in LeastUpperBound. * copy.bara.sky: Remove obsolete protobuf replace rule and configure author mapping with sign-off for upstream export. Signed-off-by: verios-google PiperOrigin-RevId: 986185053 --- p4_constraints/ast.cc | 2 +- p4_constraints/backend/constraint_info.cc | 6 +++--- p4_constraints/backend/type_checker.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/p4_constraints/ast.cc b/p4_constraints/ast.cc index 3c38681..1c63dee 100644 --- a/p4_constraints/ast.cc +++ b/p4_constraints/ast.cc @@ -113,7 +113,7 @@ absl::optional TypeBitwidth(const Type& type) { case Type::kOptionalMatch: return type.optional_match().bitwidth(); default: - return absl::nullopt; + return std::nullopt; } } diff --git a/p4_constraints/backend/constraint_info.cc b/p4_constraints/backend/constraint_info.cc index a292c4f..bfd4223 100644 --- a/p4_constraints/backend/constraint_info.cc +++ b/p4_constraints/backend/constraint_info.cc @@ -120,7 +120,7 @@ absl::StatusOr> ExtractConstraint( } } - if (constraint_string.empty()) return absl::nullopt; + if (constraint_string.empty()) return std::nullopt; constraint_location.set_line(line); if (constraint_location.file_path().empty()) { @@ -258,7 +258,7 @@ absl::StatusOr ParseTableInfo(const Table& table) { std::optional constraint_source, ExtractConstraint(ConstraintKind::kTableConstraint, table.preamble())); - std::optional constraint = absl::nullopt; + std::optional constraint = std::nullopt; if (constraint_source.has_value()) { ASSIGN_OR_RETURN( constraint, @@ -341,7 +341,7 @@ std::optional GetAttributeInfo( } // Unknown attribute. - return absl::nullopt; + return std::nullopt; } const TableInfo* GetTableInfoOrNull(const ConstraintInfo& constraint_info, diff --git a/p4_constraints/backend/type_checker.cc b/p4_constraints/backend/type_checker.cc index 06facd5..b638068 100644 --- a/p4_constraints/backend/type_checker.cc +++ b/p4_constraints/backend/type_checker.cc @@ -118,7 +118,7 @@ std::optional LeastUpperBound(const Type& left, const Type& right) { // While it is not true for partial orders in general that // LeastUpperBound(x,y) exists iff x >= y or y >= x, it is true for our // castability relation. - return absl::nullopt; + return std::nullopt; } // Mutates the input expression, wrapping it with a type_cast to the given type.