[PATCH] D84005: Introduce ns_error_domain attribute.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 26 09:11:49 PDT 2020


aaron.ballman added a comment.

In D84005#2172747 <https://reviews.llvm.org/D84005#2172747>, @doug.gregor wrote:

> In D84005#2171982 <https://reviews.llvm.org/D84005#2171982>, @MForster wrote:
>
> > @milseman, @doug.gregor, could you please help with the open questions on this review?
> >
> > Specifically:
> >
> > - Is `ns_error_domain` ever needed for something other than an enum?
>
>
> No, it only makes sense on enums.
>
> > - Why is this designed in the way it is (requiring an identifier for the domain, not allowing literals and then only using the name of the identifier from Swift)?
>
> It's codifying the design of NSError, which has been this way since... longer than Clang has existed, and is independent of Swift. NSErrors have a domain (identified by an NSString constant symbol, not a literal, for pointer uniqueness and code size)  and a code (an integer, conventionally defined by an enum). The two need to be used together, e.g., you create an NSError with a domain and a code from that domain. This attribute finally ties those things together at the source level.


Ah, thank you, that makes the design far more clear to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84005/new/

https://reviews.llvm.org/D84005





More information about the cfe-commits mailing list