xref: /llvm-project/compiler-rt/lib/ubsan/ubsan_flags.h (revision 2d7fd38cf7db18edbbfa0e6dfb7454a255171867)
1bfa711c8SAlexey Samsonov //===-- ubsan_flags.h -------------------------------------------*- C++ -*-===//
2bfa711c8SAlexey Samsonov //
3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6bfa711c8SAlexey Samsonov //
7bfa711c8SAlexey Samsonov //===----------------------------------------------------------------------===//
8bfa711c8SAlexey Samsonov //
9bfa711c8SAlexey Samsonov // Runtime flags for UndefinedBehaviorSanitizer.
10bfa711c8SAlexey Samsonov //
11bfa711c8SAlexey Samsonov //===----------------------------------------------------------------------===//
12bfa711c8SAlexey Samsonov #ifndef UBSAN_FLAGS_H
13bfa711c8SAlexey Samsonov #define UBSAN_FLAGS_H
14bfa711c8SAlexey Samsonov 
1525c22249SAlexey Samsonov #include "sanitizer_common/sanitizer_internal_defs.h"
1625c22249SAlexey Samsonov 
1709dce3b7SAlexey Samsonov namespace __sanitizer {
1809dce3b7SAlexey Samsonov class FlagParser;
1909dce3b7SAlexey Samsonov }
2009dce3b7SAlexey Samsonov 
21bfa711c8SAlexey Samsonov namespace __ubsan {
22bfa711c8SAlexey Samsonov 
23bfa711c8SAlexey Samsonov struct Flags {
2403499e92SAlexey Samsonov #define UBSAN_FLAG(Type, Name, DefaultValue, Description) Type Name;
2503499e92SAlexey Samsonov #include "ubsan_flags.inc"
2603499e92SAlexey Samsonov #undef UBSAN_FLAG
2703499e92SAlexey Samsonov 
2803499e92SAlexey Samsonov   void SetDefaults();
29bfa711c8SAlexey Samsonov };
30bfa711c8SAlexey Samsonov 
31bfa711c8SAlexey Samsonov extern Flags ubsan_flags;
flags()32bfa711c8SAlexey Samsonov inline Flags *flags() { return &ubsan_flags; }
33bfa711c8SAlexey Samsonov 
3409dce3b7SAlexey Samsonov void InitializeFlags();
3509dce3b7SAlexey Samsonov void RegisterUbsanFlags(FlagParser *parser, Flags *f);
3609dce3b7SAlexey Samsonov 
37bfa711c8SAlexey Samsonov }  // namespace __ubsan
38bfa711c8SAlexey Samsonov 
3925c22249SAlexey Samsonov extern "C" {
4025c22249SAlexey Samsonov // Users may provide their own implementation of __ubsan_default_options to
4125c22249SAlexey Samsonov // override the default flag values.
4225c22249SAlexey Samsonov SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
4325c22249SAlexey Samsonov const char *__ubsan_default_options();
4425c22249SAlexey Samsonov }  // extern "C"
4525c22249SAlexey Samsonov 
46bfa711c8SAlexey Samsonov #endif  // UBSAN_FLAGS_H
47