1f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov//===-- sanitizer_flags.h ---------------------------------------*- C++ -*-===//
2f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov//
3f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov//                     The LLVM Compiler Infrastructure
4f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov//
5f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov// This file is distributed under the University of Illinois Open Source
6f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov// License. See LICENSE.TXT for details.
7f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov//
8f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov//===----------------------------------------------------------------------===//
9f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov//
10f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov// This file is a part of ThreadSanitizer/AddressSanitizer runtime.
11f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov//
12f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov//===----------------------------------------------------------------------===//
13f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov
14f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov#ifndef SANITIZER_FLAGS_H
15f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov#define SANITIZER_FLAGS_H
16f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov
179b1b10193420f5adc769eda0d5bd548e429e0ce2Alexey Samsonov#include "sanitizer_internal_defs.h"
18f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov
19f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonovnamespace __sanitizer {
20f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov
21ed20ebe35c64b8c7043447f6a48b0e5adc89adedSergey Matveevstruct CommonFlags {
2286277eb844c4983c81de62d7c050e92fe7155788Stephen Hines#define COMMON_FLAG(Type, Name, DefaultValue, Description) Type Name;
2386277eb844c4983c81de62d7c050e92fe7155788Stephen Hines#include "sanitizer_flags.inc"
2486277eb844c4983c81de62d7c050e92fe7155788Stephen Hines#undef COMMON_FLAG
2586277eb844c4983c81de62d7c050e92fe7155788Stephen Hines
2686277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  void SetDefaults();
2786277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  void CopyFrom(const CommonFlags &other);
28ed20ebe35c64b8c7043447f6a48b0e5adc89adedSergey Matveev};
29ed20ebe35c64b8c7043447f6a48b0e5adc89adedSergey Matveev
3086277eb844c4983c81de62d7c050e92fe7155788Stephen Hines// Functions to get/set global CommonFlags shared by all sanitizer runtimes:
3186277eb844c4983c81de62d7c050e92fe7155788Stephen Hinesextern CommonFlags common_flags_dont_use;
3286277eb844c4983c81de62d7c050e92fe7155788Stephen Hinesinline const CommonFlags *common_flags() {
332d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  return &common_flags_dont_use;
34ed20ebe35c64b8c7043447f6a48b0e5adc89adedSergey Matveev}
35ed20ebe35c64b8c7043447f6a48b0e5adc89adedSergey Matveev
3686277eb844c4983c81de62d7c050e92fe7155788Stephen Hinesinline void SetCommonFlagsDefaults() {
3786277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  common_flags_dont_use.SetDefaults();
3886277eb844c4983c81de62d7c050e92fe7155788Stephen Hines}
3986277eb844c4983c81de62d7c050e92fe7155788Stephen Hines
4086277eb844c4983c81de62d7c050e92fe7155788Stephen Hines// This function can only be used to setup tool-specific overrides for
4186277eb844c4983c81de62d7c050e92fe7155788Stephen Hines// CommonFlags defaults. Generally, it should only be used right after
4286277eb844c4983c81de62d7c050e92fe7155788Stephen Hines// SetCommonFlagsDefaults(), but before ParseCommonFlagsFromString(), and
4386277eb844c4983c81de62d7c050e92fe7155788Stephen Hines// only during the flags initialization (i.e. before they are used for
4486277eb844c4983c81de62d7c050e92fe7155788Stephen Hines// the first time).
4586277eb844c4983c81de62d7c050e92fe7155788Stephen Hinesinline void OverrideCommonFlags(const CommonFlags &cf) {
4686277eb844c4983c81de62d7c050e92fe7155788Stephen Hines  common_flags_dont_use.CopyFrom(cf);
4786277eb844c4983c81de62d7c050e92fe7155788Stephen Hines}
48ed20ebe35c64b8c7043447f6a48b0e5adc89adedSergey Matveev
4986277eb844c4983c81de62d7c050e92fe7155788Stephen Hinesclass FlagParser;
5086277eb844c4983c81de62d7c050e92fe7155788Stephen Hinesvoid RegisterCommonFlags(FlagParser *parser,
5186277eb844c4983c81de62d7c050e92fe7155788Stephen Hines                         CommonFlags *cf = &common_flags_dont_use);
523d763c0d3700e73b3aead8e65e04ec28efc56138Pirama Arumuga Nainarvoid RegisterIncludeFlags(FlagParser *parser, CommonFlags *cf);
53f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov}  // namespace __sanitizer
54f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov
55f3be7069465c15b4c3f6719423d6075b0cf5a871Alexey Samsonov#endif  // SANITIZER_FLAGS_H
56