Commit Graph

50 Commits

Author SHA1 Message Date
Anders Carlsson 093bdff0c5 Factor emitting a call to a copy constructor out into a separate function.
llvm-svn: 99866
2010-03-30 03:27:09 +00:00
Anders Carlsson b9fd57f198 Introduce a CXXTemporariesCleanupScope RAII object and use it to cleanup the temporaries code.
llvm-svn: 99865
2010-03-30 03:14:41 +00:00
Anders Carlsson 10834b8d56 Handle default arguments when calling copy constructors for bases or members when synthesizing a copy constructor. Fixes PR6628.
llvm-svn: 99864
2010-03-30 02:57:48 +00:00
Anders Carlsson 383f4cc8b9 Flip the switch to always get vtables from the VTT when necessary, I've verified that clang bootstraps with this.
llvm-svn: 99800
2010-03-29 02:38:51 +00:00
Anders Carlsson f6f24c609b Cleanup, no functionality change.
llvm-svn: 99798
2010-03-29 02:08:26 +00:00
Anders Carlsson 948d3f4ec6 Fix another thinko, so that flags don't depend on previous bases.
llvm-svn: 99791
2010-03-29 01:16:41 +00:00
Anders Carlsson 74d7dfcf8e When generating base ctors/dtors, we need to lookup virtual bases using the vtable.
llvm-svn: 99790
2010-03-29 01:14:25 +00:00
Anders Carlsson 5889027ccc Use construction vtables when needed. This is currently guarded by -fdump-vtable-layouts since it doesn't work 100% yet :)
llvm-svn: 99787
2010-03-29 01:08:49 +00:00
Anders Carlsson d589593c93 Reapply r99775 with a fix for a silly bug - we were setting the vtable pointer for all bases, even those without a vtable pointer :)
llvm-svn: 99777
2010-03-28 21:07:49 +00:00
Anders Carlsson fcc9f91287 Looks like I broke self-host again :(.
llvm-svn: 99776
2010-03-28 20:55:21 +00:00
Anders Carlsson 74eab715ae More improvements to setting the vtable pointer. We now no longer set the 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.
llvm-svn: 99775
2010-03-28 20:34:31 +00:00
Anders Carlsson e87fae9afa Factor vtable pointer setting code out into a separate function.
llvm-svn: 99773
2010-03-28 19:40:00 +00:00
Anders Carlsson aaf8acfea1 Revert r99612 and see if it fixes self-host.
llvm-svn: 99614
2010-03-26 06:35:42 +00:00
Anders Carlsson 6fffc64dd2 Don't initialize virtual pointers for primary bases, they've already been initialized.
llvm-svn: 99612
2010-03-26 05:53:12 +00:00
Anders Carlsson 1f9348c1fc Simplify InitializeVtablePtrs in preparation of making it work with construction vtables.
llvm-svn: 99609
2010-03-26 04:39:42 +00:00
Anders Carlsson 67fbf9853f Use getNamedGlobal instead of getGlobalVariable. (Fixes self-host).
llvm-svn: 99385
2010-03-24 05:32:05 +00:00
Anders Carlsson b35ea55e2e More vtable work; preparations for moving over to the new vtable layout code (finally).
llvm-svn: 99381
2010-03-24 03:57:14 +00:00
Anders Carlsson a864caff8c Rename CGVtableInfo to CodeGenVTables in preparation of adding another VTableInfo class.
llvm-svn: 99250
2010-03-23 04:11:45 +00:00
Anders Carlsson 4cbe83cccb Rename getVirtualBaseOffsetIndex to getVirtualBaseOffsetOffset to reflect what it actually does.
llvm-svn: 98248
2010-03-11 07:15:17 +00:00
John McCall f8ff7b9fd1 Perform two more constructor/destructor code-size optimizations:
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.

llvm-svn: 96842
2010-02-23 00:48:20 +00:00
John McCall b81884d347 More refactoring around constructor/destructor code generation.
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.

llvm-svn: 96670
2010-02-19 09:25:03 +00:00
John McCall 5c60a6f597 Make deleting and complete dtor variants defer to other dtor variants by
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.

llvm-svn: 96605
2010-02-18 19:59:28 +00:00
John McCall 89b12b34f6 Extract out function-body code generation into its own method. No functionality
change.

llvm-svn: 96564
2010-02-18 03:17:58 +00:00
John McCall 347132b32f IRgen optimization: cache the value of 'this' and 'vtt' instead of
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).

llvm-svn: 96403
2010-02-16 22:04:33 +00:00
John McCall 6ce747220a When emitting complete destructors for classes with virtual bases, compute
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.

llvm-svn: 96327
2010-02-16 04:15:37 +00:00
Anders Carlsson ff8cce4395 Make sure to set vtable pointers in the destructors as well.
llvm-svn: 95525
2010-02-07 19:45:40 +00:00
Anders Carlsson 5ade5d39b4 Call destructors for constructed bases as well.
llvm-svn: 95502
2010-02-06 20:00:21 +00:00
Anders Carlsson ba63167b64 If a constructor throws an exception we need to execute the destructors for all fully constructed members. Fixes ctor_dtor_count.cpp in the test suite.
llvm-svn: 95501
2010-02-06 19:50:17 +00:00
Ted Kremenek 9c193965ba Remove unused variable.
llvm-svn: 95476
2010-02-06 03:29:18 +00:00
John McCall ca972cd1f1 Rearrange some checks to avoid call to isCopyConstructor() and clarify path
taken for non-trivial constructors.

llvm-svn: 95457
2010-02-06 00:25:16 +00:00
John McCall ab26cfa58d Standardize the parsing of function type attributes in a way that
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().

llvm-svn: 95436
2010-02-05 21:31:56 +00:00
Anders Carlsson 3b227bd629 Revert the new reference binding code; I came up with a way simpler solution for the reference binding bug that is preventing self-hosting.
llvm-svn: 95223
2010-02-03 16:38:03 +00:00
Anders Carlsson 5dc86337fb Set the correct vtable pointers _before_ generating code for any member initializers. Fixes about ~2000 clang/LLVM tests in the clang-on-clang build.
llvm-svn: 95116
2010-02-02 19:58:43 +00:00
Eli Friedman 604179775a Simplify EmitMemberInitializer; no intended functionality change.
llvm-svn: 94965
2010-01-31 19:07:50 +00:00
Douglas Gregor 7ae2d7758f Rework base and member initialization in constructors, with several
(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.

llvm-svn: 94952
2010-01-31 09:12:51 +00:00
Anders Carlsson 6276b2506d When performing a derived-to-base cast that we know will not change the offset, we don't need to null check the input pointer. Fixes PR5965.
llvm-svn: 94942
2010-01-31 02:39:02 +00:00
Anders Carlsson 600f737b95 When doing a base-to-derived cast we don't need to null check the derived value if the class offset is 0.
llvm-svn: 94939
2010-01-31 01:43:37 +00:00
Anders Carlsson 84673e200f Some class related cleanup.
llvm-svn: 94938
2010-01-31 01:36:53 +00:00
Anders Carlsson 42c876dff2 Use EmitLValueForFieldInitialization when synthesizing the copy ctor as well.
llvm-svn: 94800
2010-01-29 05:41:25 +00:00
Anders Carlsson db78f0ad04 Add a new EmitLValueForFieldInitialization that will be used for initializing fields (and reference type fields in particular).
llvm-svn: 94799
2010-01-29 05:24:29 +00:00
Anders Carlsson 5d8645b150 Simplify EmitLValueForField - we can get whether the field is part of a union or not from the FieldDecl (through its DeclContext).
llvm-svn: 94798
2010-01-29 05:05:36 +00:00
Eli Friedman cab014721b Fix a couple bugs in copy assignment operator synthesis.
llvm-svn: 93546
2010-01-15 20:06:11 +00:00
Anders Carlsson 93a1884fde Move address points to CGVtableInfo, no functionality change.
llvm-svn: 92420
2010-01-02 18:02:32 +00:00
Anders Carlsson e36a6b3e44 Correctly pass VTT parameters to constructors and destructors. The VTTs aren't yet used in the ctors/dtors, but that will follow.
llvm-svn: 92409
2010-01-02 01:01:18 +00:00
Anders Carlsson 27da15ba8e Move a few more functions away from CGCXX and to CGClass and CGExprCXX.
llvm-svn: 92399
2010-01-01 20:29:01 +00:00
Anders Carlsson fb404888af Move a bunch of class related functions to CGClass.cpp, no functionality change.
llvm-svn: 92148
2009-12-24 22:46:43 +00:00
Anders Carlsson 5f91fd64b6 Add CodeGenModule::ComputeThunkAdjustment, which Eli wrote.
llvm-svn: 90401
2009-12-03 03:06:55 +00:00
Eli Friedman c9e3e6ff29 Tests now pass with the assertion.
llvm-svn: 90026
2009-11-28 03:35:45 +00:00
Eli Friedman 78910a508a Add a much more thorough test of casts to virtual bases, and fix
GetCXXBaseClassOffset to actually pass the test.

llvm-svn: 90025
2009-11-28 03:31:34 +00:00
Anders Carlsson 59486a2ddb Get rid of the ugly CGCXX names and replace them with CGClass, CGExprCXX and CGTemporaries.
llvm-svn: 89742
2009-11-24 05:51:11 +00:00