[clang] [clang] return type not correctly deduced for discarded lambdas (PR #153921)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 16 14:45:52 PDT 2025


ojhunt wrote:

@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/153921


More information about the cfe-commits mailing list