source: src/include/cassert @ 893e106

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 893e106 was 8abee136, checked in by Michael Brooks <mlbrooks@…>, 5 years ago

early bug fixes from running conversion old-new-old, just before resolver

  • Property mode set to 100644
File size: 1.5 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// assert.h --
8//
9// Author           : Peter A. Buhr
10// Created On       : Thu Aug 18 13:19:26 2016
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Aug  1 11:56:01 2017
13// Update Count     : 16
14//
15
16#pragma once
17// Pragmas for header cleanup tool
18// IWYU pragma: private, include <cassert>
19
20#include_next <cassert>
21
22#include <string>
23
24template < typename ... Params >
25std::string toString( const Params & ... params );
26
27#ifdef NDEBUG
28
29#define assertf(expr, fmt, ...) (__ASSERT_VOID_ASSERT (0))
30
31#else
32
33#define assertf(expr, fmt, ...) ((expr) \
34        ? (__ASSERT_VOID_CAST (0)) \
35        : __assert_fail_f( #expr, __FILE__, __LINE__, \
36        __ASSERT_FUNCTION, fmt, ## __VA_ARGS__ ))
37
38void __assert_fail_f(   const char *assertion, const char *file,
39                                                unsigned int line, const char *function,
40                                                const char *fmt, ...
41        ) __attribute__((noreturn, format(printf, 5, 6)));
42
43#endif
44
45template<typename T, typename U>
46static inline __attribute__((nonnull)) T strict_dynamic_cast( const U & src ) {
47        assert(src);
48        T ret = dynamic_cast<T>(src);
49        assertf(ret, "%s", toString(src).c_str());
50        return ret;
51}
52
53extern void abort(const char *fmt, ...  ) noexcept __attribute__((noreturn, format(printf, 1, 2)));
54// Local Variables: //
55// tab-width: 4 //
56// mode: c++ //
57// compile-command: "make install" //
58// End: //
Note: See TracBrowser for help on using the repository browser.