[libcxxabi] r331150 - Move _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS macro to build system

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 29 16:05:11 PDT 2018


Author: nico
Date: Sun Apr 29 16:05:11 2018
New Revision: 331150

URL: http://llvm.org/viewvc/llvm-project?rev=331150&view=rev
Log:
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 <tzik at chromium.org>!

Modified:
    libcxxabi/trunk/CMakeLists.txt
    libcxxabi/trunk/src/cxa_exception.cpp
    libcxxabi/trunk/test/test_exception_storage.pass.cpp

Modified: libcxxabi/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=331150&r1=331149&r2=331150&view=diff
==============================================================================
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Sun Apr 29 16:05:11 2018
@@ -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()

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=331150&r1=331149&r2=331150&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Sun Apr 29 16:05:11 2018
@@ -11,8 +11,6 @@
 //  
 //===----------------------------------------------------------------------===//
 
-#define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
-
 #include "cxxabi.h"
 
 #include <exception>        // for std::terminate

Modified: libcxxabi/trunk/test/test_exception_storage.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_exception_storage.pass.cpp?rev=331150&r1=331149&r2=331150&view=diff
==============================================================================
--- libcxxabi/trunk/test/test_exception_storage.pass.cpp (original)
+++ libcxxabi/trunk/test/test_exception_storage.pass.cpp Sun Apr 29 16:05:11 2018
@@ -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 <cstdlib>
 #include <algorithm>
 #include <iostream>




More information about the cfe-commits mailing list