Path: blob/main/contrib/llvm-project/compiler-rt/lib/nsan/nsan_flags.cpp
35233 views
//===-- nsan_flags.cc -----------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file is a part of NumericalStabilitySanitizer.9//10//===----------------------------------------------------------------------===//1112#include "nsan_flags.h"1314#include "sanitizer_common/sanitizer_flag_parser.h"15#include "sanitizer_common/sanitizer_flags.h"1617using namespace __sanitizer;18using namespace __nsan;1920SANITIZER_INTERFACE_WEAK_DEF(const char *, __nsan_default_options, void) {21return "";22}2324Flags __nsan::flags_data;2526void Flags::SetDefaults() {27#define NSAN_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;28#include "nsan_flags.inc"29#undef NSAN_FLAG30}3132void Flags::PopulateCache() {33cached_absolute_error_threshold =341.0 / (1ull << log2_absolute_error_threshold);35}3637static void RegisterNSanFlags(FlagParser *parser, Flags *f) {38#define NSAN_FLAG(Type, Name, DefaultValue, Description) \39RegisterFlag(parser, #Name, Description, &f->Name);40#include "nsan_flags.inc"41#undef NSAN_FLAG42}4344static const char *MaybeCallNsanDefaultOptions() {45return (&__nsan_default_options) ? __nsan_default_options() : "";46}4748void __nsan::InitializeFlags() {49SetCommonFlagsDefaults();50{51CommonFlags cf;52cf.CopyFrom(*common_flags());53cf.external_symbolizer_path = GetEnv("NSAN_SYMBOLIZER_PATH");54OverrideCommonFlags(cf);55}5657flags().SetDefaults();5859FlagParser parser;60RegisterCommonFlags(&parser);61RegisterNSanFlags(&parser, &flags());6263const char *nsan_default_options = MaybeCallNsanDefaultOptions();64parser.ParseString(nsan_default_options);6566parser.ParseString(GetEnv("NSAN_OPTIONS"));67InitializeCommonFlags();68if (Verbosity())69ReportUnrecognizedFlags();70if (common_flags()->help)71parser.PrintFlagDescriptions();7273flags().PopulateCache();74}757677