diff --git a/ortools/linear_solver/sat_proto_solver.cc b/ortools/linear_solver/sat_proto_solver.cc index ac8168b54d..a5d3b829a9 100644 --- a/ortools/linear_solver/sat_proto_solver.cc +++ b/ortools/linear_solver/sat_proto_solver.cc @@ -38,6 +38,7 @@ namespace { #if defined(PROTOBUF_INTERNAL_IMPL) using google::protobuf::Message; +#define LegacyUnredactedShortDebugString(x) x.ShortDebugString() #else using google::protobuf::Message; #endif @@ -387,7 +388,7 @@ std::string EncodeSatParametersAsString(const sat::SatParameters& parameters) { return bytes; } - return parameters.ShortDebugString(); + return LegacyUnredactedShortDebugString(parameters); } } // namespace operations_research diff --git a/ortools/port/proto_utils.h b/ortools/port/proto_utils.h index 882e3199f7..08d7638536 100644 --- a/ortools/port/proto_utils.h +++ b/ortools/port/proto_utils.h @@ -24,13 +24,16 @@ #include "absl/base/attributes.h" #include "absl/strings/str_cat.h" +#define LegacyUnredactedDebugString(x) x.DebugString() +#define LegacyUnredactedShortDebugString(x) x.ShortDebugString() + namespace operations_research { template std::string ProtobufDebugString(const P& message) { #if defined(__PORTABLE_PLATFORM__) return message.GetTypeName(); #else // defined(__PORTABLE_PLATFORM__) - return message.DebugString(); + return LegacyUnredactedDebugString(message); #endif // !defined(__PORTABLE_PLATFORM__) } @@ -39,7 +42,7 @@ std::string ProtobufShortDebugString(const P& message) { #if defined(__PORTABLE_PLATFORM__) return message.GetTypeName(); #else // defined(__PORTABLE_PLATFORM__) - return message.ShortDebugString(); + return LegacyUnredactedShortDebugString(message); #endif // !defined(__PORTABLE_PLATFORM__) } diff --git a/ortools/sat/cp_model_checker.cc b/ortools/sat/cp_model_checker.cc index 738b10fdb6..477966edb6 100644 --- a/ortools/sat/cp_model_checker.cc +++ b/ortools/sat/cp_model_checker.cc @@ -39,6 +39,9 @@ namespace operations_research { namespace sat { namespace { +#define LegacyUnredactedDebugString(x) x.DebugString() +#define LegacyUnredactedShortDebugString(x) x.ShortDebugString() + // ============================================================================= // CpModelProto validation. // ============================================================================= @@ -637,18 +640,18 @@ std::string ValidateCumulativeConstraint(const CpModelProto& model, for (const LinearExpressionProto& demand_expr : ct.cumulative().demands()) { if (MinOfExpression(model, demand_expr) < 0) { return absl::StrCat( - "Demand ", demand_expr.DebugString(), + "Demand ", LegacyUnredactedDebugString(demand_expr), " must be positive in constraint: ", ProtobufDebugString(ct)); } if (demand_expr.vars_size() > 1) { - return absl::StrCat("Demand ", demand_expr.DebugString(), + return absl::StrCat("Demand ", LegacyUnredactedDebugString(demand_expr), " must be affine or constant in constraint: ", ProtobufDebugString(ct)); } } if (ct.cumulative().capacity().vars_size() > 1) { return absl::StrCat( - "capacity ", ct.cumulative().capacity().DebugString(), + "capacity ", LegacyUnredactedDebugString(ct.cumulative().capacity()), " must be affine or constant in constraint: ", ProtobufDebugString(ct)); }