1 //===-- sancov_flags.cc -----------------------------------------*- C++ -*-===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // Sanitizer Coverage runtime flags.
10 //===----------------------------------------------------------------------===//
12 #include "sancov_flags.h"
13 #include "sanitizer_flag_parser.h"
14 #include "sanitizer_platform.h"
16 SANITIZER_INTERFACE_WEAK_DEF(const char*, __sancov_default_options
, void) {
20 using namespace __sanitizer
;
24 SancovFlags sancov_flags_dont_use_directly
; // use via flags();
26 void SancovFlags::SetDefaults() {
27 #define SANCOV_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
28 #include "sancov_flags.inc"
32 static void RegisterSancovFlags(FlagParser
*parser
, SancovFlags
*f
) {
33 #define SANCOV_FLAG(Type, Name, DefaultValue, Description) \
34 RegisterFlag(parser, #Name, Description, &f->Name);
35 #include "sancov_flags.inc"
39 static const char *MaybeCallSancovDefaultOptions() {
40 return (&__sancov_default_options
) ? __sancov_default_options() : "";
43 void InitializeSancovFlags() {
44 SancovFlags
*f
= sancov_flags();
48 RegisterSancovFlags(&parser
, f
);
50 parser
.ParseString(MaybeCallSancovDefaultOptions());
51 parser
.ParseString(GetEnv("SANCOV_OPTIONS"));
53 ReportUnrecognizedFlags();
54 if (f
->help
) parser
.PrintFlagDescriptions();
57 } // namespace __sancov