[clang-tools-extra] [clang-tidy]Fix PreferMemberInitializer false positive for reassignment (PR #70316)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 26 05:54:51 PDT 2023


================
@@ -570,3 +570,19 @@ struct PR52818  {
 
     int bar;
 };
+
+struct RefReassignment {
+  RefReassignment(int &i) : m_i{i} {
+    m_i = 1;
+  }
+  int & m_i;
+};
+
+struct ReassignmentAfterUnsafetyAssignment {
+  ReassignmentAfterUnsafetyAssignment() {
+    int a = 10;
+    m_i = a;
+    m_i = 1;
+  }
+  int m_i;
+};
----------------
PiotrZSL wrote:

Check if there are positive tests.

https://github.com/llvm/llvm-project/pull/70316


More information about the cfe-commits mailing list