blob: 503126bbe256ed68eaefc4a15bc52afb05a4cf99 [file] [log] [blame]
Alexey Samsonovf3be7062012-07-09 13:21:39 +00001//===-- 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 Samsonov9b1b1012012-07-10 09:17:06 +000017#include "sanitizer_internal_defs.h"
Alexey Samsonovf3be7062012-07-09 13:21:39 +000018
19namespace __sanitizer {
20
Sergey Matveeved20ebe2013-05-06 11:27:58 +000021struct CommonFlags {
Stephen Hines86277eb2015-03-23 12:06:32 -070022#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 Matveeved20ebe2013-05-06 11:27:58 +000028};
29
Stephen Hines86277eb2015-03-23 12:06:32 -070030// Functions to get/set global CommonFlags shared by all sanitizer runtimes:
31extern CommonFlags common_flags_dont_use;
32inline const CommonFlags *common_flags() {
Stephen Hines2d1fdb22014-05-28 23:58:16 -070033 return &common_flags_dont_use;
Sergey Matveeved20ebe2013-05-06 11:27:58 +000034}
35
Stephen Hines86277eb2015-03-23 12:06:32 -070036inline void SetCommonFlagsDefaults() {
37 common_flags_dont_use.SetDefaults();
38}
Sergey Matveeved20ebe2013-05-06 11:27:58 +000039
Stephen Hines86277eb2015-03-23 12:06:32 -070040// 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).
45inline void OverrideCommonFlags(const CommonFlags &cf) {
46 common_flags_dont_use.CopyFrom(cf);
47}
48
Pirama Arumuga Nainarc58a4362016-09-19 23:00:23 -070049void SubstituteForFlagValue(const char *s, char *out, uptr out_size);
50
Stephen Hines86277eb2015-03-23 12:06:32 -070051class FlagParser;
52void RegisterCommonFlags(FlagParser *parser,
53 CommonFlags *cf = &common_flags_dont_use);
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080054void RegisterIncludeFlags(FlagParser *parser, CommonFlags *cf);
Pirama Arumuga Nainarc58a4362016-09-19 23:00:23 -070055
56// Should be called after parsing all flags. Sets up common flag values
57// and perform initializations common to all sanitizers (e.g. setting
58// verbosity).
59void InitializeCommonFlags(CommonFlags *cf = &common_flags_dont_use);
Alexey Samsonovf3be7062012-07-09 13:21:39 +000060} // namespace __sanitizer
61
62#endif // SANITIZER_FLAGS_H