summaryrefslogtreecommitdiffstats
path: root/clang/test/Layout/ms-x86-pack-and-align.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Non-zero-length bit-fields make a class non-empty.Richard Smith2018-05-071-12/+12
| | | | | | | | | | | | | | | | | | | | This implements the rule intended by the standard (see LWG 2358) and the rule intended by the Itanium C++ ABI (see https://github.com/itanium-cxx-abi/cxx-abi/pull/51), and makes Clang match the behavior of GCC, ICC, and MSVC. A pedantic reading of both the standard and the ABI indicate that Clang is currently technically correct, but that's not worth much when it's clear that the wording is wrong in both those places. This is an ABI break for classes that derive from a class that is empty other than one or more unnamed non-zero-length bit-fields. Such cases are expected to be rare, but -fclang-abi-compat=6 restores the old behavior just in case. Differential Revision: https://reviews.llvm.org/D45174 llvm-svn: 331620
* Fix the layout of bitfields in ms_struct unions: theirJohn McCall2015-08-191-54/+26
| | | | | | | | | | | | | | | alignment is ignored, and they always allocate a complete storage unit. Also, change the dumping of AST record layouts: use the more readable C++-style dumping even in C, include bitfield offset information in the dump, and don't print sizeof/alignof information for fields of record type, since we don't do so for bases or other kinds of field. rdar://22275433 llvm-svn: 245514
* __declspec is not a core Clang language extension. Instead, require ↵Aaron Ballman2015-05-261-2/+2
| | | | | | | -fms-extensions or -fborland to enable the language extension. Note: __declspec is also temporarily enabled when compiling for a CUDA target because there are implementation details relying on __declspec(property) support currently. When those details change, __declspec should be disabled for CUDA targets. llvm-svn: 238238
* PR6037Nathan Sidwell2015-01-191-2/+2
| | | | | | Warn on inaccessible direct base llvm-svn: 226423
* MS ABI: Correct layout for empty recordsDavid Majnemer2014-09-301-0/+34
| | | | | | | | Empty records do not always have size equivalent to their alignment. They only do so when their alignment is at least as large as the minimum empty struct size: 1 byte in C++ and 4 bytes in C. llvm-svn: 218661
* AST: Propagate 'AlignIsRequired' though many levels of typedefsDavid Majnemer2014-08-041-0/+29
| | | | | | | A typedef of a typedef should have AlignIsRequired if *either* typedef has an AlignAttr attached to it. llvm-svn: 214698
* MS ABI: Consider alignment attributes on typedefs for layoutDavid Majnemer2014-07-301-0/+91
| | | | | | | | | | | | | | | | | | | The MS ABI has a notion of 'required alignment' for fields; this alignment supercedes pragma pack directives. MSVC takes into account alignment attributes on typedefs when determining whether or not a field has a certain required alignment. Do the same in clang by tracking whether or not we saw such an attribute when calculating the type's bitwidth and alignment. This fixes PR20418. Reviewers: rnk Differential Revision: http://reviews.llvm.org/D4714 llvm-svn: 214274
* MS ABI: Padding injected between empty vbases doesn't up required alignDavid Majnemer2014-07-171-0/+57
| | | | | | Only alignment is changed, not required alignment. llvm-svn: 213217
* MS ABI: Up the required alignment after inserting padding between vbasesDavid Majnemer2014-07-161-0/+55
| | | | | | | | | | We would correctly insert sufficiently aligned padding between vbases when our leading base was empty, however we would neglect to increase the required alignment of the most derived class. This fixes PR20315. llvm-svn: 213123
* [MS-ABI] Update virtual base padding rules to match MSVC 10+Warren Hunt2014-04-111-4/+4
| | | | | | | | | | In version 9 (VS2010) (and prior)? versions of msvc, if the last field in a record was a bitfield padding equal to the size of the storage class of that bitfield was added before each vbase and vtordisp. This patch removes that feature from clang and updates the lit tests to reflect it. llvm-svn: 206004
* [MS-ABI] Fixed __declspec(align()) on bitfields under #pragma pack.Warren Hunt2014-04-101-14/+153
| | | | | | | | | | | | | | | When __declspec(align()) is applied to a bitfield it affects the alignment rather than the required alignment of the struct. The major feature that this patch adds is that the alignment of the structure obeys the alignment of __declspec(align()) from the bitfield over the value specified in pragma pack. Test cases are included. The patch also includes some small cleanups in recordlayoutbuilder and some cleanups to some lit tests, including line endings (but no functionality change to lit tests) llvm-svn: 205994
* MS ABI: Fix some layout testsDavid Majnemer2014-02-151-14/+11
| | | | | | | | Some lines intended to be used for testing x86_64 ABI compatibility were not firing because lines were annotated with the wrong FileCheck prefix: X64 vs C64 llvm-svn: 201453
* MS ABI: vptr injection should obey alignment requirementsDavid Majnemer2014-02-121-0/+45
| | | | | | | | | | | | | 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
* MS ABI: Fix some layout testsDavid Majnemer2014-02-031-8/+8
| | | | | | | | | | | | Some lines intended to be used for testing x86_64 ABI compatibility were not firing because lines were annotated with the wrong FileCheck prefix: X64 vs x64 N.B. Changes beyond just changing x64 to X64 were made, presumably because other parts of the layout engine have changed. I've verified the changes to make sure that MSVC creates a compatible layout. llvm-svn: 200670
* Remove the -cxx-abi command-line flag.Hans Wennborg2014-01-141-2/+2
| | | | | | | | | | | | | | | This makes the C++ ABI depend entirely on the target: MS ABI for -win32 triples, Itanium otherwise. It's no longer possible to do weird combinations. To be able to run a test with a specific ABI without constraining it to a specific triple, new substitutions are added to lit: %itanium_abi_triple and %ms_abi_triple can be used to get the current target triple adjusted to the desired ABI. For example, if the test suite is running with the i686-pc-win32 target, %itanium_abi_triple will expand to i686-pc-mingw32. Differential Revision: http://llvm-reviews.chandlerc.com/D2545 llvm-svn: 199250
* [ms-abi] Small Change to pack+alignment interaction.Warren Hunt2014-01-141-0/+23
| | | | | | | | | 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] Reordering __declspec(align) pragma pack handlingWarren Hunt2014-01-131-2/+31
| | | | | | | | 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] Change the way alignment is trackedWarren Hunt2014-01-111-2/+34
| | | | | | | | | | | | 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] Handle __declspec(align) on bitfields "properly"Warren Hunt2014-01-101-1/+116
| | | | | | | | | | __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] Refactor Microsoft Record LayoutWarren Hunt2014-01-091-80/+92
| | | | | | | | | 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-1/+35
| | | | | | | | 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] Makes Virtual Base Alignment Look at All Virtual BasesWarren Hunt2013-12-111-1/+26
| | | | | | | | 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
* Support MS-ABI's concept of "Required Alignment" imposed by Warren Hunt2013-12-061-0/+120
__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
OpenPOWER on IntegriCloud