From e822cc3715b94b6736fbadbac748e8c09973df24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joshua=20Vanda=C3=ABle?= Date: Thu, 8 Jan 2026 22:51:39 +0100 Subject: [PATCH] c++23: Replace Common::Unreachable with std::unreachable Requires at least GCC 12, Clang 15, MSVC 19.32, or AppleClang 14.0.3. --- CMakeLists.txt | 8 +++---- Source/Core/Common/CMakeLists.txt | 1 - Source/Core/Common/Unreachable.h | 21 ------------------- .../Interpreter/Interpreter_FloatingPoint.cpp | 4 ++-- .../Core/PowerPC/JitArm64/JitArm64_Paired.cpp | 5 +++-- Source/Core/Core/PowerPC/PPCSymbolDB.cpp | 3 +-- Source/Core/DolphinLib.props | 1 - .../DolphinQt/Debugger/BranchWatchDialog.cpp | 3 +-- .../Debugger/BranchWatchTableModel.cpp | 8 +++---- .../DolphinQt/Debugger/JitBlockTableModel.cpp | 8 +++---- 10 files changed, 19 insertions(+), 43 deletions(-) delete mode 100644 Source/Core/Common/Unreachable.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b57ecc08c1..f16030737d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,11 +39,11 @@ if (COMPILER STREQUAL "GNU") endif() # Enforce minimum compiler versions that support the c++23 features we use -set (GCC_min_version 11) -set (Clang_min_version 14) +set (GCC_min_version 12) +set (Clang_min_version 15) set (AppleClang_min_version 14.0.3) -set (min_xcode_version "14.0") # corresponding xcode version for AppleClang_min_version -set (MSVC_min_version 19.30) +set (min_xcode_version "14.3") # corresponding xcode version for AppleClang_min_version +set (MSVC_min_version 19.32) set (min_vs_version "2022 17.2.3") # corresponding Visual Studio version for MSVC_min_version message(STATUS "Using ${COMPILER} ${CMAKE_CXX_COMPILER_VERSION}") diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index a1d6d4a80e..2961354afb 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -156,7 +156,6 @@ add_library(common TraversalClient.h TraversalProto.h TypeUtils.h - Unreachable.h UPnP.cpp UPnP.h VariantUtil.h diff --git a/Source/Core/Common/Unreachable.h b/Source/Core/Common/Unreachable.h deleted file mode 100644 index a01810a239..0000000000 --- a/Source/Core/Common/Unreachable.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2024 Dolphin Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "Common/CommonFuncs.h" - -namespace Common -{ -// TODO C++23: Replace with std::unreachable. -[[noreturn]] inline void Unreachable() -{ -#ifdef _DEBUG - Crash(); -#elif defined(_MSC_VER) && !defined(__clang__) - __assume(false); -#else - __builtin_unreachable(); -#endif -} -} // namespace Common diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp index 134cae495c..9af5767df6 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp @@ -5,10 +5,10 @@ #include #include +#include #include "Common/CommonTypes.h" #include "Common/FloatUtils.h" -#include "Common/Unreachable.h" #include "Core/PowerPC/Gekko.h" #include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h" #include "Core/PowerPC/PowerPC.h" @@ -81,7 +81,7 @@ void ConvertToInteger(PowerPC::PowerPCState& ppc_state, UGeckoInstruction inst, rounded = std::floor(b); break; default: - Common::Unreachable(); + std::unreachable(); } if (std::isnan(b)) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Paired.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Paired.cpp index 7ac2c31bb9..283944dd8b 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Paired.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Paired.cpp @@ -3,11 +3,12 @@ #include "Core/PowerPC/JitArm64/Jit.h" +#include + #include "Common/Arm64Emitter.h" #include "Common/CommonTypes.h" #include "Common/Config/Config.h" #include "Common/StringUtil.h" -#include "Common/Unreachable.h" #include "Core/Config/SessionSettings.h" #include "Core/ConfigManager.h" @@ -343,7 +344,7 @@ void JitArm64::ps_sel(UGeckoInstruction inst) else if (d == c) m_float_emit.BIF(VD, VB, V0); else - Common::Unreachable(); + std::unreachable(); } ASSERT_MSG(DYNA_REC, singles == (fpr.IsSingle(a) && fpr.IsSingle(b) && fpr.IsSingle(c)), diff --git a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp index 250d901bc2..9abc4ad03a 100644 --- a/Source/Core/Core/PowerPC/PPCSymbolDB.cpp +++ b/Source/Core/Core/PowerPC/PPCSymbolDB.cpp @@ -20,7 +20,6 @@ #include "Common/IOFile.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" -#include "Common/Unreachable.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/Debugger/DebugInterface.h" @@ -558,7 +557,7 @@ bool PPCSymbolDB::LoadMap(const Core::CPUThreadGuard& guard, std::string filenam break; default: // Should never happen - Common::Unreachable(); + std::unreachable(); break; } diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index 2ad92b44e6..f1b76cd0cb 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -175,7 +175,6 @@ - diff --git a/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp b/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp index c67645b7f3..98d53767e4 100644 --- a/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp +++ b/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp @@ -34,7 +34,6 @@ #include "Common/CommonTypes.h" #include "Common/FileUtil.h" #include "Common/IOFile.h" -#include "Common/Unreachable.h" #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/Debugger/BranchWatch.h" @@ -1217,7 +1216,7 @@ QMenu* BranchWatchDialog::GetTableContextMenu(const QModelIndex& index) const return m_mnu_table_context_symbol; } static_assert(Column::NumberOfColumns == 8); - Common::Unreachable(); + std::unreachable(); } void BranchWatchDialog::RefreshVisibleContextMenuActions(bool core_initialized) const diff --git a/Source/Core/DolphinQt/Debugger/BranchWatchTableModel.cpp b/Source/Core/DolphinQt/Debugger/BranchWatchTableModel.cpp index 2a3f4cb3d1..eec667868a 100644 --- a/Source/Core/DolphinQt/Debugger/BranchWatchTableModel.cpp +++ b/Source/Core/DolphinQt/Debugger/BranchWatchTableModel.cpp @@ -6,12 +6,12 @@ #include #include #include +#include #include #include "Common/Assert.h" #include "Common/GekkoDisassembler.h" -#include "Common/Unreachable.h" #include "Core/Debugger/BranchWatch.h" #include "Core/PowerPC/PPCSymbolDB.h" @@ -352,7 +352,7 @@ QVariant BranchWatchTableModel::DisplayRoleData(const QModelIndex& index) const return QString::number(kv->second.total_hits); } static_assert(Column::NumberOfColumns == 8); - Common::Unreachable(); + std::unreachable(); } QVariant BranchWatchTableModel::FontRoleData(const QModelIndex& index) const @@ -402,7 +402,7 @@ QVariant BranchWatchTableModel::TextAlignmentRoleData(const QModelIndex& index) return QVariant::fromValue(Qt::AlignLeft | Qt::AlignVCenter); } static_assert(Column::NumberOfColumns == 8); - Common::Unreachable(); + std::unreachable(); } QVariant BranchWatchTableModel::ForegroundRoleData(const QModelIndex& index) const @@ -495,5 +495,5 @@ QVariant BranchWatchTableModel::SortRoleData(const QModelIndex& index) const return qulonglong{kv->second.total_hits}; } static_assert(Column::NumberOfColumns == 8); - Common::Unreachable(); + std::unreachable(); } diff --git a/Source/Core/DolphinQt/Debugger/JitBlockTableModel.cpp b/Source/Core/DolphinQt/Debugger/JitBlockTableModel.cpp index 3911b6c311..25701d26f4 100644 --- a/Source/Core/DolphinQt/Debugger/JitBlockTableModel.cpp +++ b/Source/Core/DolphinQt/Debugger/JitBlockTableModel.cpp @@ -5,9 +5,9 @@ #include #include +#include #include "Common/Assert.h" -#include "Common/Unreachable.h" #include "Core/Core.h" #include "Core/PowerPC/JitInterface.h" #include "Core/PowerPC/PPCSymbolDB.h" @@ -284,7 +284,7 @@ QVariant JitBlockTableModel::DisplayRoleData(const QModelIndex& index) const } } static_assert(Column::NumberOfColumns == 14); - Common::Unreachable(); + std::unreachable(); } QVariant JitBlockTableModel::TextAlignmentRoleData(const QModelIndex& index) const @@ -310,7 +310,7 @@ QVariant JitBlockTableModel::TextAlignmentRoleData(const QModelIndex& index) con return QVariant::fromValue(Qt::AlignLeft | Qt::AlignVCenter); } static_assert(Column::NumberOfColumns == 14); - Common::Unreachable(); + std::unreachable(); } QVariant JitBlockTableModel::SortRoleData(const QModelIndex& index) const @@ -358,7 +358,7 @@ QVariant JitBlockTableModel::SortRoleData(const QModelIndex& index) const return static_cast(profile_data->time_spent.count()) / profile_data->run_count; } static_assert(Column::NumberOfColumns == 14); - Common::Unreachable(); + std::unreachable(); } QVariant JitBlockTableModel::data(const QModelIndex& index, int role) const