summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/temporaries.cpp
Commit message (Collapse)AuthorAgeFilesLines
* PR42220: take into account the possibility of aggregates with baseRichard Smith2019-06-121-0/+18
| | | | | | classes when checking an InitListExpr for lifetime extension. llvm-svn: 363188
* Revert "[CodeGenCXX] Treat 'this' as noalias in constructors"Sean Fertile2018-10-151-23/+23
| | | | | | | This reverts commit https://reviews.llvm.org/rL344150 which causes MachineOutliner related failures on the ppc64le multistage buildbot. llvm-svn: 344526
* [CodeGenCXX] Treat 'this' as noalias in constructorsAnton Bikineev2018-10-101-23/+23
| | | | | | | | | This is currently a clang extension and a resolution of the defect report in the C++ Standard. Differential Revision: https://reviews.llvm.org/D46441 llvm-svn: 344150
* Support lifetime-extension of conditional temporaries.Richard Smith2018-07-231-3/+95
| | | | llvm-svn: 337767
* [clang]: Add support for "-fno-delete-null-pointer-checks"Manoj Gupta2018-07-191-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Support for this option is needed for building Linux kernel. This is a very frequently requested feature by kernel developers. More details : https://lkml.org/lkml/2018/4/4/601 GCC option description for -fdelete-null-pointer-checks: This Assume that programs cannot safely dereference null pointers, and that no code or data element resides at address zero. -fno-delete-null-pointer-checks is the inverse of this implying that null pointer dereferencing is not undefined. This feature is implemented in as the function attribute "null-pointer-is-valid"="true". This CL only adds the attribute on the function. It also strips "nonnull" attributes from function arguments but keeps the related warnings unchanged. Corresponding LLVM change rL336613 already updated the optimizations to not treat null pointer dereferencing as undefined if the attribute is present. Reviewers: t.p.northover, efriedma, jyknight, chandlerc, rnk, srhines, void, george.burgess.iv Reviewed By: jyknight Subscribers: drinkcat, xbolva00, cfe-commits Differential Revision: https://reviews.llvm.org/D47894 llvm-svn: 337433
* Restructure checking for, and warning on, lifetime extension.Richard Smith2018-07-171-27/+0
| | | | | | | | | | | | | This change implements C++ DR1696, which makes initialization of a reference member of a class from a temporary object ill-formed. The standard wording here is imprecise, but we interpret it as meaning that any time a mem-initializer would result in lifetime extension, the program is ill-formed. This reinstates r337226, reverted in r337255, with a fix for the InitializedEntity alignment problem that was breaking ARM buildbots. llvm-svn: 337329
* Temporarily revert r337226 "Restructure checking for, and warning on, ↵Florian Hahn2018-07-171-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | lifetime extension." This change breaks on ARM because pointers to clang::InitializedEntity are only 4 byte aligned and do not have 3 bits to store values. A possible solution would be to change the fields in clang::InitializedEntity to enforce a bigger alignment requirement. The error message is llvm/include/llvm/ADT/PointerIntPair.h:132:3: error: static_assert failed "PointerIntPair with integer size too large for pointer" static_assert(IntBits <= PtrTraits::NumLowBitsAvailable, include/llvm/ADT/PointerIntPair.h:73:13: note: in instantiation of template class 'llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> >' requested here Value = Info::updateInt(Info::updatePointer(0, PtrVal), llvm/include/llvm/ADT/PointerIntPair.h:51:5: note: in instantiation of member function 'llvm::PointerIntPair<const clang::InitializedEntity *, 3, (anonymous namespace)::LifetimeKind, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *>, llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> > >::setPointerAndInt' requested here setPointerAndInt(PtrVal, IntVal); ^ llvm/tools/clang/lib/Sema/SemaInit.cpp:6237:12: note: in instantiation of member function 'llvm::PointerIntPair<const clang::InitializedEntity *, 3, (anonymous namespace)::LifetimeKind, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *>, llvm::PointerIntPairInfo<const clang::InitializedEntity *, 3, llvm::PointerLikeTypeTraits<const clang::InitializedEntity *> > >::PointerIntPair' requested here return {Entity, LK_Extended}; Full log here: http://lab.llvm.org:8011/builders/clang-cmake-armv7-global-isel/builds/1330 http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/1394 llvm-svn: 337255
* Restructure checking for, and warning on, lifetime extension.Richard Smith2018-07-171-27/+0
| | | | | | | | | | This change implements C++ DR1696, which makes initialization of a reference member of a class from a temporary object ill-formed. The standard wording here is imprecise, but we interpret it as meaning that any time a mem-initializer would result in lifetime extension, the program is ill-formed. llvm-svn: 337226
* DR1213: element access on an array xvalue or prvalue produces an xvalue. In theRichard Smith2016-12-051-0/+30
| | | | | | | | | | | | | | latter case, a temporary array object is materialized, and can be lifetime-extended by binding a reference to the member access. Likewise, in an array-to-pointer decay, an rvalue array is materialized before being converted into a pointer. This caused IR generation to stop treating file-scope array compound literals as having static storage duration in some cases in C++; that has been rectified by modeling such a compound literal as an lvalue. This also improves clang's compatibility with GCC for those cases. llvm-svn: 288654
* Update Clang tests to handle explicitly typed load changes in LLVM.David Blaikie2015-02-271-3/+3
| | | | llvm-svn: 230795
* Update Clang tests to handle explicitly typed gep changes in LLVM.David Blaikie2015-02-271-11/+11
| | | | llvm-svn: 230783
* CodeGen: static constexpr data members should have a linkonce_odr initDavid Majnemer2015-02-191-8/+8
| | | | | | | | | Classes can be defined in multiple translation units. This means that the static constexpr data members should have identical initializers in all translation units. Implement this by giving the reference temporary linkonce_odr linkage. llvm-svn: 229900
* Fix temporary lifetime extension from an initializer using braced "functional"Richard Smith2015-01-101-0/+7
| | | | | | cast notation T{...} when T is a reference type. llvm-svn: 225571
* Mark C++ reference parameters as dereferenceableHal Finkel2014-07-181-9/+9
| | | | | | | | | | | | | | Because references must be initialized using some evaluated expression, they must point to something, and a callee can assume the reference parameter is dereferenceable. Taking advantage of a new attribute just added to LLVM, mark them as such. Because dereferenceability in addrspace(0) implies nonnull in the backend, we don't need both attributes. However, we need to know the size of the object to use the dereferenceable attribute, so for incomplete types we still emit only nonnull. llvm-svn: 213386
* PR20227: materialize a temporary when dynamic_casting a class prvalue to aRichard Smith2014-07-081-0/+15
| | | | | | reference type. llvm-svn: 212551
* Add 'nonnull' parameter or return attribute when producing an llvm pointer ↵Nick Lewycky2014-05-281-10/+10
| | | | | | type in a function type where the C++ type is a reference. Update the tests. llvm-svn: 209723
* AST: Update reference temporary manglingDavid Majnemer2014-05-061-26/+26
| | | | | | | | | | | | | | | Summary: Update our mangling to match the discussion on cxx-abi-dev. This involves using a seq-id instead of an optional number. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3631 llvm-svn: 208140
* CHECK-LABEL-ify some code gen tests to improve diagnostic experience when ↵Stephen Lin2013-08-151-12/+12
| | | | | | tests fail. llvm-svn: 188447
* Testcase for PR14130, which was probably fixed by r183859.Richard Smith2013-07-041-0/+8
| | | | llvm-svn: 185613
* PR16263: Implement current direction of core issue 1376. Binding a reference toRichard Smith2013-06-151-0/+28
| | | | | | | | | | | the result of a cast-to-reference-type lifetime-extends the object to which the reference inside the cast binds. This requires us to look for subobject adjustments on both the inside and the outside of the MaterializeTemporaryExpr when looking for a temporary to lifetime-extend (which we also need for core issue 616, and possibly 1213). llvm-svn: 184024
* Reapply r183721, reverted in r183776, with a fix for a bug in the former (weRichard Smith2013-06-121-7/+110
| | | | | | | | | | | | | | | | | | | | | | | were lacking ExprWithCleanups nodes in some cases where the new approach to lifetime extension needed them). Original commit message: Rework IR emission for lifetime-extended temporaries. Instead of trying to walk into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183859
* Revert r183721. It caused cleanups to be delayed too long in some cases.Richard Smith2013-06-111-81/+7
| | | | | | Testcase to follow. llvm-svn: 183776
* Rework IR emission for lifetime-extended temporaries. Instead of trying to walkRichard Smith2013-06-111-7/+81
| | | | | | | | | | | | | | | | | into the expression and dig out a single lifetime-extended entity and manually pull its cleanup outside the expression, instead keep a list of the cleanups which we'll need to emit when we get to the end of the full-expression. Also emit those cleanups early, as EH-only cleanups, to cover the case that the full-expression does not terminate normally. This allows IR generation to properly model temporary lifetime when multiple temporaries are extended by the same declaration. We have a pre-existing bug where an exception thrown from a temporary's destructor does not clean up lifetime-extended temporaries created in the same expression and extended to automatic storage duration; that is not fixed by this patch. llvm-svn: 183721
* Remove some unreachable (and wrong) code and replace it with an assertion.Richard Smith2013-06-041-0/+22
| | | | llvm-svn: 183206
* Convert some Unicode whitespace to ASCII whitespace.Richard Smith2013-06-031-4/+4
| | | | llvm-svn: 183116
* Do not walk through member-accesses on bitfields when looking for the objectRichard Smith2013-06-031-0/+12
| | | | | | | | which is lifetime-extended by a reference binding. An additional temporary is created for such a bitfield access (although we have no explicit AST representation for it). llvm-svn: 183095
* Fix handling of pointers-to-members and comma expressions whenRichard Smith2013-06-031-1/+47
| | | | | | lifetime-extending temporaries in reference bindings. llvm-svn: 183089
* Update the tests.Bill Wendling2013-01-311-3/+3
| | | | | | | This update coincides with r174110. That change ordered the attributes alphabetically. llvm-svn: 174111
* Modify the tests for the (sorted) order that the attributes come out as now.Bill Wendling2013-01-291-3/+3
| | | | llvm-svn: 173762
* Fix some wrong-code bugs in implicitly-defined assignment operators:Richard Smith2012-11-131-0/+21
| | | | | | | - In C++11, perform overload resolution over all assignment operators, rather than just looking for copy/move assignment operators. - Clean up after temporaries produced by operator= immediately, rather than accumulating them until the end of the function. llvm-svn: 167798
* In Sema::MaybeBindToTemporary, create a CXXBindTemporaryExpr for anPeter Collingbourne2011-11-271-0/+18
| | | | | | array of objects with non-trivial destructors. PR11365. llvm-svn: 145203
* Track whether an AggValueSlot is potentially aliased, and do notJohn McCall2011-08-251-3/+3
| | | | | | | | | | emit call results into potentially aliased slots. This allows us to properly mark indirect return slots as noalias, at the cost of requiring an extra memcpy when assigning an aggregate call result into a l-value. It also brings us into compliance with the x86-64 ABI. llvm-svn: 138599
* A number of array-related IR-gen cleanups.John McCall2011-07-091-13/+9
| | | | | | | | | | | | - Emit default-initialization of arrays that were partially initialized with initializer lists with a loop, rather than emitting the default initializer N times; - support destroying VLAs of non-trivial type, although this is not yet exposed to users; and - support the partial destruction of arrays initialized with initializer lists when an initializer throws an exception. llvm-svn: 134784
* Fix some obvious bugs in the conditional-cleanup code and then make theJohn McCall2011-01-261-4/+2
| | | | | | dtor cleanup use it. llvm-svn: 124309
* Reset the lifetime-managed flag between emission of the agg conditionalJohn McCall2010-11-171-0/+32
| | | | | | branches. Fixes PR8623. llvm-svn: 119408
* Fix a bug with binding l-values to elided temporaries, and leave a coupleJohn McCall2010-09-181-1/+18
| | | | | | helpful asserts behind. llvm-svn: 114250
* Right, there are *two* cases of pr-value class-type expressions that don'tJohn McCall2010-09-161-0/+34
| | | | | | | derive from temporaries of the same type. Black-list member expressions as well. llvm-svn: 114071
* Test hardening.John McCall2010-09-151-6/+6
| | | | llvm-svn: 113963
* one piece of code is responsible for the lifetime of every aggregateJohn McCall2010-09-151-0/+104
| | | | | | | | | | | | | 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
* Reinstate the fix for PR7556. A silly use of isTrivial() wasDouglas Gregor2010-07-081-0/+18
| | | | | | suppressing copies of objects with trivial copy constructors. llvm-svn: 107857
* Revert r107828 and r107827, the fix for PR7556, which seems to beDouglas Gregor2010-07-071-18/+0
| | | | | | breaking bootstrap on Linux. llvm-svn: 107837
* Do not use CXXZeroValueInitExpr for class types. Instead, useDouglas Gregor2010-07-071-0/+18
| | | | | | | | | 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
* Tweak test for destruction of copied temporary objectsDouglas Gregor2010-04-251-0/+1
| | | | llvm-svn: 102291
* When copying a temporary object to initialize an entity for which theDouglas Gregor2010-04-251-0/+18
| | | | | | | 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
* Fix PR6648 by not creating a temporary with the type of aRafael Espindola2010-03-211-0/+13
| | | | | | | | | | | 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
* Give explicit template instantiations weak ODR linkage. FormerDouglas Gregor2010-03-131-1/+1
| | | | | | | | | 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
* Re-revert the explicit template instantiation linkage patch. I am beginning ↵Douglas Gregor2010-03-131-1/+1
| | | | | | to look incompetent llvm-svn: 98425
* Reinstate patch to turn explicit template instantiations into weak symbolsDouglas Gregor2010-03-131-1/+1
| | | | llvm-svn: 98424
* Revert the linkage change for explicit template instantiations; something is ↵Douglas Gregor2010-03-121-1/+1
| | | | | | amiss llvm-svn: 98332
* Give explicit template instantiations weak linkage (but don't deferDouglas Gregor2010-03-121-1/+1
| | | | | | them). Fixes PR6578. llvm-svn: 98328
OpenPOWER on IntegriCloud