[Sanitizer] Change InitializeFlags() signatures. NFC.

These functions are always used to initialize singleton flags(), as
well as other global data (common_flags()).

llvm-svn: 228894
This commit is contained in:
Alexey Samsonov 2015-02-12 00:36:42 +00:00
parent c9b0ea6eec
commit 1225816a2d
6 changed files with 23 additions and 23 deletions

View File

@ -46,14 +46,15 @@ void Flags::SetDefaults() {
#undef ASAN_FLAG
}
void RegisterAsanFlags(FlagParser *parser, Flags *f) {
static void RegisterAsanFlags(FlagParser *parser, Flags *f) {
#define ASAN_FLAG(Type, Name, DefaultValue, Description) \
RegisterFlag(parser, #Name, Description, &f->Name);
#include "asan_flags.inc"
#undef ASAN_FLAG
}
void InitializeFlags(Flags *f) {
void InitializeFlags() {
Flags *f = flags();
FlagParser parser;
RegisterAsanFlags(&parser, f);
RegisterCommonFlags(&parser);

View File

@ -41,8 +41,8 @@ extern Flags asan_flags_dont_use_directly;
inline Flags *flags() {
return &asan_flags_dont_use_directly;
}
void RegisterAsanFlags(FlagParser *parser, Flags *f);
void InitializeFlags(Flags *f);
void InitializeFlags();
} // namespace __asan

View File

@ -314,7 +314,7 @@ static void AsanInitInternal() {
// Initialize flags. This must be done early, because most of the
// initialization steps look at flags().
InitializeFlags(flags());
InitializeFlags();
SetCanPoisonMemory(flags()->poison_heap);
SetMallocContextSize(common_flags()->malloc_context_size);

View File

@ -317,18 +317,18 @@ void Flags::SetDefaults() {
#undef DFSAN_FLAG
}
void RegisterDfsanFlags(FlagParser *parser, Flags *f) {
static void RegisterDfsanFlags(FlagParser *parser, Flags *f) {
#define DFSAN_FLAG(Type, Name, DefaultValue, Description) \
RegisterFlag(parser, #Name, Description, &f->Name);
#include "dfsan_flags.inc"
#undef DFSAN_FLAG
}
static void InitializeFlags(Flags &f, const char *env) {
static void InitializeFlags() {
FlagParser parser;
RegisterDfsanFlags(&parser, &f);
f.SetDefaults();
parser.ParseString(env);
RegisterDfsanFlags(&parser, &flags());
flags().SetDefaults();
parser.ParseString(GetEnv("DFSAN_OPTIONS"));
}
static void dfsan_fini() {
@ -363,8 +363,7 @@ static void dfsan_init(int argc, char **argv, char **envp) {
if (!(init_addr >= kUnusedAddr && init_addr < kAppAddr))
Mprotect(kUnusedAddr, kAppAddr - kUnusedAddr);
InitializeFlags(flags(), GetEnv("DFSAN_OPTIONS"));
InitializeFlags();
InitializeInterceptors();
// Register the fini callback to run when the program terminates successfully

View File

@ -120,7 +120,7 @@ class FlagHandlerKeepGoing : public FlagHandlerBase {
}
};
void RegisterMsanFlags(FlagParser *parser, Flags *f) {
static void RegisterMsanFlags(FlagParser *parser, Flags *f) {
#define MSAN_FLAG(Type, Name, DefaultValue, Description) \
RegisterFlag(parser, #Name, Description, &f->Name);
#include "msan_flags.inc"
@ -132,7 +132,8 @@ void RegisterMsanFlags(FlagParser *parser, Flags *f) {
"deprecated, use halt_on_error");
}
static void InitializeFlags(Flags *f, const char *options) {
static void InitializeFlags() {
Flags *f = flags();
FlagParser parser;
RegisterMsanFlags(&parser, f);
RegisterCommonFlags(&parser);
@ -156,7 +157,9 @@ static void InitializeFlags(Flags *f, const char *options) {
if (__msan_default_options)
parser.ParseString(__msan_default_options());
parser.ParseString(options);
const char *msan_options = GetEnv("MSAN_OPTIONS");
parser.ParseString(msan_options);
VPrintf(1, "MSAN_OPTIONS: %s\n", msan_options ? msan_options : "<empty>");
SetVerbosity(common_flags()->verbosity);
@ -351,8 +354,7 @@ void __msan_init() {
SetDieCallback(MsanDie);
InitTlsSize();
const char *msan_options = GetEnv("MSAN_OPTIONS");
InitializeFlags(&msan_flags, msan_options);
InitializeFlags();
__sanitizer_set_report_path(common_flags()->log_path);
InitializeInterceptors();
@ -369,8 +371,6 @@ void __msan_init() {
ReExec();
}
VPrintf(1, "MSAN_OPTIONS: %s\n", msan_options ? msan_options : "<empty>");
__msan_clear_on_return();
if (__msan_get_track_origins())
VPrintf(1, "msan_track_origins\n");

View File

@ -65,8 +65,8 @@ u32 Callback::Unwind() {
return CurrentStackTrace(thr, 3);
}
void InitializeFlags(Flags *f, const char *env) {
internal_memset(f, 0, sizeof(*f));
static void InitializeFlags() {
Flags *f = flags();
// Default values.
f->second_deadlock_stack = false;
@ -84,7 +84,7 @@ void InitializeFlags(Flags *f, const char *env) {
FlagParser parser;
RegisterFlag(&parser, "second_deadlock_stack", "", &f->second_deadlock_stack);
RegisterCommonFlags(&parser);
parser.ParseString(env);
parser.ParseString(GetEnv("DSAN_OPTIONS"));
SetVerbosity(common_flags()->verbosity);
}
@ -93,7 +93,7 @@ void Initialize() {
ctx = new(ctx_mem) Context();
InitializeInterceptors();
InitializeFlags(flags(), GetEnv("DSAN_OPTIONS"));
InitializeFlags();
ctx->dd = DDetector::Create(flags());
}