1//===-- utilities.h ---------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef GWP_ASAN_UTILITIES_H_
10#define GWP_ASAN_UTILITIES_H_
11
12#include "gwp_asan/definitions.h"
13
14#include <stddef.h>
15#include <stdint.h>
16
17namespace gwp_asan {
18// Terminates in a platform-specific way with `Message`.
19void die(const char *Message);
20void dieWithErrorCode(const char *Message, int64_t ErrorCode);
21
22// Checks that `Condition` is true, otherwise dies with `Message`.
23GWP_ASAN_ALWAYS_INLINE void check(bool Condition, const char *Message) {
24 if (GWP_ASAN_LIKELY(Condition))
25 return;
26 die(Message);
27}
28
29// Checks that `Condition` is true, otherwise dies with `Message` (including
30// errno at the end).
31GWP_ASAN_ALWAYS_INLINE void
32checkWithErrorCode(bool Condition, const char *Message, int64_t ErrorCode) {
33 if (GWP_ASAN_LIKELY(Condition))
34 return;
35 dieWithErrorCode(Message, ErrorCode);
36}
37} // namespace gwp_asan
38
39#endif // GWP_ASAN_UTILITIES_H_
40

Provided by KDAB

Privacy Policy
Update your C++ knowledge – Modern C++11/14/17 Training
Find out more

source code of compiler-rt/lib/gwp_asan/utilities.h