1 // NOLINT(llvm-header-guard) https://github.com/llvm/llvm-project/issues/83339 2 //===-- Internal header for assert ------------------------------*- C++ -*-===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "src/assert/__assert_fail.h" 11 12 // There is no header guard here since assert is intended to be capable of being 13 // included multiple times with NDEBUG defined differently, causing different 14 // behavior. 15 16 #undef assert 17 18 #ifdef NDEBUG 19 #define assert(e) (void)0 20 #else 21 22 #ifdef __has_builtin 23 #if __has_builtin(__builtin_expect) 24 #define __LIBC_ASSERT_LIKELY(e) __builtin_expect(e, 1) 25 #endif 26 #endif 27 #ifndef __LIBC_ASSERT_LIKELY 28 #define __LIBC_ASSERT_LIKELY(e) e 29 #endif 30 31 #define assert(e) \ 32 (__LIBC_ASSERT_LIKELY(e) ? (void)0 \ 33 : LIBC_NAMESPACE::__assert_fail( \ 34 #e, __FILE__, __LINE__, __PRETTY_FUNCTION__)) 35 #endif // NDEBUG 36