summaryrefslogtreecommitdiff
path: root/lib/AST/RecordLayoutBuilder.cpp
Commit message (Collapse)AuthorAge
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208517 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix some typosAlp Toker2014-05-05
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207994 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace one-element SmallVectors inside DenseMaps with TinyPtrVector.Benjamin Kramer2014-05-03
| | | | | | That's exactly what TinyPtrVector was designed for. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207919 91177308-0d34-0410-b5e6-96231b3b80d8
* MS ABI: Bitfields FielDecls only align if they allocateDavid Majnemer2014-04-13
| | | | | | | | | Don't consider a __declspec(align) on a bitfield's declaration if it didn't allocate any underlying storage. This fixes PR19414. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206132 91177308-0d34-0410-b5e6-96231b3b80d8
* MS ABI: #pragma vtordisp(0) only disables new vtordispsDavid Majnemer2014-04-13
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206124 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Fix warning introduced in r206087Warren Hunt2014-04-12
| | | | | | | No functional change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206090 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Fixed alias-avoidance padding in the presence of vtordispsWarren Hunt2014-04-11
| | | | | | | | If a vtordisp exists between two bases, then there is no need for additional alias avoidance padding. Test case included. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206087 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Update to vtordisp computationWarren Hunt2014-04-11
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206077 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify RecordLayoutBuilder with getAsCXXRecordDecl()Reid Kleckner2014-04-11
| | | | | | No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206038 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Update Comments in RecordLayoutBuilder - no functional changeWarren Hunt2014-04-11
| | | | | | | | | | This patch updates the comments in RecordLayoutBuilder about record layout in the MS-ABI. Also, I added a section about known incompatibilities. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206010 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Update virtual base padding rules to match MSVC 10+Warren Hunt2014-04-11
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206004 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Fix to vbptr injection site calculation.Warren Hunt2014-04-10
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206000 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Fixed __declspec(align()) on bitfields under #pragma pack.Warren Hunt2014-04-10
| | | | | | | | | | | | | | | | 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) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205994 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Update to alias-avoidance paddingWarren Hunt2014-04-09
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205933 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a bug where an explicit instantiation declaration of a class templateRichard Smith2014-03-24
| | | | | | | specialization would make us think it might have a key function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204686 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Drop Special Layout in 64-bit mode.Warren Hunt2014-03-24
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204674 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing CXXRecordDecl iterators method_begin() and method_end() ↵Aaron Ballman2014-03-13
| | | | | | with iterator_range methods(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203812 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing CXXRecordDecl iterators vbases_begin() and vbases_end() ↵Aaron Ballman2014-03-13
| | | | | | with iterator_range vbases(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203808 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing CXXRecordDecl iterators bases_begin() and bases_end() with ↵Aaron Ballman2014-03-13
| | | | | | iterator_range bases(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203803 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing RecordDecl iterators field_begin() and field_end() with ↵Aaron Ballman2014-03-08
| | | | | | iterator_range fields(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203355 91177308-0d34-0410-b5e6-96231b3b80d8
* Renaming the chains() ranged iterator to chain() per suggestion by Richard ↵Aaron Ballman2014-03-07
| | | | | | Smith. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203262 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replacing IndirectFieldDecl iterators chain_begin() and chain_end() ↵Aaron Ballman2014-03-07
| | | | | | with iterator_range chains(). Updating all of the usages of the iterators with range-based for loops. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203261 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-02
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202639 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Replace verbose functors with succinct lambdasBenjamin Kramer2014-03-01
| | | | | | No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202590 91177308-0d34-0410-b5e6-96231b3b80d8
* Attempt to fix non-MSVC buildReid Kleckner2014-02-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202458 91177308-0d34-0410-b5e6-96231b3b80d8
* -fdump-record-layouts: Sort nvbases by offset before printing themReid Kleckner2014-02-28
| | | | | | It makes our -fdump-record-layouts a little more sane. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202457 91177308-0d34-0410-b5e6-96231b3b80d8
* Diagnose attempts to apply ms_struct to records with base classesJohn McCall2014-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | or virtual functions, but permit that error to be downgraded to a warning (with -Wno-error=incompatible-ms-struct), and officially support this kind of dual, ABI-mixing layout. The basic problem here is that projects which use ms_struct are often not very circumspect about what types they annotate; for example, some projects enable the pragma in a prefix header and then only selectively disable it around system header inclusions. They may only care about binary compatibility with MSVC for a subset of those structs, but that doesn't mean they have no binary compatibility concerns at all for the rest; thus we are essentially forced into supporting this hybrid ABI. But it's reasonable for us to at least point out the places where we're not making any guarantees. The original diagnostic was for dynamic classes, i.e. those with virtual functions or virtual bases; I've extended it to include all classes with bases, because we are not actually making any attempt to duplicate MSVC's base subobject layout in ms_struct (and it is indeed quite different from Itanium, even for non-virtual bases). rdar://16178895 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202427 91177308-0d34-0410-b5e6-96231b3b80d8
* MS ABI: Just use getTypeInfoInChars to get the field sizeReid Kleckner2014-02-25
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202175 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Fix MSRecordLayout to handel MultiDimensionalArraysWarren Hunt2014-02-22
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201917 91177308-0d34-0410-b5e6-96231b3b80d8
* [MS-ABI] Update to zero-sized padding algorithmWarren Hunt2014-02-21
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201832 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert "Enable MSRecordLayout in the presence of external sources."Reid Kleckner2014-02-20
| | | | | | | | | | | This reverts commit r201810. It was failing these tests on my workstation: Clang :: CodeGen/override-layout.c Clang :: CodeGenCXX/override-layout.cpp Clang :: PCH/check-deserializations.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201823 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable MSRecordLayout in the presence of external sources.Warren Hunt2014-02-20
| | | | | | | | | | | External sources shouldn't prevent the layout engine from using MSLayout. If lldb were to support debugging in microsoft mode, some code will need to be added to MSRecordLayoutBuilder to handel external layouts. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201810 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixing a compiler assertion with zero-width bit-fields in packed structs.Yunzhong Gao2014-02-13
| | | | | | | | | | | According to the GNU docs, zero-sized bitfields should not be affected by the packed attribute. Differential Revision: http://llvm-reviews.chandlerc.com/D2693 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201288 91177308-0d34-0410-b5e6-96231b3b80d8
* ms_struct layout replaces platform-specific behavior likeJohn McCall2014-02-13
| | | | | | | | | useBitFieldTypeAlignment() and appears to ignore the special bit-packing semantics of __attribute__((packed)). Further flesh out an already-extensive comment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201282 91177308-0d34-0410-b5e6-96231b3b80d8
* MS ABI: Implement #pragma vtordisp() and clang-cl /vdNReid Kleckner2014-02-12
| | | | | | | | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201274 91177308-0d34-0410-b5e6-96231b3b80d8
* MS ABI: vptr injection should obey alignment requirementsDavid Majnemer2014-02-12
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201199 91177308-0d34-0410-b5e6-96231b3b80d8
* Extensively comment bitfield layout, rearrange someJohn McCall2014-01-29
| | | | | | | | | code for legibility, and fix a bug with bitfields in packed ms_structs. rdar://15926990 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200379 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Small Change to pack+alignment interaction.Warren Hunt2014-01-14
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199172 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Report VBPtrOffset correctlyWarren Hunt2014-01-14
| | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199168 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Reordering __declspec(align) pragma pack handlingWarren Hunt2014-01-13
| | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199154 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Leading VFPtrs don't suppress the leading zero sized flagWarren Hunt2014-01-13
| | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199132 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Quick fix layout of an array of recordsReid Kleckner2014-01-13
| | | | | | | This fixes llvm::SmallVector, which fixes lots of TUs in the MS ABI self host. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199129 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Change the way alignment is trackedWarren Hunt2014-01-11
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198988 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Adjusting Rules for Padding Between BasesWarren Hunt2014-01-10
| | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198975 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Handle __declspec(align) on bitfields "properly"Warren Hunt2014-01-10
| | | | | | | | | | | | __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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198907 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Fixing CGRecordLayoutBuilder w.r.t. MS NonVirutalBase LayoutWarren Hunt2014-01-09
| | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198900 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix the clang -Werror build after r198818David Blaikie2014-01-09
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198837 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Refactor Microsoft Record LayoutWarren Hunt2014-01-09
| | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198818 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Fixes improperly sized vfptrs with pragma packWarren Hunt2013-12-26
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198059 91177308-0d34-0410-b5e6-96231b3b80d8
* [ms-abi] Update Alignment for VtorDispsWarren Hunt2013-12-19
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197639 91177308-0d34-0410-b5e6-96231b3b80d8