From 297ec32b86753d1b90e250d92bec0fc2f5d0a634 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 29 Apr 2018 23:05:11 +0000 Subject: [PATCH] Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build system _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS is currently used to bring back std::unexpected, which is removed in C++17, but still needed for libc++abi for backward compatibility. This macro used to define in cxa_exception.cpp only, but actually needed for all sources that touches exceptions. So, a build-system-level macro is better fit to define this macro. https://reviews.llvm.org/D46056 Patch from Taiju Tsuiku ! llvm-svn: 331150 --- libcxxabi/CMakeLists.txt | 4 ++++ libcxxabi/src/cxa_exception.cpp | 2 -- libcxxabi/test/test_exception_storage.pass.cpp | 5 ----- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index 4b1f15134e07..1488737f6155 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -387,6 +387,10 @@ endif() # Prevent libc++abi from having library dependencies on libc++ add_definitions(-D_LIBCPP_DISABLE_EXTERN_TEMPLATE) +# Bring back `std::unexpected`, which is removed in C++17, to support +# pre-C++17. +add_definitions(-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) + if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) endif() diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp index 5c32a155f095..397427a02996 100644 --- a/libcxxabi/src/cxa_exception.cpp +++ b/libcxxabi/src/cxa_exception.cpp @@ -11,8 +11,6 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS - #include "cxxabi.h" #include // for std::terminate diff --git a/libcxxabi/test/test_exception_storage.pass.cpp b/libcxxabi/test/test_exception_storage.pass.cpp index 49c9b5d4963e..ef2524f4784c 100644 --- a/libcxxabi/test/test_exception_storage.pass.cpp +++ b/libcxxabi/test/test_exception_storage.pass.cpp @@ -7,11 +7,6 @@ // //===----------------------------------------------------------------------===// -// FIXME: cxa_exception.hpp directly references `std::unexpected` and friends. -// This breaks this test when compiled in C++17. For now fix this by manually -// re-enabling the STL functions. -#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS - #include #include #include