Commit Graph

31 Commits

Author SHA1 Message Date
John McCall f256eb54a2 Fix some obvious bugs in the conditional-cleanup code and then make the
dtor cleanup use it.

llvm-svn: 124309
2011-01-26 19:15:39 +00:00
John McCall 5b26f65b3d Reset the lifetime-managed flag between emission of the agg conditional
branches.  Fixes PR8623.

llvm-svn: 119408
2010-11-17 00:07:33 +00:00
John McCall 8ea46b6654 Fix a bug with binding l-values to elided temporaries, and leave a couple
helpful asserts behind.

llvm-svn: 114250
2010-09-18 00:58:34 +00:00
John McCall f4ee1ddfa2 Right, there are *two* cases of pr-value class-type expressions that don't
derive from temporaries of the same type.  Black-list member expressions
as well.

llvm-svn: 114071
2010-09-16 06:57:56 +00:00
John McCall 5a948500c5 Test hardening.
llvm-svn: 113963
2010-09-15 10:38:11 +00:00
John McCall 7a626f63f7 one piece of code is responsible for the lifetime of every aggregate
slot.  The easiest way to do that was to bundle up the information
we care about for aggregate slots into a new structure which demands
that its creators at least consider the question.

I could probably be convinced that the ObjC 'needs GC' bit should
be rolled into this structure.
Implement generalized copy elision.  The main obstacle here is that
IR-generation must be much more careful about making sure that exactly

llvm-svn: 113962
2010-09-15 10:14:12 +00:00
Douglas Gregor 747eb7840a Reinstate the fix for PR7556. A silly use of isTrivial() was
suppressing copies of objects with trivial copy constructors.

llvm-svn: 107857
2010-07-08 06:14:04 +00:00
Douglas Gregor e182370eda Revert r107828 and r107827, the fix for PR7556, which seems to be
breaking bootstrap on Linux.

llvm-svn: 107837
2010-07-07 23:37:33 +00:00
Douglas Gregor 442612c285 Do not use CXXZeroValueInitExpr for class types. Instead, use
CXXConstructExpr/CXXTemporaryObjectExpr/CXXNewExpr as
appropriate. Fixes PR7556, and provides a slide codegen improvement
when copy-initializing a POD class type from a value-initialized
temporary. Previously, we weren't eliding the copy.

llvm-svn: 107827
2010-07-07 22:35:13 +00:00
Douglas Gregor 9094fcb7c1 Tweak test for destruction of copied temporary objects
llvm-svn: 102291
2010-04-25 00:56:07 +00:00
Douglas Gregor d0ace02496 When copying a temporary object to initialize an entity for which the
temporary needs to be bound, bind the copy object. Otherwise, we won't
end up calling the destructor for the copy. Fixes Boost.Optional.

llvm-svn: 102290
2010-04-25 00:55:24 +00:00
Rafael Espindola 46b7987f85 Fix PR6648 by not creating a temporary with the type of a
CXXExprWithTemporaries.

Not emitting the expression as an aggregate might be the right thing to do,
but is orthogonal. Emitting it as an scalar expression will still try to
create a temporary for the incomplete type of the CXXExprWithTemporaries and
fail.

llvm-svn: 99134
2010-03-21 17:11:05 +00:00
Douglas Gregor b14d123774 Give explicit template instantiations weak ODR linkage. Former
iterations of this patch gave explicit template instantiation
link-once ODR linkage, which permitted the back end to eliminate
unused symbols. Weak ODR linkage still requires the symbols to be
generated.

llvm-svn: 98441
2010-03-13 18:23:07 +00:00
Douglas Gregor 17b76185f1 Re-revert the explicit template instantiation linkage patch. I am beginning to look incompetent
llvm-svn: 98425
2010-03-13 03:49:57 +00:00
Douglas Gregor 89cae0f224 Reinstate patch to turn explicit template instantiations into weak symbols
llvm-svn: 98424
2010-03-13 03:14:19 +00:00
Douglas Gregor 539bc40906 Revert the linkage change for explicit template instantiations; something is amiss
llvm-svn: 98332
2010-03-12 05:13:59 +00:00
Douglas Gregor ee3f72299c Give explicit template instantiations weak linkage (but don't defer
them). Fixes PR6578.

llvm-svn: 98328
2010-03-12 04:49:06 +00:00
Anders Carlsson 824e0613de When binding an lvalue to a reference, we always need to pop temporaries.
With this fix, and the other fixes committed today a make check-all with a clang-built LLVM now gives:

Expected Passes    : 6933
Expected Failures  : 46
Unsupported Tests  : 40
Unexpected Failures: 27

which means that we pass 99.96% of all tests :) The resulting 27 tests are all LLVMC tests and seem to be because of differences in the clang and gcc drivers.

llvm-svn: 95313
2010-02-04 17:32:58 +00:00
Anders Carlsson 75b1f959da Check in a test case and a nasty workaround for PR6199.
llvm-svn: 95076
2010-02-02 07:10:35 +00:00
Douglas Gregor 363b151ff7 When transforming CXXExprWithTemporaries and CXXBindTemporaryExpr
expressions (e.g., for template instantiation), just transform the
subexpressions and return those, since the temporary-related nodes
will be implicitly regenerated. Fixes PR5867, but I said that
before...

llvm-svn: 92135
2009-12-24 18:51:59 +00:00
Douglas Gregor f82bead3fd InitializationSequence handles binding to temporaries, so that
argument-passing doesn't have to. Fixes PR5867, where we were binding
a temporary twice in the AST and, therefore, calling its destructor
twice.

llvm-svn: 92131
2009-12-24 17:16:46 +00:00
Douglas Gregor e1314a64b8 Switch the initialization required by return statements over to the
new InitializationSequence. This fixes some bugs (e.g., PR5808),
changed some diagnostics, and caused more churn than expected. What's
new:

  - InitializationSequence now has a "C conversion sequence" category
    and step kind, which falls back to
  - Changed the diagnostics for returns to always have the result type
    of the function first and the type of the expression second.
    CheckSingleAssignmentConstraints to peform checking in C. 
  - Improved ASTs for initialization of return values. The ASTs now
    capture all of the temporaries we need to create, but
    intentionally do not bind the tempoary that is actually returned,
    so that it won't get destroyed twice.
  - Make sure to perform an (elidable!) copy of the class object that
    is returned from a class.
  - Fix copy elision in CodeGen to properly see through the
    subexpressions that occur with elidable copies.
  - Give "new" its own entity kind; as with return values and thrown
    objects, we don't bind the expression so we don't call a
    destructor for it.

Note that, with this patch, I've broken returning move-only types in
C++0x. We'll fix it later, when we tackle NRVO.

llvm-svn: 91669
2009-12-18 05:02:21 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Anders Carlsson 97df0b40c3 Don't bind arguments to temporaries if the argument has a reference type.
llvm-svn: 88662
2009-11-13 17:04:35 +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
Anders Carlsson 421a5c9651 If a member variable of reference type is bound to a temporary in its member initializer it needs to be destroyed at the end of the constructor.
llvm-svn: 86230
2009-11-06 04:19:02 +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
Benjamin Kramer 170a56f135 Add missing colons for FileCheck.
llvm-svn: 85683
2009-10-31 20:42:26 +00:00
Anders Carlsson 8f741bfad7 When building a cast argument, make sure to bind the result to a temporary.
llvm-svn: 84448
2009-10-18 21:20:14 +00:00
Anders Carlsson 63404d2861 Convert temporaries.cpp to using FileCheck.
llvm-svn: 84446
2009-10-18 21:11:11 +00:00
Anders Carlsson 3af1ba73b3 Rename temp-1.cpp to temporaries.cpp.
llvm-svn: 84443
2009-10-18 20:58:38 +00:00