================
@@ -154,6 +154,17 @@ 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())) {
+ if (Field->getParent()->isUnion()) {
+ const QualType MemberType = Field->getType();
+ if (MemberType->isPointerType() || MemberType->isReferenceType())
----------------
zeyi2 wrote:
Nit: `if (MemberType.isPointerType() || MemberType.isReferenceType())`
https://github.com/llvm/llvm-project/pull/174286
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits