2025-12-12 19:40:43 -08:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Tyler Veness <calcmogul@gmail.com>
|
|
|
|
|
Date: Wed, 3 Dec 2025 23:38:53 -0800
|
2026-03-29 20:39:18 -07:00
|
|
|
Subject: [PATCH 06/10] Replace std::unreachable()
|
2025-12-12 19:40:43 -08:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
include/sleipnir/autodiff/expression_type.hpp | 6 +++---
|
|
|
|
|
.../sleipnir/optimization/solver/exit_status.hpp | 6 +++---
|
|
|
|
|
include/sleipnir/util/unreachable.hpp | 16 ++++++++++++++++
|
|
|
|
|
3 files changed, 22 insertions(+), 6 deletions(-)
|
|
|
|
|
create mode 100644 include/sleipnir/util/unreachable.hpp
|
|
|
|
|
|
|
|
|
|
diff --git a/include/sleipnir/autodiff/expression_type.hpp b/include/sleipnir/autodiff/expression_type.hpp
|
2026-03-29 20:39:18 -07:00
|
|
|
index d06d32dac6c7b6faeedefeaa107cedac8446a3ab..1957fc0339b5538fbdc56a8ea2d8503c89ed4b59 100644
|
2025-12-12 19:40:43 -08:00
|
|
|
--- a/include/sleipnir/autodiff/expression_type.hpp
|
|
|
|
|
+++ b/include/sleipnir/autodiff/expression_type.hpp
|
|
|
|
|
@@ -4,10 +4,10 @@
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
-#include <utility>
|
|
|
|
|
-
|
|
|
|
|
#include <fmt/base.h>
|
|
|
|
|
|
|
|
|
|
+#include "sleipnir/util/unreachable.hpp"
|
|
|
|
|
+
|
|
|
|
|
namespace slp {
|
|
|
|
|
|
|
|
|
|
/// Expression type.
|
2026-03-29 20:39:18 -07:00
|
|
|
@@ -64,7 +64,7 @@ struct fmt::formatter<slp::ExpressionType> {
|
2025-12-12 19:40:43 -08:00
|
|
|
case NONLINEAR:
|
|
|
|
|
return m_underlying.format("nonlinear", ctx);
|
|
|
|
|
default:
|
|
|
|
|
- std::unreachable();
|
|
|
|
|
+ slp::unreachable();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diff --git a/include/sleipnir/optimization/solver/exit_status.hpp b/include/sleipnir/optimization/solver/exit_status.hpp
|
2026-04-09 17:03:57 -07:00
|
|
|
index 8786d6d64ac44ac88133df65a79636ec133b1b64..d1bf7e62aa844003cfcd7f3df6fd9c9a65563586 100644
|
2025-12-12 19:40:43 -08:00
|
|
|
--- a/include/sleipnir/optimization/solver/exit_status.hpp
|
|
|
|
|
+++ b/include/sleipnir/optimization/solver/exit_status.hpp
|
|
|
|
|
@@ -4,10 +4,10 @@
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
-#include <utility>
|
|
|
|
|
-
|
|
|
|
|
#include <fmt/base.h>
|
|
|
|
|
|
|
|
|
|
+#include "sleipnir/util/unreachable.hpp"
|
|
|
|
|
+
|
|
|
|
|
namespace slp {
|
|
|
|
|
|
|
|
|
|
/// Solver exit status. Negative values indicate failure.
|
2026-04-09 17:03:57 -07:00
|
|
|
@@ -96,7 +96,7 @@ struct fmt::formatter<slp::ExitStatus> {
|
2025-12-12 19:40:43 -08:00
|
|
|
case TIMEOUT:
|
|
|
|
|
return m_underlying.format("timeout", ctx);
|
|
|
|
|
default:
|
|
|
|
|
- std::unreachable();
|
|
|
|
|
+ slp::unreachable();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
diff --git a/include/sleipnir/util/unreachable.hpp b/include/sleipnir/util/unreachable.hpp
|
|
|
|
|
new file mode 100644
|
|
|
|
|
index 0000000000000000000000000000000000000000..2e5ec3e716b36e892476fb3accafacbb1ba1fa7d
|
|
|
|
|
--- /dev/null
|
|
|
|
|
+++ b/include/sleipnir/util/unreachable.hpp
|
|
|
|
|
@@ -0,0 +1,16 @@
|
|
|
|
|
+// Copyright (c) Sleipnir contributors
|
|
|
|
|
+
|
|
|
|
|
+#pragma once
|
|
|
|
|
+
|
|
|
|
|
+namespace slp {
|
|
|
|
|
+
|
|
|
|
|
+[[noreturn]]
|
|
|
|
|
+inline void unreachable() {
|
|
|
|
|
+#if defined(_MSC_VER) && !defined(__clang__)
|
|
|
|
|
+ __assume(false);
|
|
|
|
|
+#else
|
|
|
|
|
+ __builtin_unreachable();
|
|
|
|
|
+#endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+} // namespace slp
|