mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
87 lines
2.5 KiB
Diff
87 lines
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Tyler Veness <calcmogul@gmail.com>
|
|
Date: Wed, 3 Dec 2025 23:38:53 -0800
|
|
Subject: [PATCH 06/10] Replace std::unreachable()
|
|
|
|
---
|
|
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
|
|
index d06d32dac6c7b6faeedefeaa107cedac8446a3ab..1957fc0339b5538fbdc56a8ea2d8503c89ed4b59 100644
|
|
--- 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.
|
|
@@ -64,7 +64,7 @@ struct fmt::formatter<slp::ExpressionType> {
|
|
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
|
|
index 8a7904dd5664dcd66d1332f38902df2252387a58..ee9bfbc7630513a33297dbeaf39fd695509b5a97 100644
|
|
--- 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.
|
|
@@ -92,7 +92,7 @@ struct fmt::formatter<slp::ExitStatus> {
|
|
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
|