[ASan] make sure __asan_default_options gets default visibility, port corresponding test to lit

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@161869 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/asan/asan_flags.h b/lib/asan/asan_flags.h
index 5c18a31..3e37550 100644
--- a/lib/asan/asan_flags.h
+++ b/lib/asan/asan_flags.h
@@ -25,7 +25,8 @@
 
 extern "C" {
 // Can be overriden by user.
-const char *__asan_default_options() SANITIZER_WEAK_ATTRIBUTE;
+const char *__asan_default_options()
+    SANITIZER_WEAK_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE;
 }  // extern "C"
 
 namespace __asan {
diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc
index f0c51c9..a798314 100644
--- a/lib/asan/asan_rtl.cc
+++ b/lib/asan/asan_rtl.cc
@@ -101,7 +101,9 @@
 }
 
 extern "C" {
-const char* WEAK __asan_default_options() { return ""; }
+SANITIZER_WEAK_ATTRIBUTE
+SANITIZER_INTERFACE_ATTRIBUTE
+const char* __asan_default_options() { return ""; }
 }  // extern "C"
 
 void InitializeFlags(Flags *f, const char *env) {
diff --git a/lib/asan/lit_tests/default_options.cc b/lib/asan/lit_tests/default_options.cc
new file mode 100644
index 0000000..5468062
--- /dev/null
+++ b/lib/asan/lit_tests/default_options.cc
@@ -0,0 +1,15 @@
+// RUN: %clang_asan -O2 %s -o %t
+// RUN: %t 2>&1 | FileCheck %s
+
+const char *kAsanDefaultOptions="verbosity=1 foo=bar";
+
+extern "C"
+__attribute__((no_address_safety_analysis))
+const char *__asan_default_options() {
+  // CHECK: Using the defaults from __asan_default_options: {{.*}} foo=bar
+  return kAsanDefaultOptions;
+}
+
+int main() {
+  return 0;
+}