[clang] [Clang] Add C++11/C23-style spellings for Swift import attributes (PR #183484)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 15 11:49:59 PDT 2026


AaronBallman wrote:

>>  I believe that these would be the clang namespaced attributes? I wonder if we want to consider a separate domain (e.g. [[swift::swift_attr]]).
> Yes, attributes that already support [[]]-style spelling, such as swift_async and swift_async_error, use the clang namespace, and this change would follow the same convention.

I leave the vendor namespace decision to @rjmccall as a Swift maintainer; I don't know enough about Swift to feel confident making a call here. But the way I think of it is: if there's an argument about the behavior of an attribute, whichever vendor decides the semantics for the attribute is the vendor to use as a prefix. e.g., if Clang can modify the semantics of these attributes with the expectation that Swift has to react to it, then they're `clang` attributes; if Clang can't modify the semantics without agreement from Swift, then they're more `swift` attributes.

Also worth keeping in mind is that `[[swift::swift_attr]]` is kind of odd due to repeating `swift` twice, whereas dropping the `swift` from the attribute name leaves us with `__attribute__((attr))` in the GNU form which is even worse. So there's some appeal to `[[clang::swift_attr]]` based on that alone.

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


More information about the cfe-commits mailing list