Fix warning 'control reaches end of non-void function' (#4964)

This commit is contained in:
Guillaume Chatelet
2025-12-24 14:11:17 +01:00
committed by Corentin Le Molgat
parent 0782d13065
commit b28edf1d04
27 changed files with 92 additions and 20 deletions

View File

@@ -379,6 +379,7 @@ cc_library(
deps = [
":routing_enums_cc_proto",
":routing_ils_cc_proto",
"@abseil-cpp//absl/base:core_headers",
],
)

View File

@@ -60,6 +60,7 @@ std::string GetRecreateParametersName(
case RecreateParameters::PARAMETERS_NOT_SET:
return "PARAMETERS_NOT_SET";
}
ABSL_UNREACHABLE();
}
} // namespace operations_research

View File

@@ -225,6 +225,10 @@ cc_library(
"//ortools/lp_data:base",
"//ortools/lp_data:lp_utils",
"//ortools/lp_data:sparse",
"//ortools/lp_data:sparse_column",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
],
)

View File

@@ -20,8 +20,14 @@
#include <queue>
#include <vector>
#include "absl/base/optimization.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "ortools/glop/markowitz.h"
#include "ortools/lp_data/lp_types.h"
#include "ortools/lp_data/lp_utils.h"
#include "ortools/lp_data/sparse.h"
#include "ortools/lp_data/sparse_column.h"
namespace operations_research {
namespace glop {
@@ -219,6 +225,8 @@ int InitialBasis::GetMarosPriority(ColIndex col) const {
case VariableType::FIXED_VARIABLE:
return 0;
}
LOG(FATAL) << "Invalid variable type: "
<< static_cast<int>(variable_type_[col]);
}
int InitialBasis::GetMarosPriority(RowIndex row) const {
@@ -388,6 +396,7 @@ int InitialBasis::GetColumnCategory(ColIndex col) const {
case VariableType::FIXED_VARIABLE:
return 5;
}
ABSL_UNREACHABLE();
}
Fractional InitialBasis::GetColumnPenalty(ColIndex col) const {

View File

@@ -14,6 +14,7 @@
#include "ortools/glop/primal_edge_norms.h"
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include "absl/log/check.h"
@@ -68,6 +69,7 @@ DenseRow::ConstView PrimalEdgeNorms::GetSquaredNorms() {
case GlopParameters::DEVEX:
return GetDevexWeights().const_view();
}
LOG(FATAL) << "Invalid pricing rule: " << pricing_rule_;
}
const DenseRow& PrimalEdgeNorms::GetEdgeSquaredNorms() {

View File

@@ -21,6 +21,7 @@
#include <optional>
#include <string>
#include "absl/base/optimization.h"
#include "absl/container/flat_hash_set.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
@@ -403,6 +404,7 @@ absl::Status ModelIsSupported(const ModelProto& model,
case SupportType::kSupported:
LOG(FATAL) << "Unexpected call with `kSupported`";
}
ABSL_UNREACHABLE();
};
if (const SupportType support = support_menu.integer_variables;
support != SupportType::kSupported) {

View File

@@ -412,6 +412,7 @@ cc_test(
":tagged_id",
"//ortools/base:gmock_main",
"//ortools/math_opt/testing:stream",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/hash:hash_testing",
"@abseil-cpp//absl/strings",
],

View File

@@ -18,6 +18,7 @@
#include <ostream>
#include <utility>
#include "absl/base/optimization.h"
#include "absl/hash/hash_testing.h"
#include "absl/strings/str_cat.h"
#include "gtest/gtest.h"
@@ -39,6 +40,7 @@ std::ostream& operator<<(std::ostream& ostr, const TestEnum& e) {
ostr << "kValue0";
return ostr;
}
ABSL_UNREACHABLE();
}
using TestEnumId = TaggedId<TestEnum::kValue0>;

View File

@@ -322,6 +322,7 @@ cc_library(
"//ortools/math_opt/cpp:math_opt",
"//ortools/math_opt/io:mps_converter",
"//ortools/port:proto_utils",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/status",
"@abseil-cpp//absl/status:statusor",
"@abseil-cpp//absl/strings:string_view",

View File

@@ -17,6 +17,7 @@
#include <ostream>
#include <utility>
#include "absl/base/optimization.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
@@ -210,6 +211,7 @@ absl::StatusOr<SimpleMultiObjectiveSolveResult> SolveWithObjectiveDegradation(
case ObjectiveType::kAuxiliary:
return model.AddMaximizationObjective(x, /*priority=*/0);
}
ABSL_UNREACHABLE();
}();
const Objective priority_1 = [&]() {
switch (priority_1_type) {
@@ -220,6 +222,7 @@ absl::StatusOr<SimpleMultiObjectiveSolveResult> SolveWithObjectiveDegradation(
case ObjectiveType::kAuxiliary:
return model.AddMinimizationObjective(x, /*priority=*/1);
}
ABSL_UNREACHABLE();
}();
ModelSolveParameters model_parameters;
switch (tolerance_type) {

View File

@@ -97,6 +97,7 @@ cc_library(
"@abseil-cpp//absl/cleanup",
"@abseil-cpp//absl/container:flat_hash_map",
"@abseil-cpp//absl/container:flat_hash_set",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/memory",
"@abseil-cpp//absl/status",
@@ -215,6 +216,7 @@ cc_library(
deps = [
"//ortools/base:logging",
"//ortools/linear_solver:scip_helper_macros",
"@abseil-cpp//absl/log:die_if_null",
"@abseil-cpp//absl/status:statusor",
"@abseil-cpp//absl/strings",
"@scip",
@@ -225,7 +227,10 @@ cc_library(
name = "gscip_callback_result",
srcs = ["gscip_callback_result.cc"],
hdrs = ["gscip_callback_result.h"],
deps = ["@scip"],
deps = [
"@abseil-cpp//absl/base:core_headers",
"@scip",
],
)
cc_library(

View File

@@ -22,10 +22,12 @@
#include <utility>
#include <vector>
#include "absl/base/optimization.h"
#include "absl/cleanup/cleanup.h"
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/memory/memory.h"
#include "absl/status/status.h"
#include "absl/status/statusor.h"
@@ -35,14 +37,6 @@
#include "absl/synchronization/mutex.h"
#include "absl/types/span.h"
#include "lpi/lpi.h"
#include "ortools/base/logging.h"
#include "ortools/base/status_macros.h"
#include "ortools/linear_solver/scip_helper_macros.h"
#include "ortools/math_opt/solvers/gscip/gscip.pb.h"
#include "ortools/math_opt/solvers/gscip/gscip_event_handler.h"
#include "ortools/math_opt/solvers/gscip/gscip_parameters.h"
#include "ortools/port/proto_utils.h"
#include "ortools/util/status_macros.h"
#include "scip/cons_and.h"
#include "scip/cons_indicator.h"
#include "scip/cons_linear.h"
@@ -53,6 +47,13 @@
#else
#include "scip/cons_quadratic.h"
#endif // SCIP_VERSION_MAJOR >= 10
#include "ortools/base/status_macros.h"
#include "ortools/linear_solver/scip_helper_macros.h"
#include "ortools/math_opt/solvers/gscip/gscip.pb.h"
#include "ortools/math_opt/solvers/gscip/gscip_event_handler.h"
#include "ortools/math_opt/solvers/gscip/gscip_parameters.h"
#include "ortools/port/proto_utils.h"
#include "ortools/util/status_macros.h"
#include "scip/cons_sos1.h"
#include "scip/cons_sos2.h"
#include "scip/def.h"
@@ -102,6 +103,7 @@ SCIP_VARTYPE ConvertVarType(const GScipVarType var_type) {
case GScipVarType::kInteger:
return SCIP_VARTYPE_INTEGER;
}
ABSL_UNREACHABLE();
}
GScipVarType ConvertVarType(const SCIP_VARTYPE var_type) {
@@ -115,6 +117,7 @@ GScipVarType ConvertVarType(const SCIP_VARTYPE var_type) {
case SCIP_VARTYPE_BINARY:
return GScipVarType::kBinary;
}
LOG(FATAL) << "Unrecognized SCIP_VARTYPE: " << var_type;
}
GScipOutput::Status ConvertStatus(const SCIP_STATUS scip_status) {

View File

@@ -13,6 +13,7 @@
#include "ortools/math_opt/solvers/gscip/gscip_callback_result.h"
#include "absl/base/optimization.h"
#include "scip/type_result.h"
namespace operations_research {
@@ -56,6 +57,7 @@ SCIP_RESULT ConvertGScipCallbackResult(const GScipCallbackResult result) {
case GScipCallbackResult::kDelayNode:
return SCIP_DELAYNODE;
}
ABSL_UNREACHABLE();
}
} // namespace operations_research

View File

@@ -41,6 +41,7 @@ cc_binary(
"//ortools/util:sigint",
"//ortools/util:status_macros",
"@abseil-cpp//absl/base:no_destructor",
"@abseil-cpp//absl/base:nullability",
"@abseil-cpp//absl/flags:flag",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/status",
@@ -81,6 +82,7 @@ cc_library(
"//ortools/math_opt/io:mps_converter",
"//ortools/math_opt/io:proto_converter",
"@abseil-cpp//absl/algorithm:container",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/container:flat_hash_map",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/status",

View File

@@ -20,6 +20,7 @@
#include <vector>
#include "absl/algorithm/container.h"
#include "absl/base/optimization.h"
#include "absl/container/flat_hash_map.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
@@ -69,6 +70,7 @@ std::string AbslUnparseFlag(const FileFormat f) {
case FileFormat::kLP:
return "lp";
}
ABSL_UNREACHABLE();
}
std::ostream& operator<<(std::ostream& out, const FileFormat f) {
@@ -232,6 +234,7 @@ ReadModel(const absl::string_view file_path, const FileFormat format) {
return std::make_pair(std::move(model), std::nullopt);
}
}
ABSL_UNREACHABLE();
}
absl::Status WriteModel(const absl::string_view file_path,
@@ -267,6 +270,7 @@ absl::Status WriteModel(const absl::string_view file_path,
return file::SetContents(file_path, lp_data, file::Defaults());
}
}
ABSL_UNREACHABLE();
}
} // namespace operations_research::math_opt

View File

@@ -135,6 +135,7 @@ cc_library(
"//ortools/lp_data:proto_utils",
"//ortools/util:logging",
"@abseil-cpp//absl/algorithm:container",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/base:nullability",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",

View File

@@ -54,6 +54,7 @@
#include "Eigen/SparseCore"
#include "absl/algorithm/container.h"
#include "absl/base/nullability.h"
#include "absl/base/optimization.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/status/status.h"
@@ -250,6 +251,7 @@ void LogIterationStats(int verbosity_level, bool use_feasibility_polishing,
case IterationType::kPresolveTermination:
return "t ";
}
ABSL_UNREACHABLE();
} else {
return "";
}

View File

@@ -310,7 +310,9 @@ cc_library(
deps = [
":simple_graph",
"//ortools/base:file",
"//ortools/base:logging",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
"@abseil-cpp//absl/strings",
"@abseil-cpp//absl/strings:str_format",
"@abseil-cpp//absl/time",

View File

@@ -14,16 +14,25 @@
#include "ortools/routing/parsers/solution_serializer.h"
#include <algorithm>
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
#include <vector>
#include "absl/base/attributes.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/strings/ascii.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
#include "ortools/base/logging.h"
#include "ortools/base/file.h"
#include "ortools/base/helpers.h"
#include "ortools/base/options.h"
#include "ortools/routing/parsers/simple_graph.h"
namespace operations_research::routing {

View File

@@ -17,19 +17,20 @@
#ifndef ORTOOLS_ROUTING_PARSERS_SOLUTION_SERIALIZER_H_
#define ORTOOLS_ROUTING_PARSERS_SOLUTION_SERIALIZER_H_
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "absl/base/attributes.h"
#include "absl/base/optimization.h"
#include "absl/log/check.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/types/span.h"
#include "ortools/base/file.h"
#include "ortools/base/helpers.h"
#include "ortools/base/logging.h"
#include "ortools/routing/parsers/simple_graph.h"
namespace operations_research::routing {
@@ -162,6 +163,7 @@ class RoutingSolution {
case RoutingOutputFormat::kNEARPLIB:
return SerializeToNEARPLIBString();
}
ABSL_UNREACHABLE();
}
// Serializes the full solution to the given file, including metadata like
@@ -180,6 +182,7 @@ class RoutingSolution {
case RoutingOutputFormat::kNEARPLIB:
return SerializeToNEARPLIBSolutionFile();
}
ABSL_UNREACHABLE();
}
// Serializes the full solution to the given file, including metadata like
@@ -263,6 +266,7 @@ std::string FormatStatistic(absl::string_view name, T value,
case RoutingOutputFormat::kNEARPLIB:
return absl::StrCat(name, " : ", value);
}
ABSL_UNREACHABLE();
}
// Specialization for doubles to show a higher precision: without this
@@ -282,6 +286,7 @@ inline std::string FormatStatistic(absl::string_view name, double value,
case RoutingOutputFormat::kNEARPLIB:
return absl::StrFormat("%s : %f", name, value);
}
ABSL_UNREACHABLE();
}
// Prints a formatted solution or solver statistic according to the given

View File

@@ -318,6 +318,7 @@ struct Edge {
.y_start = rectangle.y_min,
.size = rectangle.SizeY()};
}
LOG(FATAL) << "Invalid edge position: " << static_cast<int>(pos);
}
template <typename H>
@@ -598,6 +599,7 @@ IntegerValue GetClockwiseStart(EdgePosition edge, const Rectangle& rectangle) {
case EdgePosition::TOP:
return rectangle.x_min;
}
LOG(FATAL) << "Invalid edge position: " << static_cast<int>(edge);
}
IntegerValue GetClockwiseEnd(EdgePosition edge, const Rectangle& rectangle) {
@@ -611,6 +613,7 @@ IntegerValue GetClockwiseEnd(EdgePosition edge, const Rectangle& rectangle) {
case EdgePosition::TOP:
return rectangle.x_max;
}
LOG(FATAL) << "Invalid edge position: " << static_cast<int>(edge);
}
// Given a list of rectangles and their neighbours graph, find the list of

View File

@@ -21,6 +21,7 @@
#include "absl/algorithm/container.h"
#include "absl/container/flat_hash_map.h"
#include "absl/container/inlined_vector.h"
#include "absl/log/log.h"
#include "absl/types/span.h"
#include "ortools/sat/diffn_util.h"
#include "ortools/sat/integer_base.h"
@@ -180,6 +181,7 @@ class Neighbours {
case EdgePosition::RIGHT:
return std::tie(a.y_min, a.y_max) > std::tie(b.y_min, b.y_max);
}
LOG(FATAL) << "Invalid edge position: " << static_cast<int>(edge_);
}
EdgePosition edge_;
};

View File

@@ -426,6 +426,7 @@ cc_library(
"//ortools/util:bitset",
"//ortools/util:saturated_arithmetic",
"//ortools/util:sorted_interval_list",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/container:flat_hash_map",
"@abseil-cpp//absl/container:flat_hash_set",
"@abseil-cpp//absl/flags:flag",
@@ -2308,6 +2309,7 @@ cc_library(
":sat_base",
":scheduling_helpers",
":util",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/base:log_severity",
"@abseil-cpp//absl/log",
"@abseil-cpp//absl/log:check",
@@ -3684,14 +3686,12 @@ cc_library(
":integer_base",
":scheduling_helpers",
":util",
"//ortools/base:logging",
"//ortools/base:stl_util",
"//ortools/base:strong_vector",
"//ortools/graph:connected_components",
"//ortools/graph:strongly_connected_components",
"//ortools/util:fixed_shape_binary_tree",
"//ortools/util:integer_pq",
"//ortools/util:saturated_arithmetic",
"//ortools/util:strong_integers",
"@abseil-cpp//absl/algorithm:container",
"@abseil-cpp//absl/container:btree",
@@ -3703,7 +3703,6 @@ cc_library(
"@abseil-cpp//absl/log:vlog_is_on",
"@abseil-cpp//absl/random:bit_gen_ref",
"@abseil-cpp//absl/strings:str_format",
"@abseil-cpp//absl/types:optional",
"@abseil-cpp//absl/types:span",
],
)

View File

@@ -22,6 +22,7 @@
#include <utility>
#include <vector>
#include "absl/base/optimization.h"
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/flags/flag.h"
@@ -547,6 +548,7 @@ absl::string_view ConstraintCaseName(
case ConstraintProto::ConstraintCase::CONSTRAINT_NOT_SET:
return "kEmpty";
}
ABSL_UNREACHABLE();
}
std::vector<int> UsedVariables(const ConstraintProto& ct) {

View File

@@ -41,7 +41,6 @@
#include "absl/log/vlog_is_on.h"
#include "absl/random/bit_gen_ref.h"
#include "absl/types/span.h"
#include "ortools/base/logging.h"
#include "ortools/base/stl_util.h"
#include "ortools/base/strong_vector.h"
#include "ortools/graph/connected_components.h"
@@ -1114,6 +1113,7 @@ constexpr const EdgeInfo& GetEdgeInfo(ProbingRectangle::Edge edge) {
case Edge::TOP:
return EdgeInfoHolder::kTop;
}
LOG(FATAL) << "Invalid edge: " << static_cast<int>(edge);
}
IntegerValue GetSmallest1DIntersection(ProbingRectangle::Direction direction,
@@ -1129,6 +1129,7 @@ IntegerValue GetSmallest1DIntersection(ProbingRectangle::Direction direction,
range.bounding_area.y_max, range.y_size,
rectangle.y_min, rectangle.y_max);
}
LOG(FATAL) << "Invalid direction: " << static_cast<int>(direction);
}
} // namespace
@@ -1391,6 +1392,7 @@ IntegerValue ProbingRectangle::GetShrinkDeltaArea(Edge edge) const {
case Edge::TOP:
return (current_rectangle.y_max - coordinate) * current_rectangle.SizeX();
}
LOG(FATAL) << "Invalid edge: " << static_cast<int>(edge);
}
void ProbingRectangle::CacheShrinkDeltaEnergy(int dimension) {
@@ -1493,6 +1495,7 @@ bool ProbingRectangle::CanShrink(Edge edge) const {
case Edge::TOP:
return (indexes_[Edge::TOP] > next_indexes_[Edge::BOTTOM]);
}
LOG(FATAL) << "Invalid edge: " << static_cast<int>(edge);
}
namespace {

View File

@@ -28,14 +28,13 @@
#include "absl/container/flat_hash_set.h"
#include "absl/container/inlined_vector.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/random/bit_gen_ref.h"
#include "absl/strings/str_format.h"
#include "absl/types/optional.h"
#include "absl/types/span.h"
#include "ortools/sat/integer_base.h"
#include "ortools/sat/scheduling_helpers.h"
#include "ortools/sat/util.h"
#include "ortools/util/saturated_arithmetic.h"
#include "ortools/util/strong_integers.h"
namespace operations_research {
@@ -471,6 +470,7 @@ struct RectangleInRange {
.y_min = bounding_area.y_max - y_size,
.y_max = bounding_area.y_max};
}
LOG(FATAL) << "Invalid corner: " << static_cast<int>(p);
}
Rectangle GetBoudingBox() const { return bounding_area; }

View File

@@ -19,6 +19,7 @@
#include <vector>
#include "absl/base/log_severity.h"
#include "absl/base/optimization.h"
#include "absl/log/check.h"
#include "absl/log/log.h"
#include "absl/types/span.h"
@@ -188,6 +189,7 @@ bool NoOverlap2DConstraintHelper::PropagateRelativePosition(
return LeftBoxBeforeRightBoxOnFirstDimension(
second, first, y_helper_.get(), x_helper_.get());
}
ABSL_UNREACHABLE();
}
void NoOverlap2DConstraintHelper::Reset(