Qt-NonPodGlobalStatic¶
Global statics shall be trivially default constructible and trivially destructible
Required inputs: IR
Constructors of globals are run before main, on library load, slowing down startup. This is more a problem for libraries, since usually the app won't use every feature the library provides, so it's a waste of resources to call constructors from unused features.
It is tolerated to have global statics in executables, so it is the user's job to run this rule only on libraries. It doesn't harm, though, to also remove global statics from executables, because they're usually evil.
The same goes for destructors at library unload time. A good way to fix them is by using Q_GLOBAL_STATIC.
[1] The term 'POD' is too strict. The correct term is 'types with a trivial dtor and trivial ctor', and that's how this check is implemented.
This rule is based on clazy rule non-pod-global-static
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
non_pod_global_static |
Non-POD global static variable. |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
level¶
level : int = 1
macro_name_whitelist¶
macro_name_whitelist : list[str] = ['Q_COREAPP_STARTUP_FUNCTION']