[clang-tools-extra] [clang-tidy] Add new check 'misc-static-initialization-cycle' (PR #175342)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 12 01:14:40 PST 2026
balazske wrote:
> We have the `cppcoreguidelines-interfaces-global-init` check, which seems to be broadly similar to this one. Can you compare and contrast the two?
`cppcoreguidelines-interfaces-global-init` finds global variables that are initialized with another global variable that has no definition in the current TU. The new `misc-static-initialization-cycle` can find 2 or more global variables where all have initialization in the current TU and depend on each other. The `cppcoreguidelines-interfaces-global-init` is somewhat like an extension of the `misc-static-initialization-cycle` for the case when more TUs are involved. (Not exactly but to some extent.) Both checks can be related to CERT rule [DCL56-CPP. Avoid cycles during initialization of static objects](https://wiki.sei.cmu.edu/confluence/display/cplusplus/DCL56-CPP.+Avoid+cycles+during+initialization+of+static+objects). I actually planned to add later an option to the new check that would detect uninitialized global variables too, this is probably not needed (`cppcoreguidelines-interfaces-global-init` can be used instead).
https://github.com/llvm/llvm-project/pull/175342
More information about the cfe-commits
mailing list