-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathsanitizers.cpp
More file actions
27 lines (26 loc) · 981 Bytes
/
sanitizers.cpp
File metadata and controls
27 lines (26 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Taken from: https://github.com/google/googletest/pull/3086/files
// Sanitizer Integration
// The
// [Undefined Behavior Sanitizer](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html),
// [Address Sanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer),
// and
// [Thread Sanitizer](https://github.com/google/sanitizers/wiki/ThreadSanitizerCppManual)
// all provide weak functions that you can override to trigger explicit failures
// when they detect sanitizer errors, such as creating a reference from `nullptr`.
// To override these functions, place definitions for them in a source file that
// you compile as part of your main binary
#include <gtest/gtest.h>
extern "C" {
void __ubsan_on_report()
{
FAIL() << "Encountered an undefined behavior sanitizer error";
}
void __asan_on_error()
{
FAIL() << "Encountered an address sanitizer error";
}
void __tsan_on_report()
{
FAIL() << "Encountered a thread sanitizer error";
}
} // extern "C"