summaryrefslogtreecommitdiffstats
path: root/clang/test/Layout
Commit message (Collapse)AuthorAgeFilesLines
* P0840R2: support for [[no_unique_address]] attributeRichard Smith2019-06-201-0/+265
| | | | | | | | | | | | | | | | | Summary: Add support for the C++2a [[no_unique_address]] attribute for targets using the Itanium C++ ABI. This depends on D63371. Reviewers: rjmccall, aaron.ballman Subscribers: dschuff, aheejin, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63451 llvm-svn: 363976
* NFC - Fix typo in test/Layout/itanium-pack-and-align.cppGabor Buella2018-07-041-1/+1
| | | | llvm-svn: 336262
* [Sema] Fix incorrect packed aligned structure layoutMomchil Velikov2018-05-211-0/+26
| | | | | | | | | | Handle attributes before checking the record layout (e.g. underalignment check during `alignas` processing), as layout may be cached without taking into account attributes that may affect it. Differential Revision: https://reviews.llvm.org/D46439 llvm-svn: 332843
* Non-zero-length bit-fields make a class non-empty.Richard Smith2018-05-072-12/+32
| | | | | | | | | | | | | | | | | | | | 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
* DR1672, DR1813, DR1881, DR2120: Implement recent fixes to "standardRichard Smith2018-04-051-0/+47
| | | | | | | | | | | | | | | | | 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 track "is C++11 standard-layout class" separately from "is standard-layout class" so that the ABIs that need this information can still use it. Differential Revision: https://reviews.llvm.org/D45176 llvm-svn: 329332
* Print nested name specifiers for typedefs and type aliasesAlex Lorenz2017-03-101-2/+2
| | | | | | | | | | | | Printing typedefs or type aliases using clang_getTypeSpelling() is missing the namespace they are defined in. This is in contrast to other types that always yield the full typename including namespaces. Patch by Michael Reiher! Differential Revision: https://reviews.llvm.org/D29944 llvm-svn: 297465
* [MS ABI] Implement __declspec(empty_bases) and __declspec(layout_version)David Majnemer2016-05-231-0/+266
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The layout_version attribute is pretty straightforward: use the layout rules from version XYZ of MSVC when used like struct __declspec(layout_version(XYZ)) S {}; The empty_bases attribute is more interesting. It tries to get the C++ empty base optimization to fire more often by tweaking the MSVC ABI rules in subtle ways: 1. Disable the leading and trailing zero-sized object flags if a class is marked __declspec(empty_bases) and is empty. This means that given: struct __declspec(empty_bases) A {}; struct __declspec(empty_bases) B {}; struct C : A, B {}; 'C' will have size 1 and nvsize 0 despite not being annotated __declspec(empty_bases). 2. When laying out virtual or non-virtual bases, disable the injection of padding between classes if the most derived class is marked __declspec(empty_bases). This means that given: struct A {}; struct B {}; struct __declspec(empty_bases) C : A, B {}; 'C' will have size 1 and nvsize 0. 3. When calculating the offset of a non-virtual base, choose offset zero if the most derived class is marked __declspec(empty_bases) and the base is empty _and_ has an nvsize of 0. Because of the ABI rules, this does not mean that empty bases reliably get placed at offset 0! For example: struct A {}; struct B {}; struct __declspec(empty_bases) C : A, B { virtual ~C(); }; 'C' will be pointer sized to account for the vfptr at offset 0. 'A' and 'B' will _not_ be at offset 0 despite being empty! Instead, they will be located right after the vfptr. This occurs due to the interaction betweeen non-virtual base layout and virtual function pointer injection: injection occurs after the nv-bases and shifts them down by the size of a pointer. llvm-svn: 270457
* [MS] Fix for bug 25013 - #pragma vtordisp is unknown inside functions, by ↵Alexey Bataev2015-11-201-0/+217
| | | | | | | | | Denis Zobnin. This patch adds support of #pragma vtordisp inside functions in attempt to improve compatibility. Microsoft compiler appears to save the stack of vtordisp modes on entry of struct methods' bodies and restore it on exit (method-local vtordisp). Differential Revision: http://reviews.llvm.org/D14467 llvm-svn: 253650
* [MS ABI] Don't crash when inheriting from base with trailing empty array memberDavid Majnemer2015-10-221-1/+25
| | | | | | | | | | We got this right for Itanium but not MSVC because CGRecordLayoutBuilder was checking if the base's size was zero when it should have been checking the non-virtual size. This fixes PR21040. llvm-svn: 251036
* Fix the layout of bitfields in ms_struct unions: theirJohn McCall2015-08-198-151/+113
| | | | | | | | | | | | | | | 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-2611-22/+22
| | | | | | | -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
* Test case B: fixed check ruleEvgeny Astigeevich2014-10-211-1/+1
| | | | llvm-svn: 220272
* Test case B is updated to work for 32-bit and 64-bit platformsEvgeny Astigeevich2014-10-211-3/+3
| | | | llvm-svn: 220271
* Commit to test commit accessEvgeny Astigeevich2014-10-201-0/+1
| | | | llvm-svn: 220189
* clang/test/Layout/itanium-union-bitfield.cpp: Appease i686.NAKAMURA Takumi2014-10-191-3/+2
| | | | llvm-svn: 220166
* D5775: The new test case was missing from the preceding commit.Artyom Skrobov2014-10-171-0/+29
| | | | llvm-svn: 220032
* MS ABI: Add an additional test for empty structs in CDavid Majnemer2014-10-031-0/+88
| | | | | | | | | | | | Empty structs in C differ from those in C++. - C++ requires that empty types have size 1; alignment requirements may increase the size of the struct. - The C implementation doesn't let empty structs have a size under 4 bytes. Again, alignment requirements may increase the struct's size. Add a test to stress these differences. llvm-svn: 218963
* MS ABI: Correct layout for empty recordsDavid Majnemer2014-09-302-0/+66
| | | | | | | | 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
* MS ABI: Pure virtual functions don't contribute to vtordispsDavid Majnemer2014-09-231-0/+26
| | | | | | | | | | | Usually, overriding a virtual function defined in a virtual base required emission of a vtordisp slot in the record. However no vtordisp is needed if the overriding function is pure; it should be impossible to observe the pure virtual method. This fixes PR21046. llvm-svn: 218340
* 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
* Fix warning in ms-x86-vtordisp test caseReid Kleckner2014-04-141-2/+2
| | | | llvm-svn: 206224
* MS ABI: #pragma vtordisp(0) only disables new vtordispsDavid Majnemer2014-04-131-0/+36
| | | | | | | | | | | Previously, it was believed that #pragma vtordisp(0) would prohibit the generation of any and all vtordisps. In actuality, it only disables the generation of additional vtordisps. This fixes PR19413. llvm-svn: 206124
* [MS-ABI] Fixed alias-avoidance padding in the presence of vtordispsWarren Hunt2014-04-111-0/+31
| | | | | | | If a vtordisp exists between two bases, then there is no need for additional alias avoidance padding. Test case included. llvm-svn: 206087
* [MS-ABI] Update to vtordisp computationWarren Hunt2014-04-111-1/+58
| | | | | | | | | | A portion of the vtordisp computation that was previously unguarded by a test for the declaration of user defined constructors/destructors was erroniously adding vtordisps to things that shouldn't have them. This patch correctly guards that codepath. In addition, it updates the comments to make them more clear. Test case is included. llvm-svn: 206077
* [MS-ABI] Update virtual base padding rules to match MSVC 10+Warren Hunt2014-04-112-24/+24
| | | | | | | | | | 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] Fix to vbptr injection site calculation.Warren Hunt2014-04-102-109/+150
| | | | | | | | The vbptr is injected after the last non-virtual base lexographically rather than the last non-virtual base in layout order. Test case included. Also, some line ending fixes. llvm-svn: 206000
* [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] Update to alias-avoidance paddingWarren Hunt2014-04-091-0/+260
| | | | | | | | | | This patch changes how we determine if padding is needed between two bases in msvc compatibility mode. Test cases included. In addition, a very minor change to the printing of structures to ease lit testing. llvm-svn: 205933
* Render anonymous entities as '(anonymous <thing>)' (and lambdas as '(lambda ↵David Blaikie2014-04-021-4/+4
| | | | | | | | | | | | at ... )') For namespaces, this is consistent with mangling and GCC's debug info behavior. For structs, GCC uses <anonymous struct> but we prefer consistency between all anonymous entities but don't want to confuse them with template arguments, etc, so we'll just go with parens in all cases. llvm-svn: 205398
* [MS-ABI] Drop Special Layout in 64-bit mode.Warren Hunt2014-03-246-144/+144
| | | | | | | | | As of cl.exe version 18, the special layout rules for structs with alignment 16 or greater has been dropped. This patch drops the behavior from clang. This patch also updates the lit tests to reflect the change. llvm-svn: 204674
* -fdump-record-layouts: Sort nvbases by offset before printing themReid Kleckner2014-02-282-14/+14
| | | | | | It makes our -fdump-record-layouts a little more sane. llvm-svn: 202457
* MS ABI: Just use getTypeInfoInChars to get the field sizeReid Kleckner2014-02-251-0/+17
| | | | | | | | | | | | This was changed to use manual desugaring and multiplication in r201832 and fixed for multi-dimensional arrays in r201917. However, it breaks down in the presence of typedefs. Rather than attempting to handle all the desugaring, just go back to calling the generic type info code. This was discovered while compiling SIInstrWaits.cpp in the R600 backend. llvm-svn: 202175
* [MS-ABI] Fix MSRecordLayout to handel MultiDimensionalArraysWarren Hunt2014-02-221-1/+18
| | | | | | | | A recent change caused multi-dimensional arrays not to be handled correctly, this patch fixes that. Also, it adds a lit test for multi-dimensional arrays. llvm-svn: 201917
* [MS-ABI] Update to zero-sized padding algorithmWarren Hunt2014-02-211-1/+36
| | | | | | | | | | Slight change to the way zero-sized sub-objects are tracked in the presence of virtual bases. In addition we correctly distinguish between dsize and nvsize. addresses http://llvm.org/bugs/show_bug.cgi?id=18826 Unit tests are included. llvm-svn: 201832
* MS ABI: Fix some layout testsDavid Majnemer2014-02-151-20/+16
| | | | | | | | 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 64 llvm-svn: 201454
* 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
* Fix some -Wdocumentation warnings in Sema.h and try to fix test for win64Reid Kleckner2014-02-131-1/+1
| | | | llvm-svn: 201278
* MS ABI: Implement #pragma vtordisp() and clang-cl /vdNReid Kleckner2014-02-121-2/+118
| | | | | | | | | | | | | | | | | 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-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-033-33/+32
| | | | | | | | | | | | 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
* [ms-cxxabi] Raise aggregate memptr alignment to 8 for x86_32Reid Kleckner2014-01-311-0/+80
| | | | | | | | | | | | | | | | With this change, we give different results for __alignof than MSVC, but our record layout is compatible. Some data member pointers also now have a size that is not a multiple of their alignment. Fixes PR18618. Reviewers: majnemer Differential Revision: http://llvm-reviews.chandlerc.com/D2669 llvm-svn: 200585
* Remove the -cxx-abi command-line flag.Hans Wennborg2014-01-1415-31/+31
| | | | | | | | | | | | | | | 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] Leading VFPtrs don't suppress the leading zero sized flagWarren Hunt2014-01-131-0/+44
| | | | | | | | | | 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-1/+17
| | | | | | | This fixes llvm::SmallVector, which fixes lots of TUs in the MS ABI self host. llvm-svn: 199129
OpenPOWER on IntegriCloud