8274400: HotSpot Style Guide should permit use of alignof

Reviewed-by: kbarrett, kvn, dholmes, dcubed
This commit is contained in:
Julian Waters 2023-03-11 14:36:56 +00:00
parent 98a7a60fcb
commit a06426a52f
2 changed files with 18 additions and 2 deletions

View File

@ -598,10 +598,17 @@ conventions might appear jarring and reduce readability.</p></li>
<code>std::nothrow</code>, and <code>std::nothrow_t</code>.</li>
<li><code>#include &lt;limits&gt;</code> to use
<code>std::numeric_limits</code>.</li>
<li><code>#include &lt;type_traits&gt;</code>.</li>
<li><code>#include &lt;type_traits&gt;</code> with some restrictions,
listed below.</li>
<li><code>#include &lt;cstddef&gt;</code> to use
<code>std::nullptr_t</code> and <code>std::max_align_t</code>.</li>
</ul>
<p>Certain restrictions apply to the declarations provided by
<code>&lt;type_traits&gt;</code>.</p>
<ul>
<li>The <code>alignof</code> operator should be used rather than
<code>std::alignment_of&lt;&gt;</code>.</li>
</ul>
<p>TODO: Rather than directly #including (permitted) Standard Library
headers, use a convention of #including wrapper headers (in some
location like hotspot/shared/stdcpp). This provides a single place for
@ -1086,6 +1093,8 @@ function name and the parameter list.</li>
<h3 id="additional-permitted-features">Additional Permitted
Features</h3>
<ul>
<li><p><code>alignof</code> (<a
href="https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf">n2341</a>)</p></li>
<li><p><code>constexpr</code> (<a
href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf">n2235</a>)
(<a

View File

@ -572,9 +572,13 @@ There are a few exceptions to this rule.
* `#include <new>` to use placement `new`, `std::nothrow`, and `std::nothrow_t`.
* `#include <limits>` to use `std::numeric_limits`.
* `#include <type_traits>`.
* `#include <type_traits>` with some restrictions, listed below.
* `#include <cstddef>` to use `std::nullptr_t` and `std::max_align_t`.
Certain restrictions apply to the declarations provided by `<type_traits>`.
* The `alignof` operator should be used rather than `std::alignment_of<>`.
TODO: Rather than directly \#including (permitted) Standard Library
headers, use a convention of \#including wrapper headers (in some
location like hotspot/shared/stdcpp). This provides a single place
@ -1082,6 +1086,9 @@ The following attributes are expressly forbidden:
### Additional Permitted Features
* `alignof`
([n2341](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf))
* `constexpr`
([n2235](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf))
([n3652](https://isocpp.org/files/papers/N3652.html))