1 //===-- sancov_flags.cc -----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Sanitizer Coverage runtime flags.
12 //===----------------------------------------------------------------------===//
14 #include "sancov_flags.h"
15 #include "sanitizer_flag_parser.h"
16 #include "sanitizer_platform.h"
19 // other platforms do not have weak symbols out of the box.
20 extern "C" const char* __sancov_default_options() { return ""; }
23 using namespace __sanitizer;
27 SancovFlags sancov_flags_dont_use_directly; // use via flags();
29 void SancovFlags::SetDefaults() {
30 #define SANCOV_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
31 #include "sancov_flags.inc"
35 static void RegisterSancovFlags(FlagParser *parser, SancovFlags *f) {
36 #define SANCOV_FLAG(Type, Name, DefaultValue, Description) \
37 RegisterFlag(parser, #Name, Description, &f->Name);
38 #include "sancov_flags.inc"
42 static const char *MaybeCallSancovDefaultOptions() {
43 return (&__sancov_default_options) ? __sancov_default_options() : "";
46 void InitializeSancovFlags() {
47 SancovFlags *f = sancov_flags();
51 RegisterSancovFlags(&parser, f);
53 parser.ParseString(MaybeCallSancovDefaultOptions());
54 parser.ParseString(GetEnv("SANCOV_OPTIONS"));
56 ReportUnrecognizedFlags();
57 if (f->help) parser.PrintFlagDescriptions();
60 } // namespace __sancov