I don't know how feasible this is to roll out on linux or other platforms
which may or may not have sympathetic libc maintainers. Assuming they aren't
sympathetic, you only have one less-great option IMO. That is that you hack
Clang to pattern match a well-known AST pattern into the
__builtin_errno_address builtin. For targets without a well-known pattern,
it would never add the "does not touch errno" attribute.
Would it be practical to determine the pattern by recognizing the definition
(or declaration, pre-'11) of errno? The language standards impose strict
conditions it must meet:
- be defined (declared) within <errno.h> or <cerrno>;
- in C11 and C++11, be a macro;
- pre-'11, alternatively be an identifier with external linkage.