[AArch64] Fix SDNode type mismatches between *.td files and ISel (#116523)
[llvm-project.git] / compiler-rt / lib / nsan / nsan_flags.cpp
blob94e3a187c8e6cc56baeb77533f3c359c6501ed8f
1 //===-- nsan_flags.cc -----------------------------------------------------===//
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 // This file is a part of NumericalStabilitySanitizer.
11 //===----------------------------------------------------------------------===//
13 #include "nsan_flags.h"
15 #include "sanitizer_common/sanitizer_flag_parser.h"
16 #include "sanitizer_common/sanitizer_flags.h"
18 using namespace __sanitizer;
19 using namespace __nsan;
21 SANITIZER_INTERFACE_WEAK_DEF(const char *, __nsan_default_options, void) {
22 return "";
25 Flags __nsan::flags_data;
27 void Flags::SetDefaults() {
28 #define NSAN_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
29 #include "nsan_flags.inc"
30 #undef NSAN_FLAG
33 void Flags::PopulateCache() {
34 cached_absolute_error_threshold =
35 1.0 / (1ull << log2_absolute_error_threshold);
38 static void RegisterNSanFlags(FlagParser *parser, Flags *f) {
39 #define NSAN_FLAG(Type, Name, DefaultValue, Description) \
40 RegisterFlag(parser, #Name, Description, &f->Name);
41 #include "nsan_flags.inc"
42 #undef NSAN_FLAG
45 static const char *MaybeCallNsanDefaultOptions() {
46 return (&__nsan_default_options) ? __nsan_default_options() : "";
49 void __nsan::InitializeFlags() {
50 SetCommonFlagsDefaults();
52 CommonFlags cf;
53 cf.CopyFrom(*common_flags());
54 cf.external_symbolizer_path = GetEnv("NSAN_SYMBOLIZER_PATH");
55 OverrideCommonFlags(cf);
58 flags().SetDefaults();
60 FlagParser parser;
61 RegisterCommonFlags(&parser);
62 RegisterNSanFlags(&parser, &flags());
64 const char *nsan_default_options = MaybeCallNsanDefaultOptions();
65 parser.ParseString(nsan_default_options);
67 parser.ParseString(GetEnv("NSAN_OPTIONS"));
68 InitializeCommonFlags();
69 if (Verbosity())
70 ReportUnrecognizedFlags();
71 if (common_flags()->help)
72 parser.PrintFlagDescriptions();
74 flags().PopulateCache();