mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-02 18:58:15 +00:00
[sanitizers] Do not define __has_feature in sanitizer/common_interface_defs.h (#66628)
Public headers intended for user code should not define `__has_feature`, because this can break preprocessor checks done later in user code, e.g. if they test `#ifdef __has_feature` to check for real support in the compiler. Replace the only use in the public header with a check for it being supported before trying to use it. Define the fallback definition in the internal headers, so that other internal sanitizer headers can continue to use it as preferred. This resolves a bug reported to GCC as https://gcc.gnu.org/PR109882
This commit is contained in:
parent
1d95a071d6
commit
c670cdb968
@ -50,7 +50,15 @@ void SANITIZER_CDECL __asan_unpoison_memory_region(void const volatile *addr,
|
||||
size_t size);
|
||||
|
||||
// Macros provided for convenience.
|
||||
#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
|
||||
#ifdef __has_feature
|
||||
#if __has_feature(address_sanitizer)
|
||||
#define ASAN_DEFINE_REGION_MACROS
|
||||
#endif
|
||||
#elif defined(__SANITIZE_ADDRESS__)
|
||||
#define ASAN_DEFINE_REGION_MACROS
|
||||
#endif
|
||||
|
||||
#ifdef ASAN_DEFINE_REGION_MACROS
|
||||
/// Marks a memory region as unaddressable.
|
||||
///
|
||||
/// \note Macro provided for convenience; defined as a no-op if ASan is not
|
||||
@ -74,6 +82,7 @@ void SANITIZER_CDECL __asan_unpoison_memory_region(void const volatile *addr,
|
||||
#define ASAN_POISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size))
|
||||
#define ASAN_UNPOISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size))
|
||||
#endif
|
||||
#undef ASAN_DEFINE_REGION_MACROS
|
||||
|
||||
/// Checks if an address is poisoned.
|
||||
///
|
||||
|
@ -15,11 +15,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// GCC does not understand __has_feature.
|
||||
#if !defined(__has_feature)
|
||||
#define __has_feature(x) 0
|
||||
#endif
|
||||
|
||||
// Windows allows a user to set their default calling convention, but we always
|
||||
// use __cdecl
|
||||
#ifdef _WIN32
|
||||
|
@ -15,6 +15,11 @@
|
||||
#include "sanitizer_platform.h"
|
||||
#include "sanitizer_redefine_builtins.h"
|
||||
|
||||
// GCC does not understand __has_feature.
|
||||
#if !defined(__has_feature)
|
||||
#define __has_feature(x) 0
|
||||
#endif
|
||||
|
||||
#ifndef SANITIZER_DEBUG
|
||||
# define SANITIZER_DEBUG 0
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user