[clang] [llvm] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)

Aaron Ballman via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 12:11:02 PST 2025


AaronBallman wrote:

> I saw this got updates over break. Did LWG make its decision already? Are you expecting re-review? I didn't see anything go across my emails about LWG, but I could definitely have missed it.

The LWG issue is still open: https://cplusplus.github.io/LWG/issue4149 but doesn't seem to be under active discussion any longer. My reading of the reflector thread is that my suggested approach is not quite correct. Consider a case like:
```
#define maybe_unused 12

#include <algorithm>
```
where the namespace isn't going to be declared (aka header not included) at the time the `#define` happens. We could aim for a perfect analysis here, but it gets pretty complicated, so I am leaning towards always issuing a `-Wreserved-attribute-identifier` warning when we see the `#define` of a standard attribute name. It does mean false positives are possible, but the amount of C++ code that does not include a standard library header anywhere in the TU *and* defines standard attribute identifiers as macro names is hopefully quite small.

WDYT @erichkeane?

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


More information about the llvm-commits mailing list