[PATCH] D51190: [AttrDocs]: document gnu_inline function attribute

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 29 15:49:34 PDT 2018

nickdesaulniers updated this revision to Diff 163215.
nickdesaulniers added a comment.

- link to correct doc
- explicitly mention extern inline
- s/c89/GNU inline extension/g and mention -std=gnu89/-fgnu89-inline
- Take rsmith's sugguested wording. Add info about __GNUC_STDC_INLINE__.
- some final touches recommended by rsmith

  rC Clang



Index: include/clang/Basic/AttrDocs.td
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3505,3 +3505,38 @@
 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. In particular, an out-of-line
+definition is still emitted for a function with external linkage, even if all
+call sites are inlined, unlike in C99 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.
+Some important consequences: ``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. It is
+unspecified which macro is defined in a C++ compilation.
+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
@@ -1168,7 +1168,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.163215.patch
Type: text/x-patch
Size: 2413 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180829/9a063da2/attachment.bin>

More information about the cfe-commits mailing list