summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprAgg.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename the ARC cast kinds to start with "ARC".John McCall2011-09-101-4/+4
| | | | llvm-svn: 139466
* When converting a block pointer to an Objective-C pointer type, extendJohn McCall2011-09-101-0/+1
| | | | | | | | | | | the lifetime of the block by copying it to the heap, or else we'll get a dangling reference because the code working with the non-block-typed object will not know it needs to copy. There is some danger here, e.g. with assigning a block literal to an unsafe variable, but, well, it's an unsafe variable. llvm-svn: 139451
* Give conversions of block pointers to ObjC pointers a different cast kindJohn McCall2011-09-091-1/+2
| | | | | | | | than conversions of C pointers to ObjC pointers. In order to ensure that we've caught every case, add asserts to CastExpr that strictly determine which cast kind is used for which kind of bit cast. llvm-svn: 139352
* When performing a derived-to-base cast on the right-hand side of theDouglas Gregor2011-09-061-1/+3
| | | | | | | | | | | | | | | | synthesized move assignment within an implicitly-defined move assignment operator, be sure to treat the derived-to-base cast as an xvalue (rather than an lvalue). Otherwise, we'll end up getting the wrong constructor. Optimize a direct call to a trivial move assignment operator to an aggregate copy, as we do for trivial copy assignment operators, and update the the assertion in CodeGenFunction::EmitAggregateCopy() to cope with this optimization. Fixes PR10860. llvm-svn: 139143
* Extend the ASTContext constructor to delay the initialization ofDouglas Gregor2011-09-021-1/+1
| | | | | | | | builtin types (When requested). This is another step toward making ASTUnit build the ASTContext as needed when loading an AST file, rather than doing so after the fact. No actual functionality change (yet). llvm-svn: 138985
* What say we document some of these AggValueSlot flags a bitJohn McCall2011-08-261-9/+10
| | | | | | better. llvm-svn: 138628
* Since the 'is aliased' bit is critical for correctness in C++, itJohn McCall2011-08-261-3/+6
| | | | | | | | | really shouldn't be optional. Fix the remaining place where a temporary was being passed as potentially-aliased memory. Fixes PR10756. llvm-svn: 138627
* Track whether an AggValueSlot is potentially aliased, and do notJohn McCall2011-08-251-21/+33
| | | | | | | | | | 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
* Use stronger typing for the flags on AggValueSlot and requireJohn McCall2011-08-251-12/+16
| | | | | | | creators to tell us whether something needs GC barriers. No functionality change. llvm-svn: 138581
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-1/+1
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Convert IRBuilder::CreateGEP and IRBuilder::CreateInBoundsGEP to useJay Foad2011-07-221-1/+1
| | | | | | ArrayRef. llvm-svn: 135761
* de-constify llvm::Type, patch by David Blaikie!Chris Lattner2011-07-181-11/+11
| | | | llvm-svn: 135370
* Create a new expression node, SubstNonTypeTemplateParmExpr,John McCall2011-07-151-0/+3
| | | | | | | | to represent a fully-substituted non-type template parameter. This should improve source fidelity, as well as being generically useful for diagnostics and such. llvm-svn: 135243
* Emit partial destruction of structs with initializer lists.John McCall2011-07-111-20/+47
| | | | llvm-svn: 134913
* Fix a lot of problems with the partial destruction of arrays:John McCall2011-07-111-12/+15
| | | | | | | | | | | - an off-by-one error in emission of irregular array limits for InitListExprs - use an EH partial-destruction cleanup within the normal array-destruction cleanup - get the branch destinations right for the empty check Also some refactoring which unfortunately obscures these changes. llvm-svn: 134890
* A number of array-related IR-gen cleanups.John McCall2011-07-091-36/+123
| | | | | | | | | | | | - 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
* In ARC, reclaim all return values of retainable type, not just thoseJohn McCall2011-07-071-0/+1
| | | | | | | | | | | | where we have an immediate need of a retained value. As an exception, don't do this when the call is made as the immediate operand of a __bridge retain. This is more in the way of a workaround than an actual guarantee, so it's acceptable to be brittle here. rdar://problem/9504800 llvm-svn: 134605
* LValue carries a type now, so simplify the main EmitLoad/Store APIsJohn McCall2011-06-251-3/+3
| | | | | | by removing the redundant type parameter. llvm-svn: 133860
* Introduce a new AST node describing reference binding to temporaries.Douglas Gregor2011-06-211-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | MaterializeTemporaryExpr captures a reference binding to a temporary value, making explicit that the temporary value (a prvalue) needs to be materialized into memory so that its address can be used. The intended AST invariant here is that a reference will always bind to a glvalue, and MaterializeTemporaryExpr will be used to convert prvalues into glvalues for that binding to happen. For example, given const int& r = 1.0; The initializer of "r" will be a MaterializeTemporaryExpr whose subexpression is an implicit conversion from the double literal "1.0" to an integer value. IR generation benefits most from this new node, since it was previously guessing (badly) when to materialize temporaries for the purposes of reference binding. There are likely more refactoring and cleanups we could perform there, but the introduction of MaterializeTemporaryExpr fixes PR9565, a case where IR generation would effectively bind a const reference directly to a bitfield in a struct. Addresses <rdar://problem/9552231>. llvm-svn: 133521
* When emitting a compound literal of POD type, continue to emit aDouglas Gregor2011-06-171-0/+10
| | | | | | | | | | | | | | | | | separate aggregate temporary and then memcpy it over to the destination. This fixes a regression I introduced with r133235, where the compound literal on the RHS of an assignment makes use of the structure on the LHS of the assignment. I'm deeply suspicious of AggExprEmitter::VisitBinAssign()'s optimization where it emits the RHS of an aggregate assignment directly into the LHS lvalue without checking whether there is any aliasing between the LHS/RHS. However, I'm not in a position to revisit this now. Big thanks to Eli for finding the regression! llvm-svn: 133261
* Implement proper support for generating code for compound literals inDouglas Gregor2011-06-171-3/+8
| | | | | | | | | | | | | C++, which means: - binding the temporary as needed in Sema, so that we generate the appropriate call to the destructor, and - emitting the compound literal into the appropriate location for the aggregate, rather than trying to emit it as a temporary and memcpy() it. Fixes PR10138 / <rdar://problem/9615901>. llvm-svn: 133235
* Restore correct use of GC barriers.John McCall2011-06-161-33/+32
| | | | llvm-svn: 133144
* Automatic Reference Counting.John McCall2011-06-151-8/+16
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Rename "hasTrivialConstructor" to "hasTrivialDefaultConstructor" andAlexis Hunt2011-05-091-1/+1
| | | | | | | modify the semantics slightly to accomodate default constructors (I hope). llvm-svn: 131087
* removes a meaningless comment.Fariborz Jahanian2011-04-291-3/+1
| | | | llvm-svn: 130550
* block variables on lhs need be ir-gen'ed after theFariborz Jahanian2011-04-291-1/+18
| | | | | | | | rhs when its 'forwarding' pointer may be modified in rhs evaluation as result of call to Block_copy. // rdar://9309454 llvm-svn: 130545
* Cut down unnecessary zero'ing when value-initializing arrays of C++ objects.Argyrios Kyrtzidis2011-04-281-1/+10
| | | | | | | -C++ objects with user-declared constructor don't need zero'ing. -We can zero-initialize arrays of C++ objects in "bulk" now, in which case don't zero-initialize each object again. llvm-svn: 130453
* Get the base element type even in multidimensional arrays.Argyrios Kyrtzidis2011-04-281-1/+2
| | | | llvm-svn: 130427
* When value-initializing the elements of an array not not included in the ↵Argyrios Kyrtzidis2011-04-281-1/+9
| | | | | | | | | | initializer make sure that a non-trivial C++ constructor gets called. Fixes rdar://9347552 & http://llvm.org/PR9801 llvm-svn: 130421
* Convert size and alignment variables to CharUnits in EmitAggregateCopy(). NoKen Dyck2011-04-241-7/+10
| | | | | | change in functionality intended. llvm-svn: 130113
* Convert type size and alignment to CharUnits in CheckAggExprForMemSetUse().Ken Dyck2011-04-241-8/+9
| | | | | | No change in functionality intended. llvm-svn: 130112
* Convert the return type of GetNumNonZeroBytesInInit() to CharUnits. NoKen Dyck2011-04-241-7/+8
| | | | | | change in functionality intended. llvm-svn: 130111
* Eliminate some literal 8s by converting size variables in EmitGCMove() andKen Dyck2011-04-241-4/+4
| | | | | | EmitFinalDestCopy() to CharUnits. No change in functionality intended. llvm-svn: 130110
* Replace calls to ASTContext::getTypeInfo() with calls toKen Dyck2011-04-241-6/+2
| | | | | | | ASTContext::getTypeSize() when only the size part is used. No change in functionality intended. llvm-svn: 130109
* ForArgyrios Kyrtzidis2011-04-211-0/+2
| | | | | | | | | | | | | | double data[20000000] = {0}; we would blow out the memory by creating 20M Exprs to fill out the initializer. To fix this, if the initializer list initializes an array with more elements than there are initializers in the list, have InitListExpr store a single 'ArrayFiller' expression that specifies an expression to be used for value initialization of the rest of the elements. Fixes rdar://9275920. llvm-svn: 129896
* C1X: implement generic selectionsPeter Collingbourne2011-04-151-5/+6
| | | | | | | As an extension, generic selection support has been added for all supported languages. The syntax is the same as for C1X. llvm-svn: 129554
* We can't emit an aggregate cast as its sub-expression in general justJohn McCall2011-04-121-5/+2
| | | | | | | | | because the result is ignored. The particular example here is with property l-values, but there could be all sorts of lovely casts that this isn't safe for. Sink the check into the one case that seems to actually be capable of honoring this. llvm-svn: 129397
* After some discussion with Doug, we decided that it made a lot more senseJohn McCall2011-04-121-5/+0
| | | | | | | | | for __unknown_anytype resolution to destructively modify the AST. So that's what it does now, which significantly simplifies some of the implementation. Normal member calls work pretty cleanly now, and I added support for propagating unknown-ness through &. llvm-svn: 129331
* More __unknown_anytype work.John McCall2011-04-111-0/+1
| | | | llvm-svn: 129269
* Remove CK_DynamicToNull.Anders Carlsson2011-04-111-4/+1
| | | | llvm-svn: 129265
* As a first step towards fixing PR9641, add a CK_DynamicToNull cast kind whichAnders Carlsson2011-04-101-1/+4
| | | | | | | | | | | | | | | | | | represents a dynamic cast where we know that the result is always null. For example: struct A { virtual ~A(); }; struct B final : A { }; struct C { }; bool f(B* b) { return dynamic_cast<C*>(b); } llvm-svn: 129256
* Basic, untested implementation for an "unknown any" type requested by LLDB.John McCall2011-04-071-0/+4
| | | | | | | | | | | | The idea is that you can create a VarDecl with an unknown type, or a FunctionDecl with an unknown return type, and it will still be valid to access that object as long as you explicitly cast it at every use. I'm still going back and forth about how I want to test this effectively, but I wanted to go ahead and provide a skeletal implementation for the LLDB folks' benefit and because it also improves some diagnostic goodness for placeholder expressions. llvm-svn: 129065
* Fix IRGen issues related to using property-dot syntaxFariborz Jahanian2011-03-301-3/+11
| | | | | | for prperty reference types. // rdar://9208606. llvm-svn: 128551
* Change the representation of GNU ?: expressions to use a different expressionJohn McCall2011-02-171-10/+9
| | | | | | | | | | | | | | | | | | | | | | class and to bind the shared value using OpaqueValueExpr. This fixes an unnoticed problem with deserialization of these expressions where the deserialized form would lose the vital pointer-equality trait; or rather, it fixes it because this patch also does the right thing for deserializing OVEs. Change OVEs to not be a "temporary object" in the sense that copy elision is permitted. This new representation is not totally unawkward to work with, but I think that's really part and parcel with the semantics we're modelling here. In particular, it's much easier to fix things like the copy elision bug and to make the CFG look right. I've tried to update the analyzer to deal with this in at least some obvious cases, and I think we get a much better CFG out, but the printing of OpaqueValueExprs probably needs some work. llvm-svn: 125744
* Save a copy expression for non-trivial copy constructions of catch variables.John McCall2011-02-161-0/+6
| | | | llvm-svn: 125661
* Reorganize CodeGen{Function,Module} to eliminate the unfortunateJohn McCall2011-02-081-2/+2
| | | | | | | | Block{Function,Module} base class. Minor other refactorings. Fixed a few address-space bugs while I was there. llvm-svn: 125085
* Better framework for conditional cleanups; untested as yet.John McCall2011-01-261-10/+10
| | | | | | | | I'm separately committing this because it incidentally changes some block orderings and minor IR issues, like using a phi instead of an unnecessary alloca. llvm-svn: 124277
* Ensure an insertion point at the end of a statement-expression.John McCall2011-01-131-0/+1
| | | | | | Fixes PR8967. llvm-svn: 123360
* Simplify mem{cpy, move, set} creation with IRBuilder.Benjamin Kramer2010-12-301-12/+5
| | | | llvm-svn: 122634
* Rename CXXExprWithTemporaries -> ExprWithCleanups; there's no theoreticalJohn McCall2010-12-061-3/+3
| | | | | | reason this is limited to C++, and it's certainly not limited to temporaries. llvm-svn: 120996
OpenPOWER on IntegriCloud