diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/open_memstream.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/open_memstream.cpp --- a/compiler-rt/test/sanitizer_common/TestCases/Linux/open_memstream.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/open_memstream.cpp @@ -7,23 +7,7 @@ #include #include -#ifndef __has_feature -#define __has_feature(x) 0 -#endif - -#if __has_feature(memory_sanitizer) -#include -static void check_mem_is_good(void *p, size_t s) { - __msan_check_mem_is_initialized(p, s); -} -#elif __has_feature(address_sanitizer) -#include -static void check_mem_is_good(void *p, size_t s) { - assert(__asan_region_is_poisoned(p, s) == 0); -} -#else -static void check_mem_is_good(void *p, size_t s) {} -#endif +#include "sanitizer_common/sanitizer_specific.h" static void run(bool flush) { char *buf; diff --git a/compiler-rt/test/sanitizer_common/lit.common.cfg.py b/compiler-rt/test/sanitizer_common/lit.common.cfg.py --- a/compiler-rt/test/sanitizer_common/lit.common.cfg.py +++ b/compiler-rt/test/sanitizer_common/lit.common.cfg.py @@ -57,6 +57,7 @@ extra_link_flags += ["-ldl"] clang_cflags = config.debug_info_flags + tool_cflags + [config.target_cflags] +clang_cflags += ["-I%s" % os.path.dirname(os.path.dirname(__file__))] clang_cflags += extra_link_flags clang_cxxflags = config.cxx_mode_flags + clang_cflags diff --git a/compiler-rt/test/sanitizer_common/sanitizer_specific.h b/compiler-rt/test/sanitizer_common/sanitizer_specific.h new file mode 100644 --- /dev/null +++ b/compiler-rt/test/sanitizer_common/sanitizer_specific.h @@ -0,0 +1,24 @@ +#ifndef __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__ +#define __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__ + +#ifndef __has_feature +# define __has_feature(x) 0 +#endif + +#if __has_feature(memory_sanitizer) +# include +static void check_mem_is_good(void *p, size_t s) { + __msan_check_mem_is_initialized(p, s); +} +#elif __has_feature(address_sanitizer) +# include +# include +static void check_mem_is_good(void *p, size_t s) { + if (__asan_region_is_poisoned(p, s)) + abort(); +} +#else +static void check_mem_is_good(void *p, size_t s) {} +#endif + +#endif // __SANITIZER_COMMON_SANITIZER_SPECIFIC_H__ \ No newline at end of file