summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "[CodeGenCXX] Treat 'this' as noalias in constructors"Sean Fertile2018-10-151-4/+4
| | | | | | | 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-4/+4
| | | | | | | | | 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
* Fold dangling-field warning into general initialization lifetime checks.Richard Smith2018-07-231-11/+11
| | | | | | | This reinstates r337627, reverted in r337671, with a fix to correctly handle the lvalueness of array subscript expressions on pointers. llvm-svn: 337726
* Revert "Fold dangling-field warning into general initialization lifetime ↵Ilya Biryukov2018-07-231-11/+11
| | | | | | | | | | | | | | | | checks." This reverts commit r337627. After the change, clang started producing invalid warning on the following code: struct foo { foo(char *x) : x_(&x[10]) {} private: char *x_; }; 1.cpp:2:21: warning: initializing pointer member 'x_' with the stack address of parameter 'x' [-Wdangling-field] llvm-svn: 337671
* Fold dangling-field warning into general initialization lifetime checks.Richard Smith2018-07-201-11/+11
| | | | llvm-svn: 337627
* Restructure checking for, and warning on, lifetime extension.Richard Smith2018-07-171-30/+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/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-30/+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
* Disable -fmerge-all-constants as default.Manoj Gupta2018-04-051-2/+2
| | | | | | | | | | | | | | | | | | | Summary: "-fmerge-all-constants" is a non-conforming optimization and should not be the default. It is also causing miscompiles when building Linux Kernel (https://lkml.org/lkml/2018/3/20/872). Fixes PR18538. Reviewers: rjmccall, rsmith, chandlerc Reviewed By: rsmith, chandlerc Subscribers: srhines, cfe-commits Differential Revision: https://reviews.llvm.org/D45289 llvm-svn: 329300
* [AMDGPU] Clean up old address space mapping and fix constant address space valueYaxun Liu2018-03-051-9/+9
| | | | | | Differential Revision: https://reviews.llvm.org/D43911 llvm-svn: 326725
* Clean up AMDGCN testsYaxun Liu2018-02-151-23/+23
| | | | | | Differential Revision: https://reviews.llvm.org/D43340 llvm-svn: 325279
* CodeGen: Fix address space of global variableYaxun Liu2017-07-081-65/+86
| | | | | | | | | | | | | Certain targets (e.g. amdgcn) require global variable to stay in global or constant address space. In C or C++ global variables are emitted in the default (generic) address space. This patch introduces virtual functions TargetCodeGenInfo::getGlobalVarAddressSpace and TargetInfo::getConstantAddressSpace to handle this in a general approach. It only affects IR generated for amdgcn target. Differential Revision: https://reviews.llvm.org/D33842 llvm-svn: 307470
* Replace Sema-level implementation of -fassume-sane-operator-new with aRichard Smith2016-04-071-1/+1
| | | | | | | | | | | | | | CodeGen-level implementation. Instead of adding an attribute to clang's FunctionDecl, add the IR attribute directly. This means a module built with this flag is now compatible with code built without it and vice versa. This change also results in the 'noalias' attribute no longer being added to calls to operator new in the IR; it's now only added to the declaration. It also fixes a bug where we failed to add the attribute to the 'nothrow' versions (because we didn't implicitly declare them, there was no good time to inject a fake attribute). llvm-svn: 265728
* Compute and preserve alignment more faithfully in IR-generation.John McCall2015-09-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce an Address type to bundle a pointer value with an alignment. Introduce APIs on CGBuilderTy to work with Address values. Change core APIs on CGF/CGM to traffic in Address where appropriate. Require alignments to be non-zero. Update a ton of code to compute and propagate alignment information. As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment helper function to CGF and made use of it in a number of places in the expression emitter. The end result is that we should now be significantly more correct when performing operations on objects that are locally known to be under-aligned. Since alignment is not reliably tracked in the type system, there are inherent limits to this, but at least we are no longer confused by standard operations like derived-to-base conversions and array-to-pointer decay. I've also fixed a large number of bugs where we were applying the complete-object alignment to a pointer instead of the non-virtual alignment, although most of these were hidden by the very conservative approach we took with member alignment. Also, because IRGen now reliably asserts on zero alignments, we should no longer be subject to an absurd but frustrating recurring bug where an incomplete type would report a zero alignment and then we'd naively do a alignmentAtOffset on it and emit code using an alignment equal to the largest power-of-two factor of the offset. We should also now be emitting much more aggressive alignment attributes in the presence of over-alignment. In particular, field access now uses alignmentAtOffset instead of min. Several times in this patch, I had to change the existing code-generation pattern in order to more effectively use the Address APIs. For the most part, this seems to be a strict improvement, like doing pointer arithmetic with GEPs instead of ptrtoint. That said, I've tried very hard to not change semantics, but it is likely that I've failed in a few places, for which I apologize. ABIArgInfo now always carries the assumed alignment of indirect and indirect byval arguments. In order to cut down on what was already a dauntingly large patch, I changed the code to never set align attributes in the IR on non-byval indirect arguments. That is, we still generate code which assumes that indirect arguments have the given alignment, but we don't express this information to the backend except where it's semantically required (i.e. on byvals). This is likely a minor regression for those targets that did provide this information, but it'll be trivial to add it back in a later patch. I partially punted on applying this work to CGBuiltin. Please do not add more uses of the CreateDefaultAligned{Load,Store} APIs; they will be going away eventually. llvm-svn: 246985
* [CodeGen] Do a more principled fix for PR231653, always use the inner type.Benjamin Kramer2015-04-091-1/+1
| | | | | | | We were still using the MaterializeTemporaryExpr's type to check if the transform is legal. Always use the inner Expr type. llvm-svn: 234543
* Fix test in release mode. This reapplies r232456, corresponding to r232579.NAKAMURA Takumi2015-03-181-1/+1
| | | | llvm-svn: 232582
* Fix the LLVM type used when lowering initializer list reference temporaries ↵Nick Lewycky2015-03-181-0/+33
| | | | | | to global variables. Reapplies r232454 with fix for PR22940. llvm-svn: 232579
* Revert r232454 and r232456: "Fix the LLVM type used when lowering ↵Hans Wennborg2015-03-171-24/+0
| | | | | | | | initializer list reference temporaries to global variables." This caused PR22940. llvm-svn: 232496
* Fix test in release mode.Nick Lewycky2015-03-171-1/+1
| | | | llvm-svn: 232456
* Fix the LLVM type used when lowering initializer list reference temporaries ↵Nick Lewycky2015-03-171-0/+24
| | | | | | to global variables. llvm-svn: 232454
* Add a bunch of missing "CHECK" colons in tests. NFC.Ahmed Bougacha2015-03-141-1/+1
| | | | llvm-svn: 232237
* Test case updates for explicit type parameter to the gep operatorDavid Blaikie2015-03-131-25/+25
| | | | llvm-svn: 232187
* Reapply r231508 "CodeGen: Emit constant temporaries into read-only globals."Benjamin Kramer2015-03-071-11/+28
| | | | | | | | | | | | I disabled putting the new global into the same COMDAT as the function for now. There's a fundamental problem when we inline references to the global but still have the global in a COMDAT linked to the inlined function. Since this is only an optimization there may be other versions of the COMDAT around that are missing the new global and hell breaks loose at link time. I hope the chromium build doesn't break this time :) llvm-svn: 231564
* Revert r231508 "CodeGen: Emit constant temporaries into read-only globals."Hans Wennborg2015-03-071-28/+11
| | | | | | | | | This broke the Chromium build. Links were failing with messages like: obj/dbus/libdbus_test_support.a(obj/dbus/dbus_test_support.mock_object_proxy.o):../../dbus/mock_object_proxy.cc:function dbus::MockObjectProxy::Detach(): warning: relocation refers to discarded section /usr/local/google/work/chromium/src/third_party/binutils/Linux_x64/Release/bin/ld.gold: error: treating warnings as errors llvm-svn: 231541
* CodeGen: Emit constant temporaries into read-only globals.Benjamin Kramer2015-03-061-11/+28
| | | | | | | | | | | | | | | | | | | | | | | Instead of creating a copy on the stack just stash them in a private constant global. This saves both the copying overhead and the stack space, and gives the optimizer more room to constant fold. This tries to make array temporaries more similar to regular arrays, they can't use the same logic because a temporary has no VarDecl to be bound to so we roll our own version here. The original use case for this optimization was code like for (int i : {1, 2, 3, 4, 5, 6, 7, 8, 10}) foo(i); where without this patch (assuming that the loop is not unrolled) we would alloca an array on the stack, copy the 10 values over and iterate on that. With this patch we put the array in .text use it directly. Apart from that case this helps on virtually any passing of a constant std::initializer_list as a function argument. Differential Revision: http://reviews.llvm.org/D8034 llvm-svn: 231508
* Update Clang tests to handle explicitly typed load changes in LLVM.David Blaikie2015-02-271-1/+1
| | | | llvm-svn: 230795
* Update Clang tests to handle explicitly typed gep changes in LLVM.David Blaikie2015-02-271-2/+2
| | | | 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
* PR20445: Properly transform the initializer in a CXXNewExpr rather than runningRichard Smith2014-07-251-0/+10
| | | | | | | it through the normal TreeTransform logic for Exprs (which will strip off implicit parts of the initialization and never re-create them). llvm-svn: 213913
* Remove incorrect assertion.Richard Smith2014-06-031-0/+7
| | | | llvm-svn: 210092
* Implement DR990 and DR1070. Aggregate initialization initializes uninitializedRichard Smith2014-06-031-1/+18
| | | | | | | | | elements from {}, rather than value-initializing them. This permits calling an initializer-list constructor or constructing a std::initializer_list object. (It would also permit initializing a const reference or rvalue reference if that weren't explicitly prohibited by other rules.) llvm-svn: 210091
* AST: Update reference temporary manglingDavid Majnemer2014-05-061-9/+9
| | | | | | | | | | | | | | | 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-20/+20
| | | | | | tests fail. llvm-svn: 188447
* Fix nested lifetime extension when a std::initializer_list member isRichard Smith2013-06-271-0/+36
| | | | | | initialized during aggregate initialization of the surrounding structure. llvm-svn: 185117
* Emit initializers for static-storage-duration temporaries as constants whereRichard Smith2013-06-141-5/+46
| | | | | | possible. llvm-svn: 183967
* Clean up test to appease NDEBUG builds.Richard Smith2013-06-131-6/+6
| | | | llvm-svn: 183924
* PR12086, PR15117Richard Smith2013-06-121-8/+74
| | | | | | | | | | | | | | | | | | | Introduce CXXStdInitializerListExpr node, representing the implicit construction of a std::initializer_list<T> object from its underlying array. The AST representation of such an expression goes from an InitListExpr with a flag set, to a CXXStdInitializerListExpr containing a MaterializeTemporaryExpr containing an InitListExpr (possibly wrapped in a CXXBindTemporaryExpr). This more detailed representation has several advantages, the most important of which is that the new MaterializeTemporaryExpr allows us to directly model lifetime extension of the underlying temporary array. Using that, this patch *drastically* simplifies the IR generation of this construct, provides IR generation support for nested global initializer_list objects, fixes several bugs where the destructors for the underlying array would accidentally not get invoked, and provides constant expression evaluation support for std::initializer_list objects. llvm-svn: 183872
* Model temporary lifetime-extension explicitly in the AST. Use this model toRichard Smith2013-06-051-0/+3
| | | | | | | | | handle temporaries which have been lifetime-extended to static storage duration within constant expressions. This correctly handles nested lifetime extension (through reference members of aggregates in aggregate initializers) but non-constant-expression emission hasn't yet been updated to do the same. llvm-svn: 183283
* Fix assert on temporary std::initializer_list.Richard Smith2013-05-231-0/+10
| | | | llvm-svn: 182615
* CodeGen support for function-local static thread_local variables withRichard Smith2013-04-141-0/+6
| | | | | | | | | non-constant constructors or non-trivial destructors. Plus bugfixes for thread_local references bound to temporaries (the temporaries themselves are lifetime-extended to become thread_local), and the corresponding case for std::initializer_list. llvm-svn: 179496
* <rdar://problem/13325066> Destroy std::initializer_list temporaries whose ↵Douglas Gregor2013-04-061-0/+19
| | | | | | lifetime has been extended by reference binding. llvm-svn: 178939
* Provide fixed target triples to make test results consistent across ARM hosts.David Blaikie2012-09-101-1/+1
| | | | | | Patch by David Tweed, review by myself and John McCall. llvm-svn: 163564
* If the element type of an initializer list has a destructor, make sure we ↵Sebastian Redl2012-03-051-0/+18
| | | | | | check it. Fixes PR12178. llvm-svn: 152048
* CodeGen support for global variables of type std::initializer_list<X>.Sebastian Redl2012-02-251-15/+32
| | | | | | | | | | | | | This emits a backing array with internal linkage and fills it with data, then has the initializer_list point at the array. Dynamic initialization and global destructors are correctly supported. What doesn't work is nested initializer_lists. I have no idea how to get them to work, either. However, these should be very rare, and so I'll just call it a known bug and declare generalized initializers DONE! llvm-svn: 151457
* Harden test against for operator new(unsigned int).Benjamin Kramer2012-02-191-1/+1
| | | | llvm-svn: 150932
* Make heap-allocation of std::initializer_list 'work'.Sebastian Redl2012-02-191-0/+20
| | | | llvm-svn: 150931
* Make std::initializer_list member initializers 'work'.Sebastian Redl2012-02-191-0/+31
| | | | llvm-svn: 150930
* Get recursive initializer lists to work and add a test. Codegen of ↵Sebastian Redl2012-02-191-0/+28
| | | | | | std::initializer_list is now complete. Onward to array new. llvm-svn: 150926
* Add a testcase for using objects with list-constructors, and fix a Sema ↵Sebastian Redl2012-02-191-1/+29
| | | | | | crash by repeating an old hack. llvm-svn: 150925
* Add a testcase to show that temporaries from the initializer list are ↵Sebastian Redl2012-02-191-0/+30
| | | | | | destroyed correctly. llvm-svn: 150924
OpenPOWER on IntegriCloud