[clangd] Re-land "support outgoing calls in call hierarchy" (#117673)
[llvm-project.git] / libc / src / assert / assert.h
blob1ea19ea5554f0aa7428cf477097826d08d5bf1a7
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 //===----------------------------------------------------------------------===//
10 #include "src/assert/__assert_fail.h"
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.
16 #undef assert
18 #ifdef NDEBUG
19 #define assert(e) (void)0
20 #else
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
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