summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RecordLayoutBuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-1/+1
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* Do not insert asan paddings after fields that have flexible arrays.Kostya Serebryany2014-10-271-3/+8
| | | | | | | | | | | | | | | | | | | Summary: We should avoid a tail padding not only if the last field has zero size but also if the last field is a struct with a flexible array. If/when http://reviews.llvm.org/D5478 is committed, this will also handle the case of structs with zero-sized arrays. Reviewers: majnemer, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5924 llvm-svn: 220708
* D5775: Fix of assertion failure in case of non-POD unions with bitfields. ↵Artyom Skrobov2014-10-171-4/+14
| | | | | | Patch by Evgeny Astigeevich! llvm-svn: 220031
* AST: Remove dead code from RecordLayoutBuilderDavid Majnemer2014-10-171-11/+0
| | | | | | No functionality change intended. llvm-svn: 220005
* Insert poisoned paddings between fields in C++ classes so that ↵Kostya Serebryany2014-10-161-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | AddressSanitizer can find intra-object-overflow bugs Summary: The general approach is to add extra paddings after every field in AST/RecordLayoutBuilder.cpp, then add code to CTORs/DTORs that poisons the paddings (CodeGen/CGClass.cpp). Everything is done under the flag -fsanitize-address-field-padding. The blacklist file (-fsanitize-blacklist) allows to avoid the transformation for given classes or source files. See also https://code.google.com/p/address-sanitizer/wiki/IntraObjectOverflow Test Plan: run SPEC2006 and some of the Chromium tests with -fsanitize-address-field-padding Reviewers: samsonov, rnk, rsmith Reviewed By: rsmith Subscribers: majnemer, cfe-commits Differential Revision: http://reviews.llvm.org/D5687 llvm-svn: 219961
* AST: Fix a typo (NFC)Justin Bogner2014-10-081-1/+1
| | | | llvm-svn: 219279
* MS ABI: Correct layout for empty recordsDavid Majnemer2014-09-301-3/+13
| | | | | | | | 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: Fix a typo in RecordLayoutBuilderDavid Majnemer2014-09-291-1/+1
| | | | | | No functional change intended. llvm-svn: 218628
* MS ABI: Pure virtual functions don't contribute to vtordispsDavid Majnemer2014-09-231-14/+13
| | | | | | | | | | | 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
* MS ABI: Consider alignment attributes on typedefs for layoutDavid Majnemer2014-07-301-6/+12
| | | | | | | | | | | | | | | | | | | 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-1/+1
| | | | | | Only alignment is changed, not required alignment. llvm-svn: 213217
* MS ABI: Up the required alignment after inserting padding between vbasesDavid Majnemer2014-07-161-1/+3
| | | | | | | | | | 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
* AST: Convert a SmallPtrSet to a SmallPtrSetImpl in RecordLayoutBuilderDavid Majnemer2014-07-161-4/+4
| | | | | | No functionality changed, it just makes the code a little less brittle. llvm-svn: 213122
* AST: Cleanup RecordLayoutBuilderDavid Majnemer2014-07-161-90/+77
| | | | | | | | | | | No functionality changed, just some cleanups: - Switch some loops to range-based for. - Name some iterators with a more creative name than "I". - Reduce dependence on auto. Does RD->bases() give you a list of CXXBaseSpecifiers or CXXRecordDecls? It's more clear to just say which upfront. llvm-svn: 213121
* Fix an iterator invalidation issue: deserializing a key function can write toRichard Smith2014-07-071-7/+18
| | | | | | | the key functions table. Don't hold references to anything within that table across such an access. llvm-svn: 212437
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-121-27/+28
| | | | llvm-svn: 208517
* Fix some typosAlp Toker2014-05-051-2/+2
| | | | llvm-svn: 207994
* Replace one-element SmallVectors inside DenseMaps with TinyPtrVector.Benjamin Kramer2014-05-031-1/+1
| | | | | | That's exactly what TinyPtrVector was designed for. No functionality change. llvm-svn: 207919
* MS ABI: Bitfields FielDecls only align if they allocateDavid Majnemer2014-04-131-3/+5
| | | | | | | | | Don't consider a __declspec(align) on a bitfield's declaration if it didn't allocate any underlying storage. This fixes PR19414. llvm-svn: 206132
* MS ABI: #pragma vtordisp(0) only disables new vtordispsDavid Majnemer2014-04-131-12/+9
| | | | | | | | | | | 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] Fix warning introduced in r206087Warren Hunt2014-04-121-2/+2
| | | | | | No functional change. llvm-svn: 206090
* [MS-ABI] Fixed alias-avoidance padding in the presence of vtordispsWarren Hunt2014-04-111-4/+1
| | | | | | | 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-33/+37
| | | | | | | | | | 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
* Simplify RecordLayoutBuilder with getAsCXXRecordDecl()Reid Kleckner2014-04-111-57/+34
| | | | | | No functionality change. llvm-svn: 206038
* [MS-ABI] Update Comments in RecordLayoutBuilder - no functional changeWarren Hunt2014-04-111-31/+67
| | | | | | | | This patch updates the comments in RecordLayoutBuilder about record layout in the MS-ABI. Also, I added a section about known incompatibilities. llvm-svn: 206010
* [MS-ABI] Update virtual base padding rules to match MSVC 10+Warren Hunt2014-04-111-7/+0
| | | | | | | | | | 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-101-8/+8
| | | | | | | | 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-34/+31
| | | | | | | | | | | | | | | 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-16/+15
| | | | | | | | | | 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
* Fix a bug where an explicit instantiation declaration of a class templateRichard Smith2014-03-241-1/+2
| | | | | | specialization would make us think it might have a key function. llvm-svn: 204686
* [MS-ABI] Drop Special Layout in 64-bit mode.Warren Hunt2014-03-241-72/+4
| | | | | | | | | 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
* [C++11] Replacing CXXRecordDecl iterators method_begin() and method_end() ↵Aaron Ballman2014-03-131-9/+4
| | | | | | with iterator_range methods(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203812
* [C++11] Replacing CXXRecordDecl iterators vbases_begin() and vbases_end() ↵Aaron Ballman2014-03-131-29/+17
| | | | | | with iterator_range vbases(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203808
* [C++11] Replacing CXXRecordDecl iterators bases_begin() and bases_end() with ↵Aaron Ballman2014-03-131-71/+49
| | | | | | iterator_range bases(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203803
* [C++11] Replacing RecordDecl iterators field_begin() and field_end() with ↵Aaron Ballman2014-03-081-10/+5
| | | | | | iterator_range fields(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203355
* Renaming the chains() ranged iterator to chain() per suggestion by Richard ↵Aaron Ballman2014-03-071-1/+1
| | | | | | Smith. llvm-svn: 203262
* [C++11] Replacing IndirectFieldDecl iterators chain_begin() and chain_end() ↵Aaron Ballman2014-03-071-4/+2
| | | | | | with iterator_range chains(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203261
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-021-1/+1
| | | | llvm-svn: 202639
* [C++11] Replace verbose functors with succinct lambdasBenjamin Kramer2014-03-011-12/+4
| | | | | | No functionality change. llvm-svn: 202590
* Attempt to fix non-MSVC buildReid Kleckner2014-02-281-7/+10
| | | | llvm-svn: 202458
* -fdump-record-layouts: Sort nvbases by offset before printing themReid Kleckner2014-02-281-7/+22
| | | | | | It makes our -fdump-record-layouts a little more sane. llvm-svn: 202457
* Diagnose attempts to apply ms_struct to records with base classesJohn McCall2014-02-271-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 202427
* MS ABI: Just use getTypeInfoInChars to get the field sizeReid Kleckner2014-02-251-10/+4
| | | | | | | | | | | | 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-2/+3
| | | | | | | | 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-20/+23
| | | | | | | | | | 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
* Revert "Enable MSRecordLayout in the presence of external sources."Reid Kleckner2014-02-201-1/+1
| | | | | | | | | | | 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 llvm-svn: 201823
* Enable MSRecordLayout in the presence of external sources.Warren Hunt2014-02-201-1/+1
| | | | | | | | | 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. llvm-svn: 201810
* Fixing a compiler assertion with zero-width bit-fields in packed structs.Yunzhong Gao2014-02-131-2/+2
| | | | | | | | | According to the GNU docs, zero-sized bitfields should not be affected by the packed attribute. Differential Revision: http://llvm-reviews.chandlerc.com/D2693 llvm-svn: 201288
* ms_struct layout replaces platform-specific behavior likeJohn McCall2014-02-131-17/+46
| | | | | | | | | useBitFieldTypeAlignment() and appears to ignore the special bit-packing semantics of __attribute__((packed)). Further flesh out an already-extensive comment. llvm-svn: 201282
* 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
OpenPOWER on IntegriCloud