[compiler-rt] f67fc3a - [sanitizer] Extract check_mem_is_good into header
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 7 12:06:54 PDT 2022
Author: Vitaly Buka
Date: 2022-07-07T12:06:49-07:00
New Revision: f67fc3acad70c20d8088b72ee9563690c8ab9be0
URL: https://github.com/llvm/llvm-project/commit/f67fc3acad70c20d8088b72ee9563690c8ab9be0
DIFF: https://github.com/llvm/llvm-project/commit/f67fc3acad70c20d8088b72ee9563690c8ab9be0.diff
LOG: [sanitizer] Extract check_mem_is_good into header
Reviewed By: kstoimenov
Differential Revision: https://reviews.llvm.org/D129245
Added:
compiler-rt/test/sanitizer_common/sanitizer_specific.h
Modified:
compiler-rt/test/sanitizer_common/TestCases/Linux/open_memstream.cpp
compiler-rt/test/sanitizer_common/lit.common.cfg.py
Removed:
################################################################################
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/open_memstream.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/open_memstream.cpp
index cf31f44be7e96..196f39e2866f0 100644
--- 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 <stdlib.h>
#include <string.h>
-#ifndef __has_feature
-#define __has_feature(x) 0
-#endif
-
-#if __has_feature(memory_sanitizer)
-#include <sanitizer/msan_interface.h>
-static void check_mem_is_good(void *p, size_t s) {
- __msan_check_mem_is_initialized(p, s);
-}
-#elif __has_feature(address_sanitizer)
-#include <sanitizer/asan_interface.h>
-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
index 110314bbb4bdf..13a21c6c4adcd 100644
--- 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
index 0000000000000..1a802020cfd66
--- /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 <sanitizer/msan_interface.h>
+static void check_mem_is_good(void *p, size_t s) {
+ __msan_check_mem_is_initialized(p, s);
+}
+#elif __has_feature(address_sanitizer)
+# include <sanitizer/asan_interface.h>
+# include <stdlib.h>
+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
More information about the llvm-commits
mailing list