[PATCH] D84005: Introduce ns_error_domain attribute.
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 17 02:09:49 PDT 2020
gribozavr2 added inline comments.
================
Comment at: clang/include/clang/Basic/Attr.td:1860
+def NSErrorDomain : Attr {
+ let Spellings = [GNU<"ns_error_domain">];
+ let Args = [IdentifierArgument<"ErrorDomain">];
----------------
Could we try to add a list of subjects here? It seems like it is a type-only attribute, and most likely enum-only.
let Subjects = SubjectList<[Enum]>;
================
Comment at: clang/include/clang/Basic/AttrDocs.td:3317
+def NSErrorDomainDocs : Documentation {
+ let Category = DocCatFunction;
+ let Content = [{
----------------
Shouldn't the category be DocCatType since it is a type attribute?
================
Comment at: clang/include/clang/Basic/AttrDocs.td:3319
+ let Content = [{
+The ``ns_error_domain`` attribute indicates a global constant representing the error domain.
+ }];
----------------
I think we should try to expand the docs. For example:
In Cocoa frameworks in Objective-C, one can group related error codes in enums, and categorize these enums with error domains.
The ``ns_error_domain`` attribute specifies the error domain that error codes belong to. This attribute is attached to enums that describe error codes.
This metadata is useful for documentation purposes, for static analysis, and for improving interoperability between Objective-C and Swift. It is not used for code generation in Objective-C.
For example:
(insert an example from tests)
================
Comment at: clang/test/Analysis/ns_error_enum.m:1
+// RUN: %clang_cc1 -verify %s
+
----------------
This file is a `.m` -- any specific reason? I'd call it `.c` and run the test in C, Objective-C, and C++ modes (enums might work slightly differently, the name lookup functionality might work differently).
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