Skip to content

Commit 0144b65

Browse files
committed
Remove DEBUG_ASSERT_ASSUME()
It doesn't get completely discarded after all...
1 parent dfeca6b commit 0144b65

2 files changed

Lines changed: 5 additions & 42 deletions

File tree

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ The options are named like the macros.
5656

5757
#define <a href='doc_debug_assert.md#debug_assert.hpp'>DEBUG_ASSERT_PURE_FUNCTION</a>
5858

59-
#define <a href='doc_debug_assert.md#debug_assert.hpp'>DEBUG_ASSERT_ASSUME</a>(Expr)
60-
6159
#define <a href='doc_debug_assert.md#debug_assert.hpp'>DEBUG_ASSERT_FORCE_INLINE</a>
6260

6361
#define <a href='doc_debug_assert.md#DEBUG_ASSERT_CUR_SOURCE_LOCATION'>DEBUG_ASSERT_CUR_SOURCE_LOCATION</a>

debug_assert.hpp

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
#ifndef DEBUG_ASSERT_HPP_INCLUDED
2626
#define DEBUG_ASSERT_HPP_INCLUDED
2727

28-
// Ignore __builtin_assume() warnings on clang.
29-
// See https://github.com/foonathan/debug_assert/issues/12
30-
#ifdef __clang__
31-
#pragma clang diagnostic push
32-
#pragma clang diagnostic ignored "-Wassume"
33-
#endif // __clang__
34-
3528
#include <cstdlib>
3629

3730
#ifndef DEBUG_ASSERT_NO_STDIO
@@ -60,28 +53,6 @@
6053
#endif
6154
#endif
6255

63-
// checking for clang must come first because clang also defines __GNUC__.
64-
#if !defined(DEBUG_ASSERT_ASSUME) && defined(__clang__)
65-
// __has_builtin may not work in other compilers.
66-
#if __has_builtin(__builtin_assume)
67-
#define DEBUG_ASSERT_ASSUME(Expr) static_cast<void>(__builtin_assume(Expr), 0)
68-
#endif
69-
#endif
70-
71-
#ifndef DEBUG_ASSERT_ASSUME
72-
#ifdef __GNUC__
73-
#define DEBUG_ASSERT_ASSUME(Expr) static_cast<void>((Expr) ? 0 : (__builtin_unreachable(), 0))
74-
#elif defined(_MSC_VER)
75-
#define DEBUG_ASSERT_ASSUME(Expr) static_cast<void>(__assume(Expr), 0)
76-
#else
77-
/// Hint to the compiler that a condition is `true`.
78-
/// Define it yourself prior to including the header to override it.
79-
/// \notes This must be usable in an expression,
80-
/// and yield a `void` value.
81-
#define DEBUG_ASSERT_ASSUME(Expr) static_cast<void>(0)
82-
#endif
83-
#endif
84-
8556
#ifndef DEBUG_ASSERT_FORCE_INLINE
8657
#ifdef __GNUC__
8758
#define DEBUG_ASSERT_FORCE_INLINE [[gnu::always_inline]] inline
@@ -293,12 +264,12 @@ namespace debug_assert
293264
}
294265

295266
template <class Expr, class Handler, unsigned Level, typename... Args>
296-
DEBUG_ASSERT_FORCE_INLINE constexpr auto do_assert(const Expr& expr, const source_location&,
267+
DEBUG_ASSERT_FORCE_INLINE constexpr auto do_assert(const Expr&, const source_location&,
297268
const char*, Handler, level<Level>,
298269
Args&&...) noexcept ->
299270
typename enable_if<(Level > Handler::level), regular_void>::type
300271
{
301-
return DEBUG_ASSERT_ASSUME(expr()), regular_void();
272+
return regular_void();
302273
}
303274

304275
template <class Expr, class Handler, typename... Args>
@@ -315,11 +286,11 @@ namespace debug_assert
315286
}
316287

317288
template <class Expr, class Handler, typename... Args>
318-
DEBUG_ASSERT_FORCE_INLINE constexpr auto do_assert(const Expr& expr, const source_location&,
289+
DEBUG_ASSERT_FORCE_INLINE constexpr auto do_assert(const Expr&, const source_location&,
319290
const char*, Handler, Args&&...) noexcept
320291
-> typename enable_if<Handler::level == 0, regular_void>::type
321292
{
322-
return DEBUG_ASSERT_ASSUME(expr()), regular_void();
293+
return regular_void();
323294
}
324295

325296
DEBUG_ASSERT_PURE_FUNCTION constexpr bool always_false() noexcept
@@ -397,15 +368,9 @@ namespace debug_assert
397368
debug_assert::detail::do_assert(debug_assert::detail::always_false, \
398369
DEBUG_ASSERT_CUR_SOURCE_LOCATION, "", __VA_ARGS__)
399370
#else
400-
#define DEBUG_ASSERT(Expr, ...) DEBUG_ASSERT_ASSUME(Expr)
371+
#define DEBUG_ASSERT(Expr, ...) static_cast<void>(0)
401372

402373
#define DEBUG_UNREACHABLE(...) (DEBUG_ASSERT_MARK_UNREACHABLE, debug_assert::detail::regular_void())
403374
#endif
404375

405-
// Ignore __builtin_assume() warnings on clang.
406-
// See https://github.com/foonathan/debug_assert/issues/12
407-
#ifdef __clang__
408-
#pragma clang diagnostic pop
409-
#endif // __clang__
410-
411376
#endif // DEBUG_ASSERT_HPP_INCLUDED

0 commit comments

Comments
 (0)