[llvm-commits] [compiler-rt] r160712 - in /compiler-rt/trunk/lib/asan: asan_flags.h asan_rtl.cc output_tests/default_options.cc output_tests/test_output.sh

Alexander Potapenko glider at google.com
Wed Jul 25 02:18:44 PDT 2012


Author: glider
Date: Wed Jul 25 04:18:43 2012
New Revision: 160712

URL: http://llvm.org/viewvc/llvm-project?rev=160712&view=rev
Log:
Make __asan_default_options a weak function that returns a const char*.
Users may define it to override the default ASan options.
This function has to be marked with __attribute__((no_address_safety_analysis)), because it is called before ASan is fully initialized.

Add an output test checking the __asan_default_options functionality.

Added:
    compiler-rt/trunk/lib/asan/output_tests/default_options.cc   (with props)
Modified:
    compiler-rt/trunk/lib/asan/asan_flags.h
    compiler-rt/trunk/lib/asan/asan_rtl.cc
    compiler-rt/trunk/lib/asan/output_tests/test_output.sh

Modified: compiler-rt/trunk/lib/asan/asan_flags.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_flags.h?rev=160712&r1=160711&r2=160712&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_flags.h (original)
+++ compiler-rt/trunk/lib/asan/asan_flags.h Wed Jul 25 04:18:43 2012
@@ -25,7 +25,7 @@
 extern "C" {
 #if !defined(_WIN32)
   // We do not need to redefine the defaults right now on Windows.
-  char *__asan_default_options SANITIZER_WEAK_ATTRIBUTE;
+  const char *__asan_default_options() SANITIZER_WEAK_ATTRIBUTE;
 #endif
 }
 
@@ -89,6 +89,7 @@
   // to dump 16T+ core.
   bool disable_core;
 };
+
 Flags *flags();
 void InitializeFlags(Flags *f, const char *env);
 

Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=160712&r1=160711&r2=160712&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Jul 25 04:18:43 2012
@@ -128,10 +128,10 @@
   // Override from user-specified string.
 #if !defined(_WIN32)
   if (__asan_default_options) {
-    ParseFlagsFromString(f, __asan_default_options);
+    ParseFlagsFromString(f, __asan_default_options());
     if (flags()->verbosity) {
       Report("Using the defaults from __asan_default_options: %s\n",
-             __asan_default_options);
+             __asan_default_options());
     }
   }
 #endif

Added: compiler-rt/trunk/lib/asan/output_tests/default_options.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/default_options.cc?rev=160712&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/output_tests/default_options.cc (added)
+++ compiler-rt/trunk/lib/asan/output_tests/default_options.cc Wed Jul 25 04:18:43 2012
@@ -0,0 +1,12 @@
+const char *kAsanDefaultOptions="verbosity=1 foo=bar";
+
+extern "C"
+__attribute__((no_address_safety_analysis))
+const char *__asan_default_options() {
+  return kAsanDefaultOptions;
+}
+
+int main() {
+  // Check-Common: foo=bar
+  return 0;
+}

Propchange: compiler-rt/trunk/lib/asan/output_tests/default_options.cc
------------------------------------------------------------------------------
    svn:eol-style = LF

Modified: compiler-rt/trunk/lib/asan/output_tests/test_output.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/output_tests/test_output.sh?rev=160712&r1=160711&r2=160712&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/output_tests/test_output.sh (original)
+++ compiler-rt/trunk/lib/asan/output_tests/test_output.sh Wed Jul 25 04:18:43 2012
@@ -39,6 +39,8 @@
 export ASAN_OPTIONS=""
 rm ./a.out
 
+# FIXME: some tests do not need to be ran for all the combinations of arch
+# and optimization mode.
 for t in  *.cc; do
   for b in 32 64; do
     for O in 0 1 2 3; do





More information about the llvm-commits mailing list