[PATCH] D108370: [clang-tidy] Fix wrong FixIt about union in cppcoreguidelines-pro-type-member-init

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 2 14:38:45 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp:526
+  union {
+    int K;
+  };
----------------
Can you add a `CHECK-FIXES-NOT` that we're not adding the fix for this case?


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp:529
+  union {
+    int Z;
+    int Y;
----------------
Same here.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-member-init.cpp:534
+
+union U2 {
+  U2() {}
----------------
A related interesting test would be:
```
union U3 {
  U3() {}

  struct {
    int B;
  } b;
  int A;
};
```
I would expect `A` or `b` to need initialization for the union, and `B` to need initialization for the struct.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108370/new/

https://reviews.llvm.org/D108370



More information about the cfe-commits mailing list