================
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - google-cpp-init-class-members
+
+google-cpp-init-class-members
+=============================
+
+Checks that class members are initialized in constructors (implicitly or
+explicitly). Reports constructors or classes where class members are not
+initialized. The goal of this checker is to eliminate UUM (Use of
+Uninitialized Memory) bugs caused by uninitialized class members.
+
+This checker is different from ProTypeMemberInitCheck in that this checker
+attempts to eliminate UUMs as a bug class, at the expense of false
+positives.
----------------
adriannistor wrote:
# Examples
> Could you provide an example where ProTypeMemberInitCheck doesn't detect the
> problem, and this check does?
The 2 cases for which this PR is written (available in the unit tests) are not
found by `ProTypeMemberInitCheck`.
Specifically (I copy them from the unit test):
```
class PositiveDefaultedDefaultConstructor {
public:
PositiveDefaultedDefaultConstructor() = default;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor should initialize
these fields: X
private:
int X;
};
```
and
```
struct PositiveStruct {
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: these fields should be
initialized: X, Y
int X;
int Y;
};
```
Also a variation (again, copied them from the unit test)
```
class PositiveDefaultedConstructorObjectAndPrimitive {
public:
PositiveDefaultedConstructorObjectAndPrimitive() = default;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor should initialize
these fields: Y
Helper* GetHelper() { return &X; }
void SetY(bool enabled) { Y = enabled; }
bool IsY() { return Y; }
private:
Helper X;
bool Y;
};
# Regarding adding to the existing checker.
I fully discuss this in the [comment
below](https://github.com/llvm/llvm-project/pull/65189#issuecomment-1709185690).
Please take a look there for the full context. Thank you!
https://github.com/llvm/llvm-project/pull/65189
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits