This is an archive of the discontinued LLVM Phabricator instance.

implement recent "standard-layout" changes
ClosedPublic

Authored by rsmith on Apr 2 2018, 12:12 PM.

Details

Summary

DR1672, DR1813, DR1881, DR2120: Implement recent fixes to "standard layout" rules.

The new rules say that a standard-layout struct has its first non-static data member and all base classes at offset 0, and consider a class to not be standard-layout if that would result in multiple subobjects of a single type having the same address.

We separately track the results that the "standard-layout" computation would have produced strictly following the C++11 rules, because that is part of the ABI tail-padding-reuse decision for some targets.

Diff Detail

Repository
rC Clang

Event Timeline

rsmith created this revision.Apr 2 2018, 12:12 PM
rsmith updated this revision to Diff 140715.Apr 2 2018, 5:41 PM
rsmith edited the summary of this revision. (Show Details)

Patch updated to track "is C++11 standard-layout class" separately from "is standard-layout class" so that we can use the former for record layout in the targets that need it. This turned out to be less ugly than I'd feared.

rjmccall added inline comments.Apr 3 2018, 2:43 PM
AST/DeclCXX.cpp
1130 ↗(On Diff #140715)

IsCXX11StandardLayout should be based on FieldRec->isCXX11StandardLayout(), I assume.

rsmith updated this revision to Diff 140896.Apr 3 2018, 7:46 PM
rsmith marked an inline comment as done.
rsmith added inline comments.
AST/DeclCXX.cpp
1130 ↗(On Diff #140715)

Oops. Yes.

rsmith updated this revision to Diff 140897.Apr 3 2018, 7:48 PM
rsmith marked an inline comment as done.
rjmccall accepted this revision.Apr 3 2018, 9:22 PM

Okay. LGTM. Thank you for putting the effort into maintaining both rules simultaneously.

This revision is now accepted and ready to land.Apr 3 2018, 9:22 PM
This revision was automatically updated to reflect the committed changes.