This is an archive of the discontinued LLVM Phabricator instance.

Make `__is_base_of` more friendly with unions
ClosedPublic

Authored by mclow.lists on May 13 2019, 9:14 AM.

Details

Summary

Unions are never base classes, and never have base classes.
It doesn't matter if they are complete or not. See http://llvm.org/PR41843

Diff Detail

Event Timeline

mclow.lists created this revision.May 13 2019, 9:14 AM

Note: There are tabs in clang/test/SemaCXX/type-traits.cpp that I didn't remove because it would have cluttered up the diff.
I can de-tabify the file when it is committed if people want.

Shouldn't we also add unit tests for PR41843 in libc++?

Shouldn't we also add unit tests for PR41843 in libc++?

Yes. But I want to do that later.
After this has landed (and probably wait a week for all the bots that are running trunk to update).

ldionne accepted this revision.May 13 2019, 12:11 PM

I'm not a frontend expert, but this looks reasonable to me.

This revision is now accepted and ready to land.May 13 2019, 12:11 PM
rsmith accepted this revision.May 13 2019, 12:15 PM

Yeah, this seems to match the library wording. (I think it's short-sighted and over-fitting -- this is baking into the library specification that the language happens to not allow unions to have base classes today -- but this isn't the venue for that discussion.)

mclow.lists closed this revision.May 13 2019, 12:27 PM

Committed as revision 360614