[PATCH] D51190: [AttrDocs]: document gnu_inline function attribute
Nick Desaulniers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 28 11:08:39 PDT 2018
nickdesaulniers updated this revision to Diff 162908.
nickdesaulniers added a comment.
- Take rsmith's sugguested wording. Add info about __GNUC_STDC_INLINE__.
Repository:
rC Clang
https://reviews.llvm.org/D51190
Files:
include/clang/Basic/Attr.td
include/clang/Basic/AttrDocs.td
Index: include/clang/Basic/AttrDocs.td
===================================================================
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3505,3 +3505,37 @@
invoking clang with -fno-c++-static-destructors.
}];
}
+
+def GnuInlineDocs : Documentation {
+ let Category = DocCatFunction;
+ let Content = [{
+The ``gnu_inline`` changes the meaning of ``extern inline`` to use GNU inline
+semantics, meaning:
+
+* If any declaration that is declared ``inline`` is not declared ``extern``,
+then the ``inline`` keyword is just a hint (note that this is different from
+the behavior of ``inline`` in both C99 inline semantics and C++ inline
+semantics).
+
+* If all declarations that are declared ``inline`` are also declared
+``extern``, then the function body is present only for inlining and no
+out-of-line version is emitted.
+
+And in particular as special cases, ``static inline`` emits an out-of-line
+version if needed, a plain ``inline`` definition emits an out-of-line version
+always, and an ``extern inline`` definition (in a header) followed by a
+(non-``extern``) ``inline`` declaration in a source file emits an out-of-line
+version of the function in that source file but provides the function body for
+inlining to all includers of the header.
+
+Either ``__GNUC_GNU_INLINE__`` (GNU inline semantics) or
+``__GNUC_STDC_INLINE__`` (C99 semantics) will be defined (they are mutually
+exclusive). If ``__GNUC_STDC_INLINE__`` is defined, then the ``gnu_inline``
+function attribute can be used to get GNU inline semantics on a per function
+basis. If ``__GNUC_GNU_INLINE__`` is defined, then the translation unit is
+already being compiled with GNU inline semantics as the implied default.
+
+GNU inline semantics are the default behavior with ``-std=gnu89``,
+``-std=c89``, ``-std=c94``, or ``-fgnu89-inline``.
+ }];
+}
Index: include/clang/Basic/Attr.td
===================================================================
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -1170,7 +1170,7 @@
def GNUInline : InheritableAttr {
let Spellings = [GCC<"gnu_inline">];
let Subjects = SubjectList<[Function]>;
- let Documentation = [Undocumented];
+ let Documentation = [GnuInlineDocs];
}
def Hot : InheritableAttr {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51190.162908.patch
Type: text/x-patch
Size: 2300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180828/2bfff6ff/attachment.bin>
More information about the cfe-commits
mailing list