[compiler-rt] [sanitizers] Do not define __has_feature in sanitizer/common_interface_defs.h (PR #66628)

Jonathan Wakely via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 15:28:10 PDT 2023


================
@@ -48,7 +48,15 @@ void __asan_poison_memory_region(void const volatile *addr, size_t size);
 void __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)
----------------
jwakely wrote:

The `#ifdef` on line 51 starts a group that ends with the `#elif` on line 55, which starts a new group that ends with the `#endif` on line 57.

The `#if` on line 51 starts a group that ends with the `#endif` on line 54.

Would it be clearer like this?

```c++
#ifdef __has_feature
# if __has_feature(address_sanitizer)
#  define ASAN_DEFINE_REGION_MACROS
# endif
#elif defined(__SANITIZE_ADDRESS__)
# define ASAN_DEFINE_REGION_MACROS
#endif
```

That's how I would format it in my own code, but that doesn't seem to be the prevailing style in the sanitizers.

https://github.com/llvm/llvm-project/pull/66628


More information about the llvm-commits mailing list