|
@@ -1686,7 +1686,7 @@ semantic checking for some attributes, etc.
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
The first step to adding a new attribute to Clang is to add its definition to
|
|
The first step to adding a new attribute to Clang is to add its definition to
|
|
`include/clang/Basic/Attr.td
|
|
`include/clang/Basic/Attr.td
|
|
-<https://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?view=markup>`_.
|
|
|
|
|
|
+<https://github.com/llvm/llvm-project/blob/master/clang/include/clang/Basic/Attr.td>`_.
|
|
This tablegen definition must derive from the ``Attr`` (tablegen, not
|
|
This tablegen definition must derive from the ``Attr`` (tablegen, not
|
|
semantic) type, or one of its derivatives. Most attributes will derive from the
|
|
semantic) type, or one of its derivatives. Most attributes will derive from the
|
|
``InheritableAttr`` type, which specifies that the attribute can be inherited by
|
|
``InheritableAttr`` type, which specifies that the attribute can be inherited by
|
|
@@ -1748,10 +1748,10 @@ the ``SubjectList``. The diagnostics generated for subject list violations are
|
|
either ``diag::warn_attribute_wrong_decl_type`` or
|
|
either ``diag::warn_attribute_wrong_decl_type`` or
|
|
``diag::err_attribute_wrong_decl_type``, and the parameter enumeration is found
|
|
``diag::err_attribute_wrong_decl_type``, and the parameter enumeration is found
|
|
in `include/clang/Sema/ParsedAttr.h
|
|
in `include/clang/Sema/ParsedAttr.h
|
|
-<https://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/ParsedAttr.h?view=markup>`_
|
|
|
|
|
|
+<https://github.com/llvm/llvm-project/blob/master/clang/include/clang/Sema/ParsedAttr.h>`_
|
|
If a previously unused Decl node is added to the ``SubjectList``, the logic used
|
|
If a previously unused Decl node is added to the ``SubjectList``, the logic used
|
|
to automatically determine the diagnostic parameter in `utils/TableGen/ClangAttrEmitter.cpp
|
|
to automatically determine the diagnostic parameter in `utils/TableGen/ClangAttrEmitter.cpp
|
|
-<https://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?view=markup>`_
|
|
|
|
|
|
+<https://github.com/llvm/llvm-project/blob/master/clang/utils/TableGen/ClangAttrEmitter.cpp>`_
|
|
may need to be updated.
|
|
may need to be updated.
|
|
|
|
|
|
By default, all subjects in the SubjectList must either be a Decl node defined
|
|
By default, all subjects in the SubjectList must either be a Decl node defined
|
|
@@ -1773,7 +1773,7 @@ All attributes must have some form of documentation associated with them.
|
|
Documentation is table generated on the public web server by a server-side
|
|
Documentation is table generated on the public web server by a server-side
|
|
process that runs daily. Generally, the documentation for an attribute is a
|
|
process that runs daily. Generally, the documentation for an attribute is a
|
|
stand-alone definition in `include/clang/Basic/AttrDocs.td
|
|
stand-alone definition in `include/clang/Basic/AttrDocs.td
|
|
-<https://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttdDocs.td?view=markup>`_
|
|
|
|
|
|
+<https://github.com/llvm/llvm-project/blob/master/clang/include/clang/Basic/AttrDocs.td>`_
|
|
that is named after the attribute being documented.
|
|
that is named after the attribute being documented.
|
|
|
|
|
|
If the attribute is not for public consumption, or is an implicitly-created
|
|
If the attribute is not for public consumption, or is an implicitly-created
|
|
@@ -1824,7 +1824,7 @@ All arguments have a name and a flag that specifies whether the argument is
|
|
optional. The associated C++ type of the argument is determined by the argument
|
|
optional. The associated C++ type of the argument is determined by the argument
|
|
definition type. If the existing argument types are insufficient, new types can
|
|
definition type. If the existing argument types are insufficient, new types can
|
|
be created, but it requires modifying `utils/TableGen/ClangAttrEmitter.cpp
|
|
be created, but it requires modifying `utils/TableGen/ClangAttrEmitter.cpp
|
|
-<https://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?view=markup>`_
|
|
|
|
|
|
+<https://github.com/llvm/llvm-project/blob/master/clang/utils/TableGen/ClangAttrEmitter.cpp>`_
|
|
to properly support the type.
|
|
to properly support the type.
|
|
|
|
|
|
Other Properties
|
|
Other Properties
|
|
@@ -1836,7 +1836,7 @@ document, however a few deserve mention.
|
|
If the parsed form of the attribute is more complex, or differs from the
|
|
If the parsed form of the attribute is more complex, or differs from the
|
|
semantic form, the ``HasCustomParsing`` bit can be set to ``1`` for the class,
|
|
semantic form, the ``HasCustomParsing`` bit can be set to ``1`` for the class,
|
|
and the parsing code in `Parser::ParseGNUAttributeArgs()
|
|
and the parsing code in `Parser::ParseGNUAttributeArgs()
|
|
-<https://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?view=markup>`_
|
|
|
|
|
|
+<https://github.com/llvm/llvm-project/blob/master/clang/lib/Parse/ParseDecl.cpp>`_
|
|
can be updated for the special case. Note that this only applies to arguments
|
|
can be updated for the special case. Note that this only applies to arguments
|
|
with a GNU spelling -- attributes with a __declspec spelling currently ignore
|
|
with a GNU spelling -- attributes with a __declspec spelling currently ignore
|
|
this flag and are handled by ``Parser::ParseMicrosoftDeclSpec``.
|
|
this flag and are handled by ``Parser::ParseMicrosoftDeclSpec``.
|
|
@@ -1899,7 +1899,7 @@ semantic attribute class object, with ``public`` access.
|
|
Boilerplate
|
|
Boilerplate
|
|
^^^^^^^^^^^
|
|
^^^^^^^^^^^
|
|
All semantic processing of declaration attributes happens in `lib/Sema/SemaDeclAttr.cpp
|
|
All semantic processing of declaration attributes happens in `lib/Sema/SemaDeclAttr.cpp
|
|
-<https://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?view=markup>`_,
|
|
|
|
|
|
+<https://github.com/llvm/llvm-project/blob/master/clang/lib/Sema/SemaDeclAttr.cpp>`_,
|
|
and generally starts in the ``ProcessDeclAttribute()`` function. If the
|
|
and generally starts in the ``ProcessDeclAttribute()`` function. If the
|
|
attribute is a "simple" attribute -- meaning that it requires no custom semantic
|
|
attribute is a "simple" attribute -- meaning that it requires no custom semantic
|
|
processing aside from what is automatically provided, add a call to
|
|
processing aside from what is automatically provided, add a call to
|
|
@@ -1915,11 +1915,11 @@ correct minimum number of arguments are passed, etc.
|
|
|
|
|
|
If the attribute adds additional warnings, define a ``DiagGroup`` in
|
|
If the attribute adds additional warnings, define a ``DiagGroup`` in
|
|
`include/clang/Basic/DiagnosticGroups.td
|
|
`include/clang/Basic/DiagnosticGroups.td
|
|
-<https://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?view=markup>`_
|
|
|
|
|
|
+<https://github.com/llvm/llvm-project/blob/master/clang/include/clang/Basic/DiagnosticGroups.td>`_
|
|
named after the attribute's ``Spelling`` with "_"s replaced by "-"s. If there
|
|
named after the attribute's ``Spelling`` with "_"s replaced by "-"s. If there
|
|
is only a single diagnostic, it is permissible to use ``InGroup<DiagGroup<"your-attribute">>``
|
|
is only a single diagnostic, it is permissible to use ``InGroup<DiagGroup<"your-attribute">>``
|
|
directly in `DiagnosticSemaKinds.td
|
|
directly in `DiagnosticSemaKinds.td
|
|
-<https://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?view=markup>`_
|
|
|
|
|
|
+<https://github.com/llvm/llvm-project/blob/master/clang/include/clang/Basic/DiagnosticSemaKinds.td>`_
|
|
|
|
|
|
All semantic diagnostics generated for your attribute, including automatically-
|
|
All semantic diagnostics generated for your attribute, including automatically-
|
|
generated ones (such as subjects and argument counts), should have a
|
|
generated ones (such as subjects and argument counts), should have a
|