diff options
author | Anna Zaks <ganna@apple.com> | 2016-09-15 21:02:18 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2016-09-15 21:02:18 +0000 |
commit | 691644f3ca6e7b0cd3acc0cf8ddde0e200bec2ae (patch) | |
tree | 1a0866389a84d9c65ebb5fb91501650911e317ec /compiler-rt/lib/sanitizer_common/tests | |
parent | 592bc4553306b250efe82ad37a0824addc1bf4ba (diff) | |
download | bcm5719-llvm-691644f3ca6e7b0cd3acc0cf8ddde0e200bec2ae.tar.gz bcm5719-llvm-691644f3ca6e7b0cd3acc0cf8ddde0e200bec2ae.zip |
[compiler-rt] Do not introduce __sanitizer namespace globally
The definitions in sanitizer_common may conflict with definitions from system headers because:
The runtime includes the system headers after the project headers (as per LLVM coding guidelines).
lib/sanitizer_common/sanitizer_internal_defs.h pollutes the namespace of everything defined after it, which is all/most of the sanitizer .h and .cc files and the included system headers with: using namespace __sanitizer; // NOLINT
This patch solves the problem by introducing the namespace only within the sanitizer namespaces as proposed by Dmitry.
Differential Revision: https://reviews.llvm.org/D21947
llvm-svn: 281657
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/tests')
4 files changed, 6 insertions, 2 deletions
diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc index b9e3c3bd7ce..02620a7e551 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_allocator_test.cc @@ -25,6 +25,8 @@ #include <vector> #include <set> +using namespace __sanitizer; + // Too slow for debug build #if !SANITIZER_DEBUG diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cc index 015e32a09e3..625257622bf 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_libc_test.cc @@ -25,6 +25,8 @@ # include "sanitizer_common/sanitizer_posix.h" #endif +using namespace __sanitizer; + // A regression test for internal_memmove() implementation. TEST(SanitizerCommon, InternalMemmoveRegression) { char src[] = "Hello World"; diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_nolibc_test_main.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_nolibc_test_main.cc index 72df621d07f..e761f00c56f 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_nolibc_test_main.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_nolibc_test_main.cc @@ -15,5 +15,5 @@ #include "sanitizer_common/sanitizer_libc.h" extern "C" void _start() { - internal__exit(0); + __sanitizer::internal__exit(0); } diff --git a/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_main.cc b/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_main.cc index 20f8f53975d..0da886120c3 100644 --- a/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_main.cc +++ b/compiler-rt/lib/sanitizer_common/tests/sanitizer_test_main.cc @@ -19,6 +19,6 @@ int main(int argc, char **argv) { argv0 = argv[0]; testing::GTEST_FLAG(death_test_style) = "threadsafe"; testing::InitGoogleTest(&argc, argv); - SetCommonFlagsDefaults(); + __sanitizer::SetCommonFlagsDefaults(); return RUN_ALL_TESTS(); } |