summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RecordLayout.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Remove trailing spaceFangrui Song2018-07-301-1/+1
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* [ARM, AArch64]: Use unadjusted alignment when passing composites as argumentsMomchil Velikov2018-07-301-0/+4
| | | | | | | | | | | | | | | | | | The "Procedure Call Procedure Call Standard for the ARM® Architecture" (https://static.docs.arm.com/ihi0042/f/IHI0042F_aapcs.pdf), specifies that composite types are passed according to their "natural alignment", i.e. the alignment before alignment adjustment on the entire composite is applied. The same applies for AArch64 ABI. Clang, however, used the adjusted alignment. GCC already implements the ABI correctly. With this patch Clang becomes compatible with GCC and passes such arguments in accordance with AAPCS. Differential Revision: https://reviews.llvm.org/D46013 llvm-svn: 338279
* [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other ↵Eugene Zelenko2017-11-101-4/+5
| | | | | | minor fixes (NFC). llvm-svn: 317854
* [RecordLayout] Use an ASTVector instead of using a separate pointer and counterDavid Majnemer2016-05-241-20/+8
| | | | | | No functional change is intended. llvm-svn: 270591
* [MS ABI] Implement __declspec(empty_bases) and __declspec(layout_version)David Majnemer2016-05-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* CXXInfo memory should be released after calling the destructorYaron Keren2014-05-241-1/+1
| | | | | | | instead of before. The wrong order had no effect since Deallocate() does nothing right now, but we may replace allocator in the future. llvm-svn: 209567
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-121-3/+3
| | | | llvm-svn: 208517
* [ms-abi] Refactor Microsoft Record LayoutWarren Hunt2014-01-091-2/+2
| | | | | | | | | 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] Fix alias-avoidance padding between basesWarren Hunt2013-12-061-0/+4
| | | | | | | | | | | 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-5/+8
| | | | | | | | | | | | | | | | | | __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
* No functional change. Renaming a variable in RecordLayoutBuilder and Warren Hunt2013-11-131-2/+2
| | | | | | | | 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-2/+2
| | | | | | Reviewed at http://llvm-reviews.chandlerc.com/D2120 llvm-svn: 194256
* Adds Microsoft compatiable C++ record layout code to clang.Warren Hunt2013-10-111-1/+8
| | | | llvm-svn: 192494
* First pass at abstracting out a class for the target C++ ABI.John McCall2013-01-251-4/+3
| | | | llvm-svn: 173514
* Remove get(V)BaseClassOffsetInBits, the CharUnit functions should be used ↵Benjamin Kramer2012-07-041-1/+1
| | | | | | | | instead. No functionality change. llvm-svn: 159719
* Add support for laying out vtordisps according to our currentJohn McCall2012-05-011-5/+5
| | | | | | | working knowledge of the Microsoft ABI. Based on a patch by Dmitry Sokolov. llvm-svn: 155905
* More ASTRecordLayout changes for MS ABI; based on patch by r4start.Eli Friedman2011-10-211-1/+3
| | | | llvm-svn: 142694
* Some changes to improve compatibility for MSVC-style C++ struct layout. ↵Eli Friedman2011-09-271-3/+9
| | | | | | Patch from r4start at gmail.com (with some minor modifications by me). llvm-svn: 140623
* Convert RecordLayout::Alignment to CharUnits from bit units. No change inKen Dyck2011-02-151-2/+2
| | | | | | functionality intended. llvm-svn: 125549
* Convert RecordLayout::DataSize to CharUnits from bits, eliminating twoKen Dyck2011-02-111-2/+2
| | | | | | | unnecessary calls to RoundUpToAlignment. No changes to functionality intended. llvm-svn: 125356
* Convert RecordLayout::Size to CharUnits from bits. No changes toKen Dyck2011-02-091-2/+2
| | | | | | functionality intended. llvm-svn: 125156
* Convert RecordLayout::NonVirtualAlign to CharUnits. No change inKen Dyck2011-02-081-1/+1
| | | | | | functionality intended. llvm-svn: 125069
* Convert RecordLayout::NonVirtualSize from bit units to CharUnits.Ken Dyck2011-02-011-1/+1
| | | | llvm-svn: 124646
* PR3558: mark "logically const" accessor methods in ASTContext as const,Jay Foad2011-01-121-4/+5
| | | | | | | and mark the fields they use as mutable. This allows us to remove a few const_casts. llvm-svn: 123314
* Remove the PrimaryBaseInfo class.Anders Carlsson2010-11-241-2/+3
| | | | llvm-svn: 120134
* Rename RecordLayout::getPrimaryBaseWasVirtual to isPrimaryBaseVirtual.Anders Carlsson2010-11-241-1/+1
| | | | llvm-svn: 120133
* Port over a couple of getVBaseClassOffsetInBits call sites to use ↵Anders Carlsson2010-10-311-1/+1
| | | | | | getVBaseClassOffset instead. llvm-svn: 117882
* Rename getBaseClassOffset to getBaseClassOffsetInBits and introduce a ↵Anders Carlsson2010-10-311-2/+2
| | | | | | getBaseClassOffset which returns the offset in CharUnits. Do the same thing for getVBaseClassOffset. llvm-svn: 117881
* EmptyObjectMap now uses CharUnits wherever possible.Anders Carlsson2010-10-311-1/+1
| | | | llvm-svn: 117877
* Plug leak. The DenseMaps of CXXRecordLayoutInfo weren't freed.Argyrios Kyrtzidis2010-08-251-1/+3
| | | | llvm-svn: 112006
* No need to use the PrimaryBaseInfo struct in the builder.Anders Carlsson2010-05-261-2/+3
| | | | llvm-svn: 104681
* Add a SizeOfLargestEmptySubobject member to ASTRecordLayout. For C++ classes ↵Anders Carlsson2010-05-081-0/+2
| | | | | | this will hold the largest empty subobject or 0 if the class doesn't have any empty subobjects. llvm-svn: 103359
* Replace the class offset vectors in RecordLayoutBuilder with maps instead so ↵Anders Carlsson2010-03-111-15/+11
| | | | | | we'll have faster lookup and so we can detect duplicates. llvm-svn: 98231
* Assert that primary bases always have offset 0.Anders Carlsson2010-03-111-0/+11
| | | | llvm-svn: 98223
* Replace copy loops with memcpy.Benjamin Kramer2010-03-091-4/+2
| | | | llvm-svn: 98055
* Allocate ASTRecordLayout objects using the allocator associated with ASTContext.Ted Kremenek2010-03-081-0/+69
This allows them to be allocated using a BumpPtrAllocated in the common case. llvm-svn: 97978
OpenPOWER on IntegriCloud