[clang] [Clang] Add __ugly__ spelling for the msvc attribute scope (PR #113765)

Nikolas Klauser via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 30 06:00:58 PDT 2024


philnik777 wrote:

> > > > The MSVC FE team hasn't expressed enthusiasm for adding ugly spellings. If I learn more I'll relay that info.
> > > 
> > > 
> > > Thank you for checking! Unfortunately, I think that's a reason for Clang to not support it for the `msvc` vendor prefix either.
> > 
> > 
> > What is the alternative?
> 
> Can you get away with not using `[[msvc::no_unique_address]]`? If so, I'd go that route.
No. We need it to have a reasonable ABI.
> If not, I'd say use the attribute with the non-ugly spelling and woe unto anyone defining `msvc` as a macro despite that being a perfectly valid thing for them to do. You could be "kind" and do
> 
> ```
> #ifdef msvc
> #error "Microsoft's vendor specific attribute prefix steals this identifier from the user's namespace, please file an issue with Microsoft if you see this diagnostic"
> #endif
> ```
> 
> or something along those lines.

This steals both `msvc` and `no_unique_address` and does that on all platforms, not just MSVC, so that's not exactly a thrilling solution. Would defining a namespace like `__clang_msvc__` be an option? libc++ only cares about Clang on MSVC targets, so it's pretty much irrelevant what MSVC does for us. Adding an alias like `[[_Clang::__no_unique_address__]]` would also work if that's more palatable. That'd have to be added to any msvc attributes libc++ cares about of course (though currently that's only `[[msvc::no_unique_address]]`).


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


More information about the cfe-commits mailing list