summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RecordLayoutBuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* MS ABI: Implement #pragma vtordisp() and clang-cl /vdNReid Kleckner2014-02-121-0/+24
| | | | | | | | | | | | | | | | | These features are new in VS 2013 and are necessary in order to layout std::ostream correctly. Currently we have an ABI incompatibility when self-hosting with the 2013 stdlib in our convertible_fwd_ostream wrapper in gtest. This change adds another implicit attribute, MSVtorDispAttr, because implicit attributes are currently the best way to make sure the information stays on class templates through instantiation. Reviewers: majnemer Differential Revision: http://llvm-reviews.chandlerc.com/D2746 llvm-svn: 201274
* MS ABI: vptr injection should obey alignment requirementsDavid Majnemer2014-02-121-8/+20
| | | | | | | | | | | | | vptr injection must inject padding equivalent to the alignment of the most aligned non-virtual subobject, not the alignment of the enclosing record. To fascilitate this change, don't let record layout observe the alignment of the record until we've injected our vptrs. Also, do not allow the alignment of vbases to affect required alignment until just before we insert the vtordisp field. llvm-svn: 201199
* Extensively comment bitfield layout, rearrange someJohn McCall2014-01-291-81/+145
| | | | | | | | | code for legibility, and fix a bug with bitfields in packed ms_structs. rdar://15926990 llvm-svn: 200379
* [ms-abi] Small Change to pack+alignment interaction.Warren Hunt2014-01-141-4/+7
| | | | | | | | | This patch makes a small behavioral change to the interaction between pack and alignment. Specifically it makes __declspec(align()) on a field change that field's alignment without respect to pack but the alignment change to the record alignment as a whole still obeys pack. llvm-svn: 199172
* [ms-abi] Report VBPtrOffset correctlyWarren Hunt2014-01-141-6/+5
| | | | | | | | | | Although VBPtrs were being placed correctly by the ms-abi layout engine, their offsets were being improperly reported to the ASTRecordLayout builder due to a bug. This patch fixes that and fixes the test cases to use the correct values. y llvm-svn: 199168
* [ms-abi] Reordering __declspec(align) pragma pack handlingWarren Hunt2014-01-131-3/+3
| | | | | | | | This patch moves the check for pragma pack until after the application of __declspec align to before pragma pack. This causes observable changes in the use of tail padding for bases. A test case is included. llvm-svn: 199154
* [ms-abi] Leading VFPtrs don't suppress the leading zero sized flagWarren Hunt2014-01-131-1/+3
| | | | | | | | | | The MS-ABI tracks a bit that asserts that the first sub-object is zero sized. This bit is used to add padding between objects if there's the potential for zero sized objects to alias. The bit is still true even if the zero sized base is lead by a VFPtr. This patch makes clang mimic that behavior. llvm-svn: 199132
* [ms-abi] Quick fix layout of an array of recordsReid Kleckner2014-01-131-4/+2
| | | | | | | This fixes llvm::SmallVector, which fixes lots of TUs in the MS ABI self host. llvm-svn: 199129
* [ms-abi] Change the way alignment is trackedWarren Hunt2014-01-111-15/+8
| | | | | | | | | | | | This patch more cleanly seperates the concepts of Preferred Alignment and Required Alignment. Most notable that changes to Required Alignment do *not* impact preferred alignment until late in struct layout. This is observable when using pragma pack and non-virtual bases and the use of tail padding when laying them out. Test cases included. llvm-svn: 198988
* [ms-abi] Adjusting Rules for Padding Between BasesWarren Hunt2014-01-101-0/+6
| | | | | | | | | | | The presence of a VBPtr suppresses the presence of zero sized sub-objects in the non-virtual portion of the object in the context of determining if two base objects need alias-avoidance padding placed between them. Test cases included. llvm-svn: 198975
* [ms-abi] Handle __declspec(align) on bitfields "properly"Warren Hunt2014-01-101-25/+36
| | | | | | | | | | __declspec(align), when applied to bitfields affects their perferred alignment instead of their required alignment. We don't know why. Also, #pragma pack(n) turns packing *off* if n is greater than the pointer size. This is now observable because of the impact of declspec(align) on bitfields. llvm-svn: 198907
* [ms-abi] Fixing CGRecordLayoutBuilder w.r.t. MS NonVirutalBase LayoutWarren Hunt2014-01-091-6/+6
| | | | | | | | | | | | | | The MS abi lays out *all* non-virtual bases with leading vfptrs before laying out non-virutal bases without vfptrs. This guarantees that the primary base is laid out first. r198818 fixed RecordLayoutBuilder to produce compatiable layouts. This patch fixes CGRecordLayoutBuilder to be able to consume those layouts and produce meaningful output without tripping any asserts about assumed incoming layout. A test case is included that shows CGRecordLayoutBuilder in fact produces output in the compatiable order. llvm-svn: 198900
* Fix the clang -Werror build after r198818David Blaikie2014-01-091-1/+1
| | | | llvm-svn: 198837
* [ms-abi] Refactor Microsoft Record LayoutWarren Hunt2014-01-091-338/+377
| | | | | | | | | This patch refactors microsoft record layout to be more "natural". The most dominant change is that vbptrs and vfptrs are injected after the fact. This simplifies the implementation and the math for the offest for the first base/field after the vbptr. llvm-svn: 198818
* [ms-abi] Fixes improperly sized vfptrs with pragma packWarren Hunt2013-12-261-5/+4
| | | | | | | | With pragma pack, the layout engine would produce vfptrs that were packed width rather than pointer width. This patch addresses the issue and adds a test case. llvm-svn: 198059
* [ms-abi] Update Alignment for VtorDispsWarren Hunt2013-12-191-8/+2
| | | | | | | | The alignment impact of the virtual bases apperas to be applied in order, rather than up front. This patch adds the new behavior and provides a test case. llvm-svn: 197639
* Use getAsCXXRecordDecl to shorten some gets and castsReid Kleckner2013-12-181-10/+5
| | | | llvm-svn: 197626
* Fix indentation from r197490 plus some typosAlp Toker2013-12-171-1/+1
| | | | llvm-svn: 197507
* [ms-abi] Refactoring Non-virtual base layout in record layoutWarren Hunt2013-12-121-69/+39
| | | | | | | | | This refactor addresses bugzilla bug 18167 and simplifies the code at the same time. Also I add a test case for the bug. Also I make a non-functional change to the basic layout lit tests to make them more reliable (using CHECK-NEXT instead of CHECK). llvm-svn: 197183
* [ms-abi][cleanup] Removing FinalizeCXXLayout : no functional changeWarren Hunt2013-12-111-10/+1
| | | | | | | After r196549 there is no need to separate FinalizeCXXLayout and FinalizeLayout so they were merged and FinalizeCXXLayout was eliminated. llvm-svn: 197083
* [ms-abi] Makes Virtual Base Alignment Look at All Virtual BasesWarren Hunt2013-12-111-5/+8
| | | | | | | | Prior to this patch, the alignment imposed by virtual bases only included direct virtual bases. This patch fixes it to look at all virtual bases. llvm-svn: 196997
* [ms-abi] 64-bit fixes for r196549Warren Hunt2013-12-101-10/+17
| | | | | | | | In order to address latent bugs that were easier to expose in 64-bit mode, we move the application of __declspec(align) to before the layout of vbases rather than after. llvm-svn: 196861
* Fixing assertion failure introduced in 196602.Warren Hunt2013-12-071-6/+4
| | | | | | Also includes a minor refactor with no functional change. llvm-svn: 196627
* [MS-ABI] adds padding before all vbases after a bitfieldWarren Hunt2013-12-061-8/+7
| | | | | | | | | | MS-ABI adds padding before *every* vbase if the last field in a record is a bit-field. This changes clangs behavior to match. I also fix some windows-style line endings in the test file. Differential Revision: http://llvm-reviews.chandlerc.com/D2277 llvm-svn: 196605
* [MS-ABI] Fix alias-avoidance padding between basesWarren Hunt2013-12-061-63/+70
| | | | | | | | | | | Adds padding between bases or virtual bases in an attempt to avoid aliasing of zero-sized sub-objects. The approach used by the ABI adds two more bits of state. Detailed comments are in the code. Test cases included. Differential Revision: http://llvm-reviews.chandlerc.com/D2258 llvm-svn: 196602
* Support MS-ABI's concept of "Required Alignment" imposed by Warren Hunt2013-12-061-24/+53
| | | | | | | | | | | | | | | | | | __declspec(align()) This patch implements required alignment in a way that makes __declspec(align()) and #pragma pack play correctly together. In the MS-ABI, __declspec(align()) is a hard rule and cannot be overridden by #pragma pack. This cases each record to have two interesting alignments "preferred alignment" (which matches Itanium's concept of alignment) and "required alignment" which is an alignment that must never be violated, even in the case of #pragma pack. This patch introduces the concept of Required Alignment to the record builder and tracks/uses it appropriately. Test cases are included. Differential Revision: http://llvm-reviews.chandlerc.com/D2283 llvm-svn: 196549
* Fix a tranche of comment, test and doc typosAlp Toker2013-12-051-3/+3
| | | | llvm-svn: 196510
* Correct hyphenations in comments and assert messagesAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
* Microsoft Record Layout: zero sized base after base with vbtbl fixWarren Hunt2013-11-191-0/+11
| | | | | | | | | | Microsoft adds an extra byte of padding before laying out zero sized non-virtual bases if the non-virtual base before it contains a vbptr. This patch adds the same behavior to clang. Differential Revision: http://llvm-reviews.chandlerc.com/D2106 llvm-svn: 195158
* No functional change. Renaming a variable in RecordLayoutBuilder and Warren Hunt2013-11-131-10/+13
| | | | | | | | improving comments to make documentation more accurate. Differential Revision:http://llvm-reviews.chandlerc.com/D2172 llvm-svn: 194609
* Thread the info about vbptr sharing through ASTRecordLayoutTimur Iskhodzhanov2013-11-081-5/+4
| | | | | | Reviewed at http://llvm-reviews.chandlerc.com/D2120 llvm-svn: 194256
* Microsoft adds weird padding before virtual bases if the last field was a ↵Warren Hunt2013-11-061-0/+9
| | | | | | | | | | bitfield This patch adds the same behavior to clang. Differential Revision: http://llvm-reviews.chandlerc.com/D2103 llvm-svn: 194115
* Improves compatibility with cl.exe when laying out array fieldsWarren Hunt2013-11-011-19/+3
| | | | | | | | | | | | | Differential Revision: http://llvm-reviews.chandlerc.com/D2090 Clang was "improperly" over-aligning arrays with sizes are not a multiple of their alignment. This behavior was removed in microsoft 32 bit mode. In addition, after examination of ASTContext::getTypeInfoImpl, a redundant code block in MicrosoftRecordLayoutBuilder::getAdjustedFieldInfo was deleted. llvm-svn: 193898
* Remove dead variables.Benjamin Kramer2013-10-251-11/+2
| | | | llvm-svn: 193395
* Remove dead recursive function.Benjamin Kramer2013-10-241-22/+0
| | | | llvm-svn: 193313
* Implements 64 bit microsoft record layout and adds lit tests to cover Warren Hunt2013-10-231-388/+70
| | | | | | | | | it. Also removes all of the microsoft C++ ABI related code from the itanium layout builder. Differential Revision: http://llvm-reviews.chandlerc.com/D2003 llvm-svn: 193290
* Rename some functions for consistency.Rafael Espindola2013-10-171-1/+1
| | | | | | Every other function in Redeclarable.h was using Decl instead of Declaration. llvm-svn: 192900
* PR17576: Fix assertion on polymorphic classes with small alignmentReid Kleckner2013-10-141-1/+1
| | | | | | | | We have to reserve at least the width of a pointer for the vfptr. For classes with small alignment, we weren't reserving enough space, and were overlapping the first field with the vfptr. llvm-svn: 192626
* Correctly check for distructors when realizing vtordispsWarren Hunt2013-10-141-1/+1
| | | | | | | | | | This patch fixes the distructor test when checking for vtordisp requirements in microsoft record layout. A test case is also included. Addresses: http://llvm.org/bugs/show_bug.cgi?id=16406#c7 llvm-svn: 192616
* Only use the MS record layout when using the MS C++ ABIReid Kleckner2013-10-111-5/+5
| | | | | | We're not ready to use it everywhere we use a win32 triple yet. llvm-svn: 192502
* Fix unused variable warning in MS record layout.Reid Kleckner2013-10-111-3/+1
| | | | llvm-svn: 192495
* Adds Microsoft compatiable C++ record layout code to clang.Warren Hunt2013-10-111-31/+728
| | | | llvm-svn: 192494
* Be lazier when loading KeyFunctions from PCH/modules. We don't need to loadRichard Smith2013-08-291-12/+11
| | | | | | | | | | | | | | these in eagerly if we're not actually processing a translation unit. The added laziness here also avoids us loading in parts of a CXXRecordDecl earlier than an upcoming class template specialization merging patch would like. Ideally, we should mark the vtable as used when we see a definition for the key function, rather than having a separate pass over dynamic classes at the end of the TU. The existing approach is pretty bad for PCH/modules, since it forcibly loads the declarations of all key functions in all imported modules, whether or not those key functions are defined. llvm-svn: 189627
* Fix alignment of class derived from empty class.Eli Friedman2013-07-161-3/+4
| | | | | | | | | The record layout code didn't properly take into account that an empty class at offset 0 can have an alignment greater than 1. Patch by Andrea Di Biagio. llvm-svn: 186370
* Changes so that a few tests do not fail when running under guarded malloc.Argyrios Kyrtzidis2013-07-121-2/+2
| | | | | | | Guarded malloc emits some messages at the beginning in stderr when enabled. These messages caused a few tests to fail. llvm-svn: 186219
* Simplify code.Eli Friedman2013-06-261-39/+7
| | | | llvm-svn: 185042
* Rewrite record layout for ms_struct structs.Eli Friedman2013-06-261-162/+78
| | | | | | | | | | | | | | The old implementation of ms_struct in RecordLayoutBuilder was a complete mess: it depended on complicated conditionals which didn't really reflect the underlying logic, and placed a burden on users of the resulting RecordLayout. This commit rips out almost all of the old code, and replaces it with simple checks in RecordLayoutBuilder::LayoutBitField. This commit also fixes <rdar://problem/14252115>, a bug where class inheritance would cause us to lay out bitfields incorrectly. llvm-svn: 185018
* Don't try to get the layout of an invalid decl in getDeclAlign.Matt Beaumont-Gay2013-06-251-0/+1
| | | | | | | | | | | When the decl that we're getting alignment for is a FieldDecl, and the field's parent record is invalid, skip the actual field alignment calculation (and return 1-byte alignment in the general case). Also, assert in in getASTRecordLayout that the decl is valid. This was inspired by PR16292; see also r184581 and r184751. llvm-svn: 184883
* [ms-cxxabi] There are no key functions in the Microsoft C++ ABIReid Kleckner2013-05-291-0/+3
| | | | | | | | | | | MSVC's class data is always comdat, so clang's should always be linkonce_odr in LLVM IR. Reviewers: pcc Differential Revision: http://llvm-reviews.chandlerc.com/D838 llvm-svn: 182865
* [ms-cxxabi] Mangle in an implicit 'E' for certain types on win64Reid Kleckner2013-05-141-1/+1
| | | | | | | | | | | | Most of the complexity of this patch is figuring out which types get the qualifier and which don't. If we implement __ptr32/64, then we should check the qualifier instead of assuming all pointers are 64-bit. This fixes PR13792. Patch by Warren Hunt! llvm-svn: 181825
OpenPOWER on IntegriCloud