================
@@ -154,6 +154,16 @@ class FindUsageOfThis : public
RecursiveASTVisitor<FindUsageOfThis> {
// 1) has builtin type (a 'const int' cannot be modified),
// 2) or it's a public member (the pointee of a public 'int * const' can
// can be modified by any user of the class).
+
+ // Union members are never safe for pointer/reference types
+ // (all union members share memory).
+ if (const auto *Field = dyn_cast<FieldDecl>(Member->getMemberDecl());
+ Field->getParent()->isUnion()) {
----------------
zwuis wrote:
If `getMemberDecl()` always returns `FieldDecl`, use `cast`. If not, we should
check if `Field` is null.
https://github.com/llvm/llvm-project/pull/174286
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits