r201715 - Moving the documentation for the clang::fallthrough attribute into AttrDocs.
Richard Smith
richard at metafoo.co.uk
Wed Feb 19 15:23:03 PST 2014
On Wed, Feb 19, 2014 at 12:56 PM, Aaron Ballman <aaron at aaronballman.com>wrote:
> Author: aaronballman
> Date: Wed Feb 19 14:56:51 2014
> New Revision: 201715
>
> URL: http://llvm.org/viewvc/llvm-project?rev=201715&view=rev
> Log:
> Moving the documentation for the clang::fallthrough attribute into
> AttrDocs.
>
> Modified:
> cfe/trunk/docs/LanguageExtensions.rst
> cfe/trunk/include/clang/Basic/Attr.td
> cfe/trunk/include/clang/Basic/AttrDocs.td
>
> Modified: cfe/trunk/docs/LanguageExtensions.rst
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=201715&r1=201714&r2=201715&view=diff
>
> ==============================================================================
> --- cfe/trunk/docs/LanguageExtensions.rst (original)
> +++ cfe/trunk/docs/LanguageExtensions.rst Wed Feb 19 14:56:51 2014
> @@ -1570,51 +1570,6 @@ Non-standard C++11 Attributes
> Clang's non-standard C++11 attributes live in the ``clang`` attribute
> namespace.
>
> -The ``clang::fallthrough`` attribute
> -------------------------------------
> -
> -The ``clang::fallthrough`` attribute is used along with the
> -``-Wimplicit-fallthrough`` argument to annotate intentional fall-through
> -between switch labels. It can only be applied to a null statement placed
> at a
> -point of execution between any statement and the next switch label. It is
> -common to mark these places with a specific comment, but this attribute is
> -meant to replace comments with a more strict annotation, which can be
> checked
> -by the compiler. This attribute doesn't change semantics of the code and
> can
> -be used wherever an intended fall-through occurs. It is designed to mimic
> -control-flow statements like ``break;``, so it can be placed in most
> places
> -where ``break;`` can, but only if there are no statements on the
> execution path
> -between it and the next switch label.
> -
> -Here is an example:
> -
> -.. code-block:: c++
> -
> - // compile with -Wimplicit-fallthrough
> - switch (n) {
> - case 22:
> - case 33: // no warning: no statements between case labels
> - f();
> - case 44: // warning: unannotated fall-through
> - g();
> - [[clang::fallthrough]];
> - case 55: // no warning
> - if (x) {
> - h();
> - break;
> - }
> - else {
> - i();
> - [[clang::fallthrough]];
> - }
> - case 66: // no warning
> - p();
> - [[clang::fallthrough]]; // warning: fallthrough annotation does not
> - // directly precede case label
> - q();
> - case 77: // warning: unannotated fall-through
> - r();
> - }
> -
> ``gnu::`` attributes
> --------------------
>
This change has left the remaining text here a bit broken: "Clang also
supports GCC's gnu attribute namespace [...]".
Modified: cfe/trunk/include/clang/Basic/Attr.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=201715&r1=201714&r2=201715&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/Attr.td (original)
> +++ cfe/trunk/include/clang/Basic/Attr.td Wed Feb 19 14:56:51 2014
> @@ -642,7 +642,7 @@ def ExtVectorType : Attr {
> def FallThrough : Attr {
> let Spellings = [CXX11<"clang", "fallthrough">];
> // let Subjects = [NullStmt];
> - let Documentation = [Undocumented];
> + let Documentation = [FallthroughDocs];
> }
>
> def FastCall : InheritableAttr {
>
> Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=201715&r1=201714&r2=201715&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
> +++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed Feb 19 14:56:51 2014
> @@ -410,3 +410,50 @@ When one method overrides another, the o
> @end
> }];
> }
> +
> +def FallthroughDocs : Documentation {
> + let Category = DocCatStmt;
> + let Content = [{
> +The ``clang::fallthrough`` attribute is used along with the
> +``-Wimplicit-fallthrough`` argument to annotate intentional fall-through
> +between switch labels. It can only be applied to a null statement placed
> at a
> +point of execution between any statement and the next switch label. It is
> +common to mark these places with a specific comment, but this attribute is
> +meant to replace comments with a more strict annotation, which can be
> checked
> +by the compiler. This attribute doesn't change semantics of the code and
> can
> +be used wherever an intended fall-through occurs. It is designed to mimic
> +control-flow statements like ``break;``, so it can be placed in most
> places
> +where ``break;`` can, but only if there are no statements on the
> execution path
> +between it and the next switch label.
> +
> +Here is an example:
> +
> +.. code-block:: c++
> +
> + // compile with -Wimplicit-fallthrough
> + switch (n) {
> + case 22:
> + case 33: // no warning: no statements between case labels
> + f();
> + case 44: // warning: unannotated fall-through
> + g();
> + [[clang::fallthrough]];
> + case 55: // no warning
> + if (x) {
> + h();
> + break;
> + }
> + else {
> + i();
> + [[clang::fallthrough]];
> + }
> + case 66: // no warning
> + p();
> + [[clang::fallthrough]]; // warning: fallthrough annotation does not
> + // directly precede case label
> + q();
> + case 77: // warning: unannotated fall-through
> + r();
> + }
> + }];
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140219/72bac99f/attachment.html>
More information about the cfe-commits
mailing list