Alexey Samsonov | f3be706 | 2012-07-09 13:21:39 +0000 | [diff] [blame] | 1 | //===-- sanitizer_flags.h ---------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file is a part of ThreadSanitizer/AddressSanitizer runtime. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef SANITIZER_FLAGS_H |
| 15 | #define SANITIZER_FLAGS_H |
| 16 | |
Alexey Samsonov | 9b1b101 | 2012-07-10 09:17:06 +0000 | [diff] [blame] | 17 | #include "sanitizer_internal_defs.h" |
Alexey Samsonov | f3be706 | 2012-07-09 13:21:39 +0000 | [diff] [blame] | 18 | |
| 19 | namespace __sanitizer { |
| 20 | |
Sergey Matveev | ed20ebe | 2013-05-06 11:27:58 +0000 | [diff] [blame] | 21 | struct CommonFlags { |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 22 | #define COMMON_FLAG(Type, Name, DefaultValue, Description) Type Name; |
| 23 | #include "sanitizer_flags.inc" |
| 24 | #undef COMMON_FLAG |
| 25 | |
| 26 | void SetDefaults(); |
| 27 | void CopyFrom(const CommonFlags &other); |
Sergey Matveev | ed20ebe | 2013-05-06 11:27:58 +0000 | [diff] [blame] | 28 | }; |
| 29 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 30 | // Functions to get/set global CommonFlags shared by all sanitizer runtimes: |
| 31 | extern CommonFlags common_flags_dont_use; |
| 32 | inline const CommonFlags *common_flags() { |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 33 | return &common_flags_dont_use; |
Sergey Matveev | ed20ebe | 2013-05-06 11:27:58 +0000 | [diff] [blame] | 34 | } |
| 35 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 36 | inline void SetCommonFlagsDefaults() { |
| 37 | common_flags_dont_use.SetDefaults(); |
| 38 | } |
Sergey Matveev | ed20ebe | 2013-05-06 11:27:58 +0000 | [diff] [blame] | 39 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 40 | // This function can only be used to setup tool-specific overrides for |
| 41 | // CommonFlags defaults. Generally, it should only be used right after |
| 42 | // SetCommonFlagsDefaults(), but before ParseCommonFlagsFromString(), and |
| 43 | // only during the flags initialization (i.e. before they are used for |
| 44 | // the first time). |
| 45 | inline void OverrideCommonFlags(const CommonFlags &cf) { |
| 46 | common_flags_dont_use.CopyFrom(cf); |
| 47 | } |
| 48 | |
| 49 | class FlagParser; |
| 50 | void RegisterCommonFlags(FlagParser *parser, |
| 51 | CommonFlags *cf = &common_flags_dont_use); |
| 52 | void RegisterIncludeFlag(FlagParser *parser, CommonFlags *cf); |
Alexey Samsonov | f3be706 | 2012-07-09 13:21:39 +0000 | [diff] [blame] | 53 | } // namespace __sanitizer |
| 54 | |
| 55 | #endif // SANITIZER_FLAGS_H |