Commit 8d228ac4 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Fix ordering between FOLLY_HAS_EXCEPTIONS and kHasExceptions

Summary: [Folly] Fix ordering between `FOLLY_HAS_EXCEPTIONS` and `kHasExceptions` definitions.

Reviewed By: swolchok

Differential Revision: D13338301

fbshipit-source-id: 855dbf7ba42eb118f84ffb84d2520c7dfc49cf39
parent d42a8052
...@@ -49,7 +49,7 @@ inline fbstring exceptionStr(std::exception_ptr ep) { ...@@ -49,7 +49,7 @@ inline fbstring exceptionStr(std::exception_ptr ep) {
if (!kHasExceptions) { if (!kHasExceptions) {
return "Exception (catch unavailable)"; return "Exception (catch unavailable)";
} }
catch_exception( return catch_exception(
[&]() -> fbstring { [&]() -> fbstring {
return catch_exception<std::exception const&>( return catch_exception<std::exception const&>(
[&]() -> fbstring { [&]() -> fbstring {
......
...@@ -256,6 +256,25 @@ FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS ...@@ -256,6 +256,25 @@ FOLLY_GCC_DISABLE_NEW_SHADOW_WARNINGS
#endif #endif
// Define FOLLY_HAS_EXCEPTIONS
#if __cpp_exceptions >= 199711 || FOLLY_HAS_FEATURE(cxx_exceptions)
#define FOLLY_HAS_EXCEPTIONS 1
#elif __GNUC__
#if __EXCEPTIONS
#define FOLLY_HAS_EXCEPTIONS 1
#else // __EXCEPTIONS
#define FOLLY_HAS_EXCEPTIONS 0
#endif // __EXCEPTIONS
#elif FOLLY_MICROSOFT_ABI_VER
#if _CPPUNWIND
#define FOLLY_HAS_EXCEPTIONS 1
#else // _CPPUNWIND
#define FOLLY_HAS_EXCEPTIONS 0
#endif // _CPPUNWIND
#else
#define FOLLY_HAS_EXCEPTIONS 1 // default assumption for unknown platforms
#endif
// Debug // Debug
namespace folly { namespace folly {
#ifdef NDEBUG #ifdef NDEBUG
...@@ -472,25 +491,6 @@ constexpr auto kCpplibVer = 0; ...@@ -472,25 +491,6 @@ constexpr auto kCpplibVer = 0;
#define FOLLY_HAVE_NOEXCEPT_FUNCTION_TYPE 1 #define FOLLY_HAVE_NOEXCEPT_FUNCTION_TYPE 1
#endif #endif
// Define FOLLY_HAS_EXCEPTIONS
#if __cpp_exceptions >= 199711 || FOLLY_HAS_FEATURE(cxx_exceptions)
#define FOLLY_HAS_EXCEPTIONS 1
#elif __GNUC__
#if __EXCEPTIONS
#define FOLLY_HAS_EXCEPTIONS 1
#else // __EXCEPTIONS
#define FOLLY_HAS_EXCEPTIONS 0
#endif // __EXCEPTIONS
#elif FOLLY_MICROSOFT_ABI_VER
#if _CPPUNWIND
#define FOLLY_HAS_EXCEPTIONS 1
#else // _CPPUNWIND
#define FOLLY_HAS_EXCEPTIONS 0
#endif // _CPPUNWIND
#else
#define FOLLY_HAS_EXCEPTIONS 1 // default assumption for unknown platforms
#endif
// feature test __cpp_lib_string_view is defined in <string>, which is // feature test __cpp_lib_string_view is defined in <string>, which is
// too heavy to include here. MSVC __has_include support arrived later // too heavy to include here. MSVC __has_include support arrived later
// than string_view, so we need an alternate case for it. // than string_view, so we need an alternate case for it.
......
/*
* Copyright 2018-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <folly/ExceptionString.h>
#include <folly/portability/GTest.h>
class ExceptionStringTest : public testing::Test {};
TEST_F(ExceptionStringTest, exception_ptr) {
auto ptr = std::make_exception_ptr(std::out_of_range("foo"));
auto expected = "std::out_of_range: foo";
auto actual = folly::exceptionStr(ptr).toStdString();
EXPECT_EQ(expected, actual);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment