summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RecordLayoutBuilder.cpp
Commit message (Collapse)AuthorAgeFilesLines
* If a struct needs to be laid out, and it has notSean Callanan2012-02-081-0/+4
| | | | | | | | been completed yet, then complete it if possible. This fixes some assertion failures encountered by LLDB. llvm-svn: 150020
* Allow the external AST source to provide a layout without specifyingDouglas Gregor2012-01-281-42/+76
| | | | | | | the alignment (because it's not encoded in DWARF). In this case, make an educated guess at the alignment. llvm-svn: 149161
* Extend the ExternalASTSource interface to allow the AST source toDouglas Gregor2012-01-261-41/+136
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | provide the layout of records, rather than letting Clang compute the layout itself. LLDB provides the motivation for this feature: because various layout-altering attributes (packed, aligned, etc.) don't get reliably get placed into DWARF, the record layouts computed by LLDB from the reconstructed records differ from the actual layouts, and badness occurs. This interface lets the DWARF data drive layout, so we don't need the attributes preserved to get the answer write. The testing methodology for this change is fun. I've introduced a variant of -fdump-record-layouts called -fdump-record-layouts-simple that always has the simple C format and provides size/alignment/field offsets. There is also a -cc1 option -foverride-record-layout=<file> to take the output of -fdump-record-layouts-simple and parse it to produce a set of overridden layouts, which is introduced into the AST via a testing-only ExternalASTSource (called LayoutOverrideSource). Each test contains a number of records to lay out, which use various layout-changing attributes, and then dumps the layouts. We then run the test again, using the preprocessor to eliminate the layout-changing attributes entirely (which would give us different layouts for the records), but supplying the previously-computed record layouts. Finally, we diff the layouts produced from the two runs to be sure that they are identical. Note that this code makes the assumption that we don't *have* to provide the offsets of bases or virtual bases to get the layout right, because the alignment attributes don't affect it. I believe this assumption holds, but if it does not, we can extend LayoutOverrideSource to also provide base offset information. Fixes the Clang side of <rdar://problem/10169539>. llvm-svn: 149055
* constexpr irgen: Add irgen support for APValue::Struct, APValue::Union,Richard Smith2012-01-141-0/+22
| | | | | | | | | | | | | | | | | | | | APValue::Array and APValue::MemberPointer. All APValue values can now be emitted as constants. Add new CGCXXABI entry point for emitting an APValue MemberPointer. The other entrypoints dealing with constant member pointers are no longer necessary and will be removed in a later change. Switch codegen from using EvaluateAsRValue/EvaluateAsLValue to VarDecl::evaluateValue. This performs caching and deals with the nasty cases in C++11 where a non-const object's initializer can refer indirectly to previously-initialized fields within the same object. Building the intermediate APValue object incurs a measurable performance hit on pathological testcases with huge initializer lists, so we continue to build IR directly from the Expr nodes for array and record types outside of C++11. llvm-svn: 148178
* Recommit r148056 with fixes to deal with weirdness with bitfields in unions.Eli Friedman2012-01-121-4/+4
| | | | | | Original message: Make sure adding a field to a struct never reduces its size. PR11745. llvm-svn: 148070
* Revert r148056 while I investigate failures.Eli Friedman2012-01-121-4/+5
| | | | llvm-svn: 148068
* Make sure adding a field to a struct never reduces its size. PR11745.Eli Friedman2012-01-121-5/+4
| | | | llvm-svn: 148056
* When performing layout for an Objective-C class, make sure to dig outDouglas Gregor2011-12-201-1/+3
| | | | | | the definition of that class. Fixes PR11613 / <rdar://problem/10604077>. llvm-svn: 146976
* Keep track of all declarations of an Objective-C class (both forwardDouglas Gregor2011-12-151-1/+1
| | | | | | | | | | declarations and definitions) as ObjCInterfaceDecls within the same redeclaration chain. This new representation matches what we do for C/C++ variables/functions/classes/templates/etc., and makes it possible to answer the query "where are all of the declarations of this class?" llvm-svn: 146679
* Fixes a bug in calculation of field offsets of ms_structFariborz Jahanian2011-12-121-3/+14
| | | | | | | fields by just following what comment says. // rdar://10513599 llvm-svn: 146414
* Fix bitfield handling for record layout with #pragma pack. ↵Eli Friedman2011-12-021-3/+5
| | | | | | <rdar://problem/10494810> and PR9560. llvm-svn: 145673
* Fix MSVC class layout for empty classes. Patch by Dmitry Sokolov.Eli Friedman2011-12-011-4/+9
| | | | llvm-svn: 145544
* Fix the layout of vb-tables and vf-tables in the MS C++ ABI.John McCall2011-11-081-184/+202
| | | | | | Based on work by Dmitry Sokolov! llvm-svn: 144072
* Now that we have a portable 64 bit format string use it to make this simple ↵Benjamin Kramer2011-11-051-2/+1
| | | | | | again. llvm-svn: 143800
* Fix incorrect format string in debug output.Eli Friedman2011-11-051-1/+2
| | | | llvm-svn: 143768
* More ASTRecordLayout changes for MS ABI; based on patch by r4start.Eli Friedman2011-10-211-24/+32
| | | | llvm-svn: 142694
* Revert accidental commit.Eli Friedman2011-10-181-2/+2
| | | | llvm-svn: 142326
* Rewrite parts of MS ABI C++ layout. Based on work by r4start; I ended up ↵Eli Friedman2011-10-181-87/+82
| | | | | | doing this while I was trying to review his patch. llvm-svn: 142325
* Change operator<< for raw_ostream and NamedDecl to take a reference instead ↵Benjamin Kramer2011-10-141-4/+4
| | | | | | | | of a pointer. Passing a pointer was a bad idea as it collides with the overload for void*. llvm-svn: 141971
* Constant expression evaluation refactoring:Richard Smith2011-10-101-10/+6
| | | | | | | | | | | - Remodel Expr::EvaluateAsInt to behave like the other EvaluateAs* functions, and add Expr::EvaluateKnownConstInt to capture the current fold-or-assert behaviour. - Factor out evaluation of bitfield bit widths. - Fix a few places which would evaluate an expression twice: once to determine whether it is a constant expression, then again to get the value. llvm-svn: 141561
* Rename TagDecl::isDefinition -> isCompleteDefinitionJohn McCall2011-10-071-1/+1
| | | | | | | for better self-documenting code, since the semantics are subtly different from getDefinition(). llvm-svn: 141355
* Record layout requires not just a definition, but a completeJohn McCall2011-10-071-0/+5
| | | | | | | | definition. Assert this. Change IR generation to not try to aggressively emit the IR translation of a record during its own definition. Fixes PR10912. llvm-svn: 141350
* Driver & AST: Implement support for -fpack-struct and -fpack-struct= commandDaniel Dunbar2011-10-051-0/+5
| | | | | | | line options. - <rdar://problem/10120602>, PR9631 llvm-svn: 141211
* Fix doxygen comment.Eric Christopher2011-10-051-2/+2
| | | | llvm-svn: 141165
* Some changes to improve compatibility for MSVC-style C++ struct layout. ↵Eli Friedman2011-09-271-38/+207
| | | | | | Patch from r4start at gmail.com (with some minor modifications by me). llvm-svn: 140623
* Don't emit -Wpadded warnings without a valid SourceLocation. This can ↵Ted Kremenek2011-09-061-0/+5
| | | | | | happen when RecordLayoutBuilder is used by Codegen, not Sema. llvm-svn: 139162
* Extend the ASTContext constructor to delay the initialization ofDouglas Gregor2011-09-021-22/+22
| | | | | | | | builtin types (When requested). This is another step toward making ASTUnit build the ASTContext as needed when loading an AST file, rather than doing so after the fact. No actual functionality change (yet). llvm-svn: 138985
* Add support for using anonymous bitfields (e.g., int : 0) to enforce alignment.Chad Rosier2011-08-051-23/+39
| | | | | | | | | | | | | | | This fixes cases where the anonymous bitfield is followed by a bitfield member. E.g., struct t4 { char foo; long : 0; char bar : 1; }; rdar://9859156 llvm-svn: 136991
* More whitespace and naming fixup. No functionality change.Chad Rosier2011-08-041-2/+2
| | | | llvm-svn: 136944
* Fix style and remove obviously redundant code.Chad Rosier2011-08-041-2/+1
| | | | llvm-svn: 136907
* Additional comments and whitespace.Chad Rosier2011-08-041-3/+3
| | | | llvm-svn: 136892
* Add partial support for using anonymous bitfields (e.g., int : 0) to enforce Chad Rosier2011-08-041-11/+30
| | | | | | | | | | | | | | | | alignment. This fixes cases where the anonymous bitfield is followed by a non-bitfield member. E.g., struct t4 { int foo : 1; long : 0; char bar; }; Part of rdar://9859156 llvm-svn: 136858
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-6/+6
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Add a const overload for ObjCInterfaceDecl::all_declared_ivar_begin.Jordy Rose2011-07-221-3/+2
| | | | | | | | | This was previously not-const only because it has to lazily construct a chain of ivars the first time it is called (and after the chain is invalidated). In practice, all the clients were just const_casting their const Decls; all those now-unnecessary const_casts have been removed. llvm-svn: 135741
* Eliminate most uses of ShallowCollectObjCIvars which requiresFariborz Jahanian2011-06-281-5/+4
| | | | | | | a vector for collection. Use iterators where needed instead. // rdar://6817577 llvm-svn: 134015
* PR10120: Make CodeGenModule::getVTableLinkage use NamedDecl::getLinkage to ↵Eli Friedman2011-06-101-2/+2
| | | | | | | | determine whether the vtable should be externally visible, instead of a rough approximation of it which messes up with templates. While I'm here, zap the other user of isInAnonymousNamespace outside of Decl.cpp. llvm-svn: 132861
* Implenment #pack pragma and ms_struct attribute layout.Fariborz Jahanian2011-05-111-1/+47
| | | | | | Concludes // radar://8823265. llvm-svn: 131188
* Support pack pragma and ms_struct attributes. // rdar://8823265Fariborz Jahanian2011-05-101-0/+7
| | | | llvm-svn: 131142
* 'long long' requires special treatment in ms_structFariborz Jahanian2011-05-091-0/+10
| | | | | | structs (impacts 32-bit only though). llvm-svn: 131103
* In ms_struct structs, Establish a new alignment for a Fariborz Jahanian2011-05-061-3/+7
| | | | | | non-bitfield following a bitfield if size of their types differ. llvm-svn: 131032
* Establish a new alignment for an ms_struct bitfield followingFariborz Jahanian2011-05-061-1/+4
| | | | | | a non-bitfield if size of their types differ. llvm-svn: 131023
* More ms_struct bitfield stuff:Fariborz Jahanian2011-05-041-1/+26
| | | | | | | | Adjacent bit fields are packed into the same 1-, 2-, or 4-byte allocation unit if the integral types are the same size. // rdar://8823265. llvm-svn: 130851
* Only the first zero-length bitfield decides alignment ofFariborz Jahanian2011-05-031-2/+4
| | | | | | | the followup data member in an ms_struct struct. // rdar:// 8823265 llvm-svn: 130795
* Finish off rules for z-length bitfields in ms_structFariborz Jahanian2011-05-031-16/+35
| | | | | | structs. // rdar://8823265 llvm-svn: 130783
* More rule enforcement of zero bitfields for ms_struct.Fariborz Jahanian2011-05-021-2/+17
| | | | llvm-svn: 130696
* Some refactoring of my ms_struct patch.Fariborz Jahanian2011-04-271-3/+1
| | | | | | // rdar://8823265 related. llvm-svn: 130311
* With ms_struct attribut, Zero-length bitfields following Fariborz Jahanian2011-04-261-2/+19
| | | | | | non-bitfield members are ignore. // rdar://8823265 wip llvm-svn: 130257
* Simplify crash recovery cleanup registration.Ted Kremenek2011-03-221-3/+2
| | | | llvm-svn: 128057
* Recover memory from RecordLayoutBuilders during crashes.Ted Kremenek2011-03-191-1/+6
| | | | llvm-svn: 127931
* Instead of round up sizes to '8', round them up to the alignment of the charKen Dyck2011-03-101-2/+4
| | | | | | type. llvm-svn: 127391
OpenPOWER on IntegriCloud