36 lines · c
1// NOLINT(llvm-header-guard) https://github.com/llvm/llvm-project/issues/833392//===-- 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-exception7//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 being13// included multiple times with NDEBUG defined differently, causing different14// behavior.15 16#undef assert17 18#ifdef NDEBUG19#define assert(e) (void)020#else21 22#ifdef __has_builtin23#if __has_builtin(__builtin_expect)24#define __LIBC_ASSERT_LIKELY(e) __builtin_expect(e, 1)25#endif26#endif27#ifndef __LIBC_ASSERT_LIKELY28#define __LIBC_ASSERT_LIKELY(e) e29#endif30 31#define assert(e) \32 (__LIBC_ASSERT_LIKELY(e) ? (void)0 \33 : LIBC_NAMESPACE::__assert_fail( \34 #e, __FILE__, __LINE__, __PRETTY_FUNCTION__))35#endif // NDEBUG36