[clang] [Headers] Don't declare unreachable() from stddef.h in C++ (PR #86748)

Ian Anderson via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 12:41:17 PDT 2024


ian-twilightcoder wrote:

> I still don't understand how that works in case you do end up including a header from the platform that (re)defines `unreachable`, for example.
> 
> The same problem also applies today to e.g. `size_t` and anything else provided by the Clang builtin headers. If a platform decides to define `size_t` differently than what the Clang builtin headers define it to, I guess we run into issues? I assume it's not something that happens often because it's pretty unambiguous what these typedefs should be, but still.

We do indeed run into issues, the redeclarations cause two problems.
1. Modules get upset when different modules declare the same name somewhat differently.
2. Swift uses the module name as part of the type name, and ambiguities arise when different modules define the same type, even identically.

We're needing to carefully remove our duplications in the Apple headers and always use the clang builtins. The coupling is unfortunate, but I don't know of any practical way around it.

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


More information about the cfe-commits mailing list