[PATCH] D63753: [Sema] Instead of rejecting C unions with non-trivial fields, detect attempts to destruct/initialize/copy them.
John McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 3 18:02:55 PDT 2019
rjmccall added inline comments.
================
Comment at: include/clang/AST/Type.h:1133
+ /// Check if this is or contains a non-trivial C struct/union type.
+ bool hasNonTrivialPrimitiveCStruct() const;
----------------
ahatanak wrote:
> rjmccall wrote:
> > You only want these checks to trigger on unions with non-trivial members (or structs containing them), right? How about something like `hasNonTrivialPrimitiveCUnionMember()`? Or maybe make it more descriptive for the use sites, like `isPrimitiveCRestrictedType()`?
> >
> > Also, it would be nice if the fast path of this could be inlined so that clients usually didn't had to make a call at all. You can write the `getBaseElementTypeUnsafe()->getAs<RecordType>()` part in an `inline` implementation at the bottom this file.
> Since we don't keep track of whether a struct or union is or contains unions with non-trivial members, we'll have to use the visitors to detect such structs or unions or, to do it faster, add a bit to `RecordDeclBits` that indicates the presence of non-trivial unions. I guess it's okay to add another bit to `RecordDeclBits`?
It looks like there's plenty of space in `RecordDeclBits`, yeah.
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63753/new/
https://reviews.llvm.org/D63753
More information about the cfe-commits
mailing list