Debian Codegraph @

llvm-project/clang-tools-extra/docs/clang-tidy/checks/fuchsia/statically-constructed-objects.rst

raw
1 .. title:: clang-tidy - fuchsia-statically-constructed-objects
2
3 fuchsia-statically-constructed-objects
4 ======================================
5
6 Warns if global, non-trivial objects with static storage are constructed, unless
7 the object is statically initialized with a ``constexpr`` constructor or has no
8 explicit constructor.
9
10 For example:
11
12 .. code-block:: c++
13
14 class A {};
15
16 class B {
17 public:
18 B(int Val) : Val(Val) {}
19 private:
20 int Val;
21 };
22
23 class C {
24 public:
25 C(int Val) : Val(Val) {}
26 constexpr C() : Val(0) {}
27
28 private:
29 int Val;
30 };
31
32 static A a; // No warning, as there is no explicit constructor
33 static C c(0); // No warning, as constructor is constexpr
34
35 static B b(0); // Warning, as constructor is not constexpr
36 static C c2(0, 1); // Warning, as constructor is not constexpr
37
38 static int i; // No warning, as it is trivial
39
40 extern int get_i();
41 static C(get_i()) // Warning, as the constructor is dynamically initialized
42
43 See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md