ojhunt wrote:

Today, in the correct PR:

@AaronBallman @cor3ntin I have an idea, and I'd like to see what you think. We 
currently have the misery of these has_feature checks, I'm wondering if we can 
make them _all_ darwin only, so for each one, say ptrauth_calls we add a 
predefined macro like `__PTRAUTH_ABI_PTRAUTH_CALLS__`, then in `ptrauth.h` we 
add

```c++
// ptrauth.h
#if !defined(__PTRAUTH__) && whatever_backwards_compat_check_darwin_needs
#define __PTRAUTH__
#endif

#ifdef __PTRAUTH__
#ifdef __PTRAUTH_ABI_PTRAUTH_CALLS__
  #define __ptrauth_internal_has_abi_define_ptrauth_calls__
#endif
#ifdef __PTRAUTH_ABI_PTRAUTH_RETURNS__
  #define __ptrauth_internal_has_abi_define_ptrauth_returns__
#endif
#define __has_ptrauth_feature(feature_name) \
  __has_feature(feature_name) || 
defined(_____ptrauth_internal_has_abi_define_##feature_name##__)
#else
#define __has_ptrauth_feature(feature_name) 0
#endif
  
#if defined(__PTRAUTH__)
  ... all the usual defines ...
#else
  .. the fallback no op defines ...
#endif
```

Then we can limit the feature checks for everything other than darwin, and 
we'll work towards migrating away from __has_feature(...)

https://github.com/llvm/llvm-project/pull/153912
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to