168d75effSDimitry Andric //===-- sancov_flags.cpp ----------------------------------------*- C++ -*-===//
268d75effSDimitry Andric //
368d75effSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
468d75effSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
568d75effSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
668d75effSDimitry Andric //
768d75effSDimitry Andric //===----------------------------------------------------------------------===//
868d75effSDimitry Andric //
968d75effSDimitry Andric // Sanitizer Coverage runtime flags.
1068d75effSDimitry Andric //
1168d75effSDimitry Andric //===----------------------------------------------------------------------===//
1268d75effSDimitry Andric
1368d75effSDimitry Andric #include "sancov_flags.h"
1468d75effSDimitry Andric #include "sanitizer_flag_parser.h"
1568d75effSDimitry Andric #include "sanitizer_platform.h"
1668d75effSDimitry Andric
SANITIZER_INTERFACE_WEAK_DEF(const char *,__sancov_default_options,void)1768d75effSDimitry Andric SANITIZER_INTERFACE_WEAK_DEF(const char*, __sancov_default_options, void) {
1868d75effSDimitry Andric return "";
1968d75effSDimitry Andric }
2068d75effSDimitry Andric
2168d75effSDimitry Andric using namespace __sanitizer;
2268d75effSDimitry Andric
2368d75effSDimitry Andric namespace __sancov {
2468d75effSDimitry Andric
2568d75effSDimitry Andric SancovFlags sancov_flags_dont_use_directly; // use via flags();
2668d75effSDimitry Andric
SetDefaults()2768d75effSDimitry Andric void SancovFlags::SetDefaults() {
2868d75effSDimitry Andric #define SANCOV_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
2968d75effSDimitry Andric #include "sancov_flags.inc"
3068d75effSDimitry Andric #undef SANCOV_FLAG
3168d75effSDimitry Andric }
3268d75effSDimitry Andric
RegisterSancovFlags(FlagParser * parser,SancovFlags * f)3368d75effSDimitry Andric static void RegisterSancovFlags(FlagParser *parser, SancovFlags *f) {
3468d75effSDimitry Andric #define SANCOV_FLAG(Type, Name, DefaultValue, Description) \
3568d75effSDimitry Andric RegisterFlag(parser, #Name, Description, &f->Name);
3668d75effSDimitry Andric #include "sancov_flags.inc"
3768d75effSDimitry Andric #undef SANCOV_FLAG
3868d75effSDimitry Andric }
3968d75effSDimitry Andric
InitializeSancovFlags()4068d75effSDimitry Andric void InitializeSancovFlags() {
4168d75effSDimitry Andric SancovFlags *f = sancov_flags();
4268d75effSDimitry Andric f->SetDefaults();
4368d75effSDimitry Andric
4468d75effSDimitry Andric FlagParser parser;
4568d75effSDimitry Andric RegisterSancovFlags(&parser, f);
4668d75effSDimitry Andric
47*0fca6ea1SDimitry Andric parser.ParseString(__sancov_default_options());
4868d75effSDimitry Andric parser.ParseStringFromEnv("SANCOV_OPTIONS");
4968d75effSDimitry Andric
5068d75effSDimitry Andric ReportUnrecognizedFlags();
5168d75effSDimitry Andric if (f->help) parser.PrintFlagDescriptions();
5268d75effSDimitry Andric }
5368d75effSDimitry Andric
5468d75effSDimitry Andric } // namespace __sancov
55