aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGClass.cpp
AgeCommit message (Collapse)Author
2010-03-30Handle default arguments when calling copy constructors for bases or members ↵Anders Carlsson
when synthesizing a copy constructor. Fixes PR6628. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99864 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-29Flip the switch to always get vtables from the VTT when necessary, I've ↵Anders Carlsson
verified that clang bootstraps with this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99800 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-29Cleanup, no functionality change.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99798 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-29Fix another thinko, so that flags don't depend on previous bases.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99791 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-29When generating base ctors/dtors, we need to lookup virtual bases using the ↵Anders Carlsson
vtable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99790 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-29Use construction vtables when needed. This is currently guarded by ↵Anders Carlsson
-fdump-vtable-layouts since it doesn't work 100% yet :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99787 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-28Reapply r99775 with a fix for a silly bug - we were setting the vtable ↵Anders Carlsson
pointer for all bases, even those without a vtable pointer :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99777 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-28Looks like I broke self-host again :(.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99776 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-28More improvements to setting the vtable pointer. We now no longer set the ↵Anders Carlsson
vtable pointer for non-virtual primary bases. We also do a pre-order traversal of the class hierarchy; this is necessary in order to get the right vbase offset offsets in base ctors/dtors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99775 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-28Factor vtable pointer setting code out into a separate function.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99773 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-26Revert r99612 and see if it fixes self-host.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99614 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-26Don't initialize virtual pointers for primary bases, they've already been ↵Anders Carlsson
initialized. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99612 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-26Simplify InitializeVtablePtrs in preparation of making it work with ↵Anders Carlsson
construction vtables. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99609 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24Use getNamedGlobal instead of getGlobalVariable. (Fixes self-host).Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99385 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24More vtable work; preparations for moving over to the new vtable layout code ↵Anders Carlsson
(finally). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99381 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23Rename CGVtableInfo to CodeGenVTables in preparation of adding another ↵Anders Carlsson
VTableInfo class. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99250 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-11Rename getVirtualBaseOffsetIndex to getVirtualBaseOffsetOffset to reflect ↵Anders Carlsson
what it actually does. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-23Perform two more constructor/destructor code-size optimizations:John McCall
1) emit base destructors as aliases to their unique base class destructors under some careful conditions. This is enabled for the same targets that can support complete-to-base aliases, i.e. not darwin. 2) Emit non-variadic complete constructors for classes with no virtual bases as calls to the base constructor. This is enabled on all targets and in theory can trigger in situations that the alias optimization can't (mostly involving virtual bases, mostly not yet supported). These are bundled together because I didn't think it worthwhile to split them, not because they really need to be. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96842 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-19More refactoring around constructor/destructor code generation.John McCall
Fix some bugs with function-try-blocks and simplify normal try-block code generation. This implementation excludes a deleting destructor's call to operator delete() from the function-try-block, which I believe is correct but which I can't find straightforward support for at a moment's glance. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96670 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18Make deleting and complete dtor variants defer to other dtor variants byJohn McCall
calling them as subroutines. This triggers whenever the alias optimization doesn't, i.e. when the dtor has linkonce linkage or there are virtual bases or it's the deleting dtor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96605 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-18Extract out function-body code generation into its own method. No functionalityJohn McCall
change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96564 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16IRgen optimization: cache the value of 'this' and 'vtt' instead ofJohn McCall
repeatedly reloading from an alloca. We still need to create the alloca for debug info purposes (although we currently create it in all cases because of some abstraction boundaries that're hard to break down). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96403 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16When emitting complete destructors for classes with virtual bases, computeJohn McCall
the offset to the virtual bases statically inside of relying on the virtual base offsets in the object's vtable(s). This is both more efficient and sound against the destructor's manipulation of the vtables. Also extract a few helper routines. Oh and we seem to pass all tests with an optimized clang now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96327 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-07Make sure to set vtable pointers in the destructors as well.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95525 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-06Call destructors for constructed bases as well.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95502 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-06If a constructor throws an exception we need to execute the destructors for ↵Anders Carlsson
all fully constructed members. Fixes ctor_dtor_count.cpp in the test suite. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95501 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-06Remove unused variable.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95476 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-06Rearrange some checks to avoid call to isCopyConstructor() and clarify pathJohn McCall
taken for non-trivial constructors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95457 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05Standardize the parsing of function type attributes in a way thatJohn McCall
follows (as conservatively as possible) gcc's current behavior: attributes written on return types that don't apply there are applied to the function instead, etc. Only parse CC attributes as type attributes, not as decl attributes; don't accepet noreturn as a decl attribute on ValueDecls, either (it still needs to apply to other decls, like blocks). Consistently consume CC/noreturn information throughout codegen; enforce this by removing their default values in CodeGenTypes::getFunctionInfo(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95436 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03Revert the new reference binding code; I came up with a way simpler solution ↵Anders Carlsson
for the reference binding bug that is preventing self-hosting. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95223 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02Set the correct vtable pointers _before_ generating code for any member ↵Anders Carlsson
initializers. Fixes about ~2000 clang/LLVM tests in the clang-on-clang build. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95116 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-31Simplify EmitMemberInitializer; no intended functionality change.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94965 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-31Rework base and member initialization in constructors, with severalDouglas Gregor
(necessarily simultaneous) changes: - CXXBaseOrMemberInitializer now contains only a single initializer rather than a set of initialiation arguments + a constructor. The single initializer covers all aspects of initialization, including constructor calls as necessary but also cleanup of temporaries created by the initializer (which we never handled before!). - Rework + simplify code generation for CXXBaseOrMemberInitializers, since we can now just emit the initializer as an initializer. - Switched base and member initialization over to the new initialization code (InitializationSequence), so that it - Improved diagnostics for the new initialization code when initializing bases and members, to match the diagnostics produced by the previous (special-purpose) code. - Simplify the representation of type-checked constructor initializers in templates; instead of keeping the fully-type-checked AST, which is rather hard to undo at template instantiation time, throw away the type-checked AST and store the raw expressions in the AST. This simplifies instantiation, but loses a little but of information in the AST. - When type-checking implicit base or member initializers within a dependent context, don't add the generated initializers into the AST, because they'll look like they were explicit. - Record in CXXConstructExpr when the constructor call is to initialize a base class, so that CodeGen does not have to infer it from context. This ensures that we call the right kind of constructor. There are also a few "opportunity" fixes here that were needed to not regress, for example: - Diagnose default-initialization of a const-qualified class that does not have a user-declared default constructor. We had this diagnostic specifically for bases and members, but missed it for variables. That's fixed now. - When defining the implicit constructors, destructor, and copy-assignment operator, set the CurContext to that constructor when we're defining the body. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94952 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-31When performing a derived-to-base cast that we know will not change the ↵Anders Carlsson
offset, we don't need to null check the input pointer. Fixes PR5965. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94942 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-31When doing a base-to-derived cast we don't need to null check the derived ↵Anders Carlsson
value if the class offset is 0. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94939 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-31Some class related cleanup.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94938 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29Use EmitLValueForFieldInitialization when synthesizing the copy ctor as well.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94800 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29Add a new EmitLValueForFieldInitialization that will be used for ↵Anders Carlsson
initializing fields (and reference type fields in particular). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94799 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29Simplify EmitLValueForField - we can get whether the field is part of a ↵Anders Carlsson
union or not from the FieldDecl (through its DeclContext). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94798 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15Fix a couple bugs in copy assignment operator synthesis.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93546 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02Move address points to CGVtableInfo, no functionality change.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92420 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-02Correctly pass VTT parameters to constructors and destructors. The VTTs ↵Anders Carlsson
aren't yet used in the ctors/dtors, but that will follow. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92409 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01Move a few more functions away from CGCXX and to CGClass and CGExprCXX.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92399 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24Move a bunch of class related functions to CGClass.cpp, no functionality change.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92148 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-03Add CodeGenModule::ComputeThunkAdjustment, which Eli wrote.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90401 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-28Tests now pass with the assertion.Eli Friedman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90026 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-28Add a much more thorough test of casts to virtual bases, and fixEli Friedman
GetCXXBaseClassOffset to actually pass the test. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90025 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-24Get rid of the ugly CGCXX names and replace them with CGClass, CGExprCXX and ↵Anders Carlsson
CGTemporaries. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89742 91177308-0d34-0410-b5e6-96231b3b80d8