1 //===-- esan_flags.cc -------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of EfficiencySanitizer, a family of performance tuners.
12 // Esan flag parsing logic.
13 //===----------------------------------------------------------------------===//
15 #include "esan_flags.h"
16 #include "sanitizer_common/sanitizer_common.h"
17 #include "sanitizer_common/sanitizer_flag_parser.h"
18 #include "sanitizer_common/sanitizer_flags.h"
22 static const char EsanOptsEnv
[] = "ESAN_OPTIONS";
24 Flags EsanFlagsDontUseDirectly
;
26 void Flags::setDefaults() {
27 #define ESAN_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
28 #include "esan_flags.inc"
32 static void registerEsanFlags(FlagParser
*Parser
, Flags
*F
) {
33 #define ESAN_FLAG(Type, Name, DefaultValue, Description) \
34 RegisterFlag(Parser, #Name, Description, &F->Name);
35 #include "esan_flags.inc"
39 void initializeFlags() {
40 SetCommonFlagsDefaults();
41 Flags
*F
= getFlags();
45 registerEsanFlags(&Parser
, F
);
46 RegisterCommonFlags(&Parser
);
47 Parser
.ParseString(GetEnv(EsanOptsEnv
));
49 InitializeCommonFlags();
51 ReportUnrecognizedFlags();
52 if (common_flags()->help
)
53 Parser
.PrintFlagDescriptions();
55 __sanitizer_set_report_path(common_flags()->log_path
);