| 1 |
//===-- sancov_flags.cpp ----------------------------------------*- C++ -*-===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
// |
| 9 |
// Sanitizer Coverage runtime flags. |
| 10 |
// |
| 11 |
//===----------------------------------------------------------------------===// |
| 12 |
|
| 13 |
#include "sancov_flags.h" |
| 14 |
#include "sanitizer_flag_parser.h" |
| 15 |
#include "sanitizer_platform.h" |
| 16 |
|
| 17 |
SANITIZER_INTERFACE_WEAK_DEF(const char*, __sancov_default_options, void) { |
| 18 |
return ""; |
| 19 |
} |
| 20 |
|
| 21 |
using namespace __sanitizer; |
| 22 |
|
| 23 |
namespace __sancov { |
| 24 |
|
| 25 |
SancovFlags sancov_flags_dont_use_directly; // use via flags(); |
| 26 |
|
| 27 |
void SancovFlags::SetDefaults() { |
| 28 |
#define SANCOV_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue; |
| 29 |
#include "sancov_flags.inc" |
| 30 |
#undef SANCOV_FLAG |
| 31 |
} |
| 32 |
|
| 33 |
static void RegisterSancovFlags(FlagParser *parser, SancovFlags *f) { |
| 34 |
#define SANCOV_FLAG(Type, Name, DefaultValue, Description) \ |
| 35 |
RegisterFlag(parser, #Name, Description, &f->Name); |
| 36 |
#include "sancov_flags.inc" |
| 37 |
#undef SANCOV_FLAG |
| 38 |
} |
| 39 |
|
| 40 |
void InitializeSancovFlags() { |
| 41 |
SancovFlags *f = sancov_flags(); |
| 42 |
f->SetDefaults(); |
| 43 |
|
| 44 |
FlagParser parser; |
| 45 |
RegisterSancovFlags(&parser, f); |
| 46 |
|
| 47 |
parser.ParseString(__sancov_default_options()); |
| 48 |
parser.ParseStringFromEnv("SANCOV_OPTIONS"); |
| 49 |
|
| 50 |
ReportUnrecognizedFlags(); |
| 51 |
if (f->help) parser.PrintFlagDescriptions(); |
| 52 |
} |
| 53 |
|
| 54 |
} // namespace __sancov |