Caffe2 - C++ API
A deep learning, cross platform ML framework
asan.h
1 #pragma once
2 
3 // Detect address sanitizer as some stuff doesn't work with it
4 
5 #undef CAFFE2_ASAN_ENABLED
6 
7 // for clang
8 #if defined(__has_feature)
9 #if ((__has_feature(address_sanitizer)))
10 #define CAFFE2_ASAN_ENABLED 1
11 #endif
12 #endif
13 
14 // for gcc
15 #if defined(__SANITIZE_ADDRESS__)
16 #if __SANITIZE_ADDRESS__
17 #if !defined(CAFFE2_ASAN_ENABLED)
18 #define CAFFE2_ASAN_ENABLED 1
19 #endif
20 #endif
21 #endif
22 
23 #if !defined(CAFFE2_ASAN_ENABLED)
24 #define CAFFE2_ASAN_ENABLED 0
25 #endif
26 
27 // Define sanitization macro
28 #if !CAFFE2_ASAN_ENABLED
29 #define CAFFE2_NO_SANITIZE(...)
30 #else
31 #define CAFFE2_NO_SANITIZE(...) __attribute__((no_sanitize(__VA_ARGS__)))
32 #endif