1 // Copyright 2019 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // LeakSanitizer support. 6 7 #ifndef V8_BASE_SANITIZER_LSAN_H_ 8 #define V8_BASE_SANITIZER_LSAN_H_ 9 10 #include <type_traits> 11 12 #include "src/base/macros.h" 13 14 // There is no compile time flag for LSan, so enable this whenever ASan is 15 // enabled. Note that LSan can be used as part of ASan with 'detect_leaks=1'. 16 // On Windows, LSan is not implemented yet, so disable it there. 17 #if defined(V8_USE_ADDRESS_SANITIZER) && !defined(V8_OS_WIN) 18 19 #include <sanitizer/lsan_interface.h> 20 21 #define LSAN_IGNORE_OBJECT(ptr) __lsan_ignore_object(ptr) 22 23 #else // defined(V8_USE_ADDRESS_SANITIZER) && !defined(V8_OS_WIN) 24 25 #define LSAN_IGNORE_OBJECT(ptr) \ 26 static_assert(std::is_convertible<decltype(ptr), const void*>::value, \ 27 "LSAN_IGNORE_OBJECT can only be used with pointer types") 28 29 #endif // defined(V8_USE_ADDRESS_SANITIZER) && !defined(V8_OS_WIN) 30 31 #endif // V8_BASE_SANITIZER_LSAN_H_ 32