11f9cb04fSpatrick //===-- utilities.h ---------------------------------------------*- C++ -*-===// 21f9cb04fSpatrick // 31f9cb04fSpatrick // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 41f9cb04fSpatrick // See https://llvm.org/LICENSE.txt for license information. 51f9cb04fSpatrick // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 61f9cb04fSpatrick // 71f9cb04fSpatrick //===----------------------------------------------------------------------===// 81f9cb04fSpatrick 9*d89ec533Spatrick #ifndef GWP_ASAN_UTILITIES_H_ 10*d89ec533Spatrick #define GWP_ASAN_UTILITIES_H_ 11*d89ec533Spatrick 121f9cb04fSpatrick #include "gwp_asan/definitions.h" 131f9cb04fSpatrick 141f9cb04fSpatrick #include <stddef.h> 151f9cb04fSpatrick 161f9cb04fSpatrick namespace gwp_asan { 17*d89ec533Spatrick // Terminates in a platform-specific way with `Message`. 18*d89ec533Spatrick void die(const char *Message); 191f9cb04fSpatrick 20*d89ec533Spatrick // Checks that `Condition` is true, otherwise dies with `Message`. Check(bool Condition,const char * Message)21*d89ec533SpatrickGWP_ASAN_ALWAYS_INLINE void Check(bool Condition, const char *Message) { 22*d89ec533Spatrick if (Condition) 23*d89ec533Spatrick return; 24*d89ec533Spatrick die(Message); 25*d89ec533Spatrick } 261f9cb04fSpatrick } // namespace gwp_asan 27*d89ec533Spatrick 28*d89ec533Spatrick #endif // GWP_ASAN_UTILITIES_H_ 29