Factor ParseAsanOptions outside __asan_init
authorAlexander Potapenko <glider@google.com>
Fri, 25 May 2012 15:37:16 +0000 (15:37 +0000)
committerAlexander Potapenko <glider@google.com>
Fri, 25 May 2012 15:37:16 +0000 (15:37 +0000)
llvm-svn: 157473

compiler-rt/lib/asan/asan_rtl.cc

index f883d31..ac4c1ea 100644 (file)
@@ -424,15 +424,7 @@ void __asan_report_error(uintptr_t pc, uintptr_t bp, uintptr_t sp,
   AsanDie();
 }
 
-void __asan_init() {
-  if (asan_inited) return;
-  asan_init_is_running = true;
-
-  // Make sure we are not statically linked.
-  AsanDoesNotSupportStaticLinkage();
-
-  // flags
-  const char *options = AsanGetEnv("ASAN_OPTIONS");
+static void ParseAsanOptions(const char *options) {
   FLAG_malloc_context_size =
       IntFlagValue(options, "malloc_context_size=", kMallocContextSize);
   CHECK(FLAG_malloc_context_size <= kMallocContextSize);
@@ -476,11 +468,24 @@ void __asan_init() {
 
   FLAG_quarantine_size = IntFlagValue(options, "quarantine_size=",
       (ASAN_LOW_MEMORY) ? 1UL << 24 : 1UL << 28);
+}
+
+void __asan_init() {
+  if (asan_inited) return;
+  asan_init_is_running = true;
+
+  // Make sure we are not statically linked.
+  AsanDoesNotSupportStaticLinkage();
+
+  // flags
+  const char *options = AsanGetEnv("ASAN_OPTIONS");
 
   if (FLAG_v) {
     Report("Parsed ASAN_OPTIONS: %s\n", options);
   }
 
+  ParseAsanOptions(options);
+
   if (FLAG_atexit) {
     Atexit(asan_atexit);
   }