Commit Graph

318 Commits

Author SHA1 Message Date
Eli Friedman 551fe84d0e Minor cleanup.
llvm-svn: 90411
2009-12-03 04:27:05 +00:00
Mike Stump e2d4a2c3a8 Add support for thunking dtors. Oh why does this make my head hurt?
llvm-svn: 90409
2009-12-03 03:47:56 +00:00
Fariborz Jahanian 037bcb5be3 Added an assert.
llvm-svn: 90285
2009-12-01 23:35:33 +00:00
Fariborz Jahanian be64149749 More support for virtual destructor calls.
Fixes pr5619

llvm-svn: 90158
2009-11-30 22:07:18 +00:00
Daniel Dunbar dacbe6bdcd Don't pass false (default) for isVolatile parameter to CreateStore.
llvm-svn: 90094
2009-11-29 21:11:41 +00:00
Anders Carlsson f942ee0297 Don't build the entire vtable when all we want is the index of a virtual method.
llvm-svn: 90017
2009-11-27 20:47:55 +00:00
Eli Friedman 250534cf9a Fix for PR5594: use EmitGlobalDefinition instead of EmitCXXDestructor so that
we check whether the vtable needs to be generated.

llvm-svn: 89984
2009-11-27 01:42:12 +00:00
Eli Friedman 4907c6f2ed Remove unused variable.
llvm-svn: 89945
2009-11-26 07:48:44 +00:00
Eli Friedman ffc066f4b9 Shortcut explicit calls to a trivial copy assignment operator.
llvm-svn: 89944
2009-11-26 07:45:48 +00:00
Eli Friedman 84a7e347bf Simplify and fix up the handling of implicit constructors, copy assignment
operators, and destructors.  Avoids generating declarations/definitions of
trivial constructors/destructors, and makes sure the trivial copy assignment
operator is generated when necessary.

llvm-svn: 89943
2009-11-26 07:40:08 +00:00
Anders Carlsson 2f87c4f1a5 Add a CovariantThunkAdjustment struct that represents the adjustments needed for a covariant thunk.
llvm-svn: 89933
2009-11-26 03:09:37 +00:00
Anders Carlsson abe274a8b0 Move the mangler into the CodeGen namespace. Change mangleThunk to take a ThunkAdjustment.
llvm-svn: 89930
2009-11-26 02:49:32 +00:00
Anders Carlsson c778540f9a Add a ThunkAdjustment struct which holds a non-virtual and a virtual adjustment offset. Start using it. General cleanup in Mangle.cpp.
llvm-svn: 89925
2009-11-26 02:32:05 +00:00
Anders Carlsson 82ba57c8f0 Add VTT parameter to base ctors/dtors with virtual bases. (They aren't used yet).
llvm-svn: 89835
2009-11-25 03:15:49 +00:00
Anders Carlsson 3c9beab48a Handle references correctly when synthesizing copy constructors.
With this change, the clang-on-clang test result is now

Expected Passes    : 224
Unexpected Failures: 37

Which means that we can compile over 80% of clang with clang! :)

llvm-svn: 89799
2009-11-24 21:08:10 +00:00
Anders Carlsson 3a202f601e Handle cases where we're constructing an array of objects and the constructor has default arguments.
llvm-svn: 89783
2009-11-24 18:43:52 +00:00
Anders Carlsson 8c793172c2 Handle base-to-derived casts. Will land test case shortly.
llvm-svn: 89678
2009-11-23 17:57:54 +00:00
Daniel Dunbar e128dd18ab IRgen: Switch the C++ mangler interfaces to take the SmallVector to write into,
instead of requiring clients to make a raw_svector_ostream, which is just an
implementation detail.

llvm-svn: 89548
2009-11-21 09:06:22 +00:00
Daniel Dunbar ef5d75afeb Sink free mangle* methods into MangleContext.
llvm-svn: 89547
2009-11-21 09:06:10 +00:00
Mike Stump 58ef18b38c Checkpoint current work. WIP.
llvm-svn: 89513
2009-11-20 23:44:51 +00:00
Mike Stump ea950e249f Reflow to fit 80-col.
llvm-svn: 89222
2009-11-18 18:57:56 +00:00
Eli Friedman fe81e3fb3c Refactor emitting call to delete operator into common function EmitDeleteCall.
llvm-svn: 89173
2009-11-18 00:50:08 +00:00
Anders Carlsson dee9a30204 Unify the way destructor epilogues are generated for synthesized and regular destructors. Also fix PR5529.
llvm-svn: 89034
2009-11-17 04:44:12 +00:00
Eli Friedman e85ef718d5 Fix up EmitMemberInitializer to handle many more cases.
llvm-svn: 88999
2009-11-16 23:53:01 +00:00
Eli Friedman 5e7d969526 Reorganize EmitMemberInitializer to put anonymous unions on the common codepath.
llvm-svn: 88995
2009-11-16 23:34:11 +00:00
Eli Friedman c1daba3ec8 Make member initializers for union members work correctly.
llvm-svn: 88989
2009-11-16 22:58:01 +00:00
Eli Friedman c2ef215bda Implement a few more cases for copy constructor synthesis.
llvm-svn: 88971
2009-11-16 21:47:41 +00:00
Eli Friedman e6ce354795 Fix a couple of cases where we weren't generating the right kind of call
for a call to a virtual function.

llvm-svn: 88891
2009-11-16 05:31:29 +00:00
Anders Carlsson d787204e6d When generating the deleting ctor, emit a call to delete.
llvm-svn: 88878
2009-11-15 23:03:25 +00:00
Eli Friedman b572c92674 PR5483: Generate missing form of destructor when it is virtual. (Someone
more familiar with this stuff should double-check that there isn't some more
general rule; this is purely from inspecting g++ output.)

llvm-svn: 88755
2009-11-14 04:19:37 +00:00
Fariborz Jahanian ebea005812 Code gen. For virtual destructor call on array objects
(still part of pr5472).

llvm-svn: 88712
2009-11-13 22:29:45 +00:00
Fariborz Jahanian 6814eaa2cc Code gen for arrady delete operator. Fixes pr5472.
llvm-svn: 88680
2009-11-13 19:27:47 +00:00
Anders Carlsson fb4dda4fed Instead of storing CXXMethodDecls in the vtable builder, store GlobalDecls so we can represent both the complete and deleting destructors. Also, when encountering a destructor decl, emit entries for both the complete and deleting destructors. Mike, please review.
With this change, FileCheck builds and runs the clang test suite without failures!

llvm-svn: 88663
2009-11-13 17:08:56 +00:00
Anders Carlsson e828c36933 Add a special BuildVirtualCall that's going to be used for building calls to destructors. This is needed because when compiling:
struct A {
	virtual ~A();
};

void f(A* a) {
	delete a;
}

A's deleting destructor should be called.

llvm-svn: 87083
2009-11-13 04:45:41 +00:00
Anders Carlsson 78cfaa9e56 Fix two bugs with temporaries:
1. For 

A f() {
	return A();
}

we were incorrectly calling the A destructor on the returned object.

2. For

void f(A);
void g() {
	A a;
	f(a);
}

we were incorrectly not calling the copy constructor.

llvm-svn: 87082
2009-11-13 04:34:45 +00:00
Fariborz Jahanian 03f62ed9bb Value initialize non-class array members in ctor's
initializer list. Fixes PR5463.

llvm-svn: 86849
2009-11-11 17:55:25 +00:00
Fariborz Jahanian e6c8112572 Avoid generating additional destructor(s) for initialized constructed
objects.

llvm-svn: 86778
2009-11-11 01:13:34 +00:00
Fariborz Jahanian 1254a0978c This patch implements Code gen. for destruction of
global array of objects.

llvm-svn: 86701
2009-11-10 19:24:06 +00:00
Mike Stump d846d0825b Add vtable caching to prevent multiple vtables for the same class from
being generated.

Add the most derived vtable pointer to the VTT.

llvm-svn: 86671
2009-11-10 07:44:33 +00:00
Eli Friedman d7686ef31c Unify the codepaths used to verify base and member initializers for explicitly
and implicitly defined constructors.  This has a number of benefits:

1. Less code.

2. Explicit and implicit constructors get the same diagnostics.

3. The AST explicitly contains constructor calls from implicit default
constructors.  This allows handing some cases that previously weren't handled
correctly in IRGen without any additional code. Specifically, implicit default
constructors containing calls to constructors with default arguments are now
handled correctly.

llvm-svn: 86500
2009-11-09 01:05:47 +00:00
Fariborz Jahanian c2d71b531c This patch fixes code gen. part of pr5333 (Conversion
using elipsis conversion).

llvm-svn: 86276
2009-11-06 18:47:57 +00:00
Anders Carlsson 5852b13827 If a member initializer create temporaries we need to destroy them. Fixes PR5077.
llvm-svn: 86225
2009-11-06 04:11:09 +00:00
Anders Carlsson a7cb98b202 More cleanup.
llvm-svn: 86224
2009-11-06 03:23:06 +00:00
Mike Stump c550768a11 References can't be zero; omit zero check for return value adjustments
in covariant thunks that return references.

llvm-svn: 86121
2009-11-05 06:32:02 +00:00
Mike Stump b8da7a046d Refine covariant return value adjustments for thunks when null
pointers are returned.

llvm-svn: 86120
2009-11-05 06:12:26 +00:00
Fariborz Jahanian 18bc195473 Add code gen for pointer-to-member function in
ctor's initializer. Fixes pr5178.

llvm-svn: 86040
2009-11-04 19:13:37 +00:00
Douglas Gregor 615ac67fb8 Store the unresolved class type in MemberPointerType's Class field,
from Peter Collingbourne!

llvm-svn: 86030
2009-11-04 16:49:01 +00:00
Mike Stump b9c9b351e9 Fix 80-col violations.
llvm-svn: 85990
2009-11-04 01:11:15 +00:00
Mike Stump 71609a2874 Split out return adjustments in thunks from this adjustment in thunks
so the optimizer can tailcall into the return value adjustment thunk.
This improves codesize for complex hierarchies.

llvm-svn: 85988
2009-11-04 00:53:51 +00:00
Mike Stump 8117848174 Misc cleanups.
llvm-svn: 85978
2009-11-03 23:50:34 +00:00
Mike Stump 53f9ded62b Refine volatile handling, specifically, we must have the canonical
type to look at the volatile specifier.  I found these all from just
hand auditing the code.

llvm-svn: 85967
2009-11-03 23:25:48 +00:00
Mike Stump 77738205e6 Refine return value adjustments for thunks.
llvm-svn: 85905
2009-11-03 16:59:27 +00:00
Mike Stump 92e5f8cb39 Refine codegen for non-virtual this adjustments for thunks.
llvm-svn: 85856
2009-11-03 03:16:46 +00:00
Mike Stump f358972fdc Add virtual adjustments for this for thunks.
llvm-svn: 85852
2009-11-03 02:12:59 +00:00
Mike Stump 31e1d43729 Add basic codegen for thunks that return values.
llvm-svn: 85842
2009-11-02 23:47:45 +00:00
Mike Stump 33ccd9e354 Refine codegen for thunks.
llvm-svn: 85839
2009-11-02 23:22:01 +00:00
Fariborz Jahanian 29baa2b1ba Minor cleanup.
llvm-svn: 85434
2009-10-28 21:07:28 +00:00
Fariborz Jahanian f1639fffbc Code gen for array construction - WIP
llvm-svn: 85432
2009-10-28 20:55:41 +00:00
Fariborz Jahanian e4d94cee05 Code-gen for CXXZeroInitValueExpr AST passed
as argument to a function call. Removes a FIXME.

llvm-svn: 84694
2009-10-20 23:29:04 +00:00
Fariborz Jahanian da21efb566 Implement derived-to-base AST/code gen. There is a
FIXME in CGCXX.cpp that I would like Anders to
take a look at.

llvm-svn: 84265
2009-10-16 19:20:59 +00:00
Anders Carlsson 6bfee8f3e3 Don't assume that the LHS and RHS of a member pointer expression is a DeclRefExpr. Fixes PR5177.
llvm-svn: 83986
2009-10-13 17:41:28 +00:00
Anders Carlsson a1b54fdbe1 Even more devirtualization cleverness.
llvm-svn: 83886
2009-10-12 19:59:15 +00:00
Anders Carlsson 2a01709204 More devirtualization improvements.
llvm-svn: 83883
2009-10-12 19:51:33 +00:00
Anders Carlsson b61301f353 Devirtualize calls on temporaries. A().f() for example.
llvm-svn: 83882
2009-10-12 19:45:47 +00:00
Anders Carlsson d7432dfb0a Factor out devirtualization checking into a separate function and make it handle references correctly.
llvm-svn: 83880
2009-10-12 19:41:04 +00:00
Anders Carlsson b5296558f1 If the base type of a member call is a record type we don't need to emit a virtual call.
llvm-svn: 83816
2009-10-11 23:55:52 +00:00
Anders Carlsson 2bb27f53e0 Move the vtable builder to CGVtable.cpp, general cleanup.
llvm-svn: 83798
2009-10-11 22:13:54 +00:00
Anders Carlsson 2295f31810 Change mangleCXXVtable and mangleCXXRtti to take CXXRecordDecls instead of QualTypes.
llvm-svn: 83793
2009-10-11 21:24:51 +00:00
Anders Carlsson 6ce51fdf43 Move our (non-existing) RTTI emission code into CGRtti.cpp. No functionality change.
llvm-svn: 83732
2009-10-10 20:49:04 +00:00
Mike Stump 0d479e6653 Avoid warning.
llvm-svn: 83609
2009-10-09 01:25:47 +00:00
Anders Carlsson ff971e8bf4 Add a MangleContext and pass it to all mangle functions. It will be used for keeping state, such as identifiers assigned to anonymous structs as well as scope encoding.
llvm-svn: 83442
2009-10-07 01:06:45 +00:00
Anders Carlsson b703fd2216 Uncomment some commented out code.
llvm-svn: 83428
2009-10-06 23:02:00 +00:00
Anders Carlsson c6d171ec77 Change GetAddressCXXOfBaseClass to use CXXBasePaths for calculating base class offsets. Fix the code to handle virtual bases as well.
llvm-svn: 83426
2009-10-06 22:43:30 +00:00
Anders Carlsson 80ef6f1a46 Pass the right type to GetAddrOfFunction when getting functions for the VTable. Fixes PR5021.
llvm-svn: 83395
2009-10-06 17:54:23 +00:00
Anders Carlsson 2ee3c011d9 Implement code generation of member function pointer calls. Fixes PR5121.
llvm-svn: 83271
2009-10-03 19:43:08 +00:00
Anders Carlsson 32bfb1ce8f Move some functions from CodeGenFunctions to CodeGenModule so they can be used by CGExprConstant.
llvm-svn: 83263
2009-10-03 14:56:57 +00:00
Anders Carlsson 8f4fd60c47 Handle CXXMemberCallExprs that point to a static method. Fixes PR5093.
llvm-svn: 83045
2009-09-29 03:54:11 +00:00
Mike Stump e7a2b48572 Fix http://llvm.org/PR5090.
llvm-svn: 83035
2009-09-29 00:50:50 +00:00
Anders Carlsson 52d78a518a CodeGen for try statements. (We just emit the body for now).
llvm-svn: 82910
2009-09-27 18:58:34 +00:00
John McCall 8ccfcb51ee Refactor the representation of qualifiers to bring ExtQualType out of the
Type hierarchy.  Demote 'volatile' to extended-qualifier status.  Audit our
use of qualifiers and fix a few places that weren't dealing with qualifiers
quite right;  many more remain.

llvm-svn: 82705
2009-09-24 19:53:00 +00:00
Anders Carlsson d49844b715 Add a new variant of EmitCXXAggrConstructorCall that takes a Value that holds the number of elements to construct, to be used when implementing new[].
llvm-svn: 82602
2009-09-23 02:45:36 +00:00
Anders Carlsson cc52f65500 Move codegen of new and delete to CGCXXExpr.cpp
llvm-svn: 82585
2009-09-22 22:53:17 +00:00
John McCall 9dd450bb78 Change all the Type::getAsFoo() methods to specializations of Type::getAs().
Several of the existing methods were identical to their respective
specializations, and so have been removed entirely.  Several more 'leaf'
optimizations were introduced.

The getAsFoo() methods which imposed extra conditions, like
getAsObjCInterfacePointerType(), have been left in place.

llvm-svn: 82501
2009-09-21 23:43:11 +00:00
Mike Stump f9c95be2f6 Generate more of the vbase virtual offset for covariant thunks. WIP.
llvm-svn: 82253
2009-09-18 19:06:35 +00:00
Anders Carlsson ddf57d3df9 Remove an unnecessary FunctionDecl parameter to the synthesizing functions.
llvm-svn: 81759
2009-09-14 05:32:02 +00:00
Anders Carlsson 8783737029 Handle delete where the class has a virtual destructor.
llvm-svn: 81733
2009-09-14 00:16:25 +00:00
Anders Carlsson 864d525533 Rename AddressCXXOfBaseClass to GetAddressCXXOfBaseClass. Add a NullCheckValue argument (currently unused).
llvm-svn: 81606
2009-09-12 04:26:35 +00:00
Anders Carlsson 307408d2af Add CGCXXClass.cpp. and move CodeGenFunction::AddressCXXOfBaseClass there.
llvm-svn: 81604
2009-09-12 03:29:09 +00:00
Anders Carlsson 97c7eda14a Fix a crash when generating vtables that contain destructors.
llvm-svn: 81587
2009-09-12 00:00:29 +00:00
Mike Stump 80f6ac5a4f Add basic covariant thunk generation support. WIP.
llvm-svn: 81585
2009-09-11 23:25:56 +00:00
Anders Carlsson 73fcc95f0f Pass GlobalDecls to GenerateCode and StartFunction.
llvm-svn: 81485
2009-09-11 00:07:24 +00:00
Anders Carlsson ecf9bf0158 GlobalDecl doesn't have an explicit constructor anymore.
llvm-svn: 81481
2009-09-10 23:43:36 +00:00
Anders Carlsson 1ca52689e7 Use the right GlobalDecl type for destructors.
llvm-svn: 81398
2009-09-09 23:17:18 +00:00
Anders Carlsson e9766d559b If a cast expression needs either a conversion function or a constructor to be called, generate implicit child expressions that call them.
llvm-svn: 81383
2009-09-09 21:33:21 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Mike Stump e73d5ca9a8 Refine vcall offsets. Cleanups. WIP.
llvm-svn: 81143
2009-09-07 04:27:52 +00:00
Mike Stump b82db12b35 Refine overrides and thunks for virtual bases. Cleanups. WIP.
llvm-svn: 81080
2009-09-05 11:28:33 +00:00
Mike Stump c9eb1727db Cleanup.
llvm-svn: 81078
2009-09-05 09:24:43 +00:00
Mike Stump 69bbd6ce84 Cleanups.
llvm-svn: 81077
2009-09-05 09:10:58 +00:00
Mike Stump 6363021ab9 Cleanups.
llvm-svn: 81075
2009-09-05 08:47:24 +00:00