1 //===-- sancov_flags.cc -----------------------------------------*- 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 // Sanitizer Coverage runtime flags. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "sancov_flags.h" 15 #include "sanitizer_flag_parser.h" 16 #include "sanitizer_platform.h" 17 18 SANITIZER_INTERFACE_WEAK_DEF(const char*, __sancov_default_options, void) { 19 return ""; 20 } 21 22 using namespace __sanitizer; 23 24 namespace __sancov { 25 26 SancovFlags sancov_flags_dont_use_directly; // use via flags(); 27 28 void SancovFlags::SetDefaults() { 29 #define SANCOV_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue; 30 #include "sancov_flags.inc" 31 #undef SANCOV_FLAG 32 } 33 34 static void RegisterSancovFlags(FlagParser *parser, SancovFlags *f) { 35 #define SANCOV_FLAG(Type, Name, DefaultValue, Description) \ 36 RegisterFlag(parser, #Name, Description, &f->Name); 37 #include "sancov_flags.inc" 38 #undef SANCOV_FLAG 39 } 40 41 static const char *MaybeCallSancovDefaultOptions() { 42 return (&__sancov_default_options) ? __sancov_default_options() : ""; 43 } 44 45 void InitializeSancovFlags() { 46 SancovFlags *f = sancov_flags(); 47 f->SetDefaults(); 48 49 FlagParser parser; 50 RegisterSancovFlags(&parser, f); 51 52 parser.ParseString(MaybeCallSancovDefaultOptions()); 53 parser.ParseString(GetEnv("SANCOV_OPTIONS")); 54 55 ReportUnrecognizedFlags(); 56 if (f->help) parser.PrintFlagDescriptions(); 57 } 58 59 } // namespace __sancov 60