Bug 1920717 - Add static checker for global variables with runtime initialisation r=glandium
This patch both: 1. Provides a static checker to detect global variables which may not be initialized at compile-time 2. Verify that variables flagged as MOZ_RUNINIT are indeed initialized at runtime 3. In case of variables whose initialisation status varies based on macro definition or template parameters, just flag them as MOZ_GLOBINIT. Differential Revision: https://phabricator.services.mozilla.com/D223342
This commit is contained in:
@@ -394,11 +394,14 @@ C/C++ practices
|
||||
- One-argument constructors, that are not copy or move constructors,
|
||||
should generally be marked explicit. Exceptions should be annotated
|
||||
with ``MOZ_IMPLICIT``.
|
||||
- Global variables with runtimle initialization should be avoided. Flagging
|
||||
- Global variables with runtime initialization should be avoided. Flagging
|
||||
them as ``constexpr`` or ``MOZ_CONSTINIT`` is a good way to make sure the
|
||||
initialization happens at compile-time. If runtime initialization cannot be
|
||||
avoided, use the attribute ``MOZ_RUNINIT`` to identify those and tell the
|
||||
linter to ignore that variable.
|
||||
linter to ignore that variable. If a variable is flagged as ``MOZ_RUNINIT``
|
||||
while the linter detects it could be ``MOZ_CONSTINIT``, you get an error. In
|
||||
case where the status of the global variable varies (e.g. depending on
|
||||
template parameter), just flag it ``MOZ_GLOBINIT``.
|
||||
- Use ``char32_t`` as the return type or argument type of a method that
|
||||
returns or takes as argument a single Unicode scalar value. (Don't
|
||||
use UTF-32 strings, though.)
|
||||
|
||||
Reference in New Issue
Block a user