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

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 27 17:35:03 PDT 2018


rsmith added inline comments.


================
Comment at: include/clang/Basic/AttrDocs.td:3514-3516
+(possibly due to being referred to by function pointer), then no out of line
+definition will be emitted (instead of c99's behaviour of always emitting an
+out of line definition).
----------------
This description is neither entirely correct nor complete. `gnu_inline` means:

 * 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.

Please capitalize the C in C99.


================
Comment at: include/clang/Basic/AttrDocs.td:3518-3522
+If ``__GNUC_STDC_INLINE__`` is defined, then the current translation unit is
+not being compiled with ``gnu_inline`` semantics, and the ``gnu_inline``
+function attribute can be used to get GNU inline semantics on a per function basis.
+If ``__GNUC_STDC_INLINE__`` is not defined, then the translation unit is
+already being compiled with GNU inline semantics as the implied default.
----------------
It would make sense to also mention `__GNUC_GNU_INLINE__` here, and that exactly one of these two macros will be defined for any compilation (although the macros are meaningless in C++ and should not be used there).


================
Comment at: include/clang/Basic/AttrDocs.td:3524
+
+This is the default behavior with ``-std=gnu89`` or ``-fgnu89-inline``.
+  }];
----------------
This is the default behavior for all pre-C99 C compilations, notably including `-std=c89` (and `-std=c94`).


Repository:
  rC Clang

https://reviews.llvm.org/D51190





More information about the cfe-commits mailing list