summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Re-land the fix for PR7139.Anders Carlsson2010-05-221-1/+1
| | | | llvm-svn: 104446
* Improve our handling of reference binding for subobjects ofDouglas Gregor2010-05-221-7/+19
| | | | | | | | | | | | | | | | | | | | | | | | | temporaries. There are actually several interrelated fixes here: - When converting an object to a base class, it's only an lvalue cast when the original object was an lvalue and we aren't casting pointer-to-derived to pointer-to-base. Previously, we were misclassifying derived-to-base casts of class rvalues as lvalues, causing various oddities (including problems with reference binding not extending the lifetimes of some temporaries). - Teach the code for emitting a reference binding how to look through no-op casts and parentheses directly, since Expr::IgnoreParenNoOpCasts is just plain wrong for this. Also, make sure that we properly look through multiple levels of indirection from the temporary object, but destroy the actual temporary object; this fixes the reference-binding issue mentioned above. - Teach Objective-C message sends to bind the result as a temporary when needed. This is actually John's change, but it triggered the reference-binding problem above, so it's included here. Now John can actually test his return-slot improvements. llvm-svn: 104434
* Unbreak self-host.Anders Carlsson2010-05-211-1/+1
| | | | llvm-svn: 104390
* Rename CodeGenFunction::EmitMemSetToZero to EmitNullInitialization. Handle ↵Anders Carlsson2010-05-211-1/+1
| | | | | | setting null data member pointers correctly. Fixes PR7139. llvm-svn: 104387
* When emitting an lvalue for an anonymous struct or union member duringJohn McCall2010-05-211-0/+29
| | | | | | | class initialization, drill down through an arbitrary number of anonymous records. llvm-svn: 104310
* Rework our handling of binding a reference to a temporaryDouglas Gregor2010-05-201-18/+100
| | | | | | | | | | | | | | | | | | | | subobject. Previously, we could only properly bind to a base class subobject while extending the lifetime of the complete object (of a derived type); for non-static data member subobjects, we could memcpy (!) the result and bind to that, which is rather broken. Now, we pull apart the expression that we're binding to, to figure out which subobject we're accessing, then construct the temporary object (adding a destruction if needed) and, finally, dig out the subobject we actually meant to access. This fixes yet another instance where we were memcpy'ing rather than doing the right thing. However, note the FIXME in references.cpp: there's more work to be done for binding to subobjects, since the AST is incorrectly modeling some member accesses in base classes as lvalues when they are really rvalues. llvm-svn: 104219
* Substantially alter the design of the Objective C type AST by introducingJohn McCall2010-05-151-4/+3
| | | | | | | | | | | | | | | | | | | | | ObjCObjectType, which is basically just a pair of one of {primitive-id, primitive-Class, user-defined @class} with a list of protocols. An ObjCObjectPointerType is therefore just a pointer which always points to one of these types (possibly sugared). ObjCInterfaceType is now just a kind of ObjCObjectType which happens to not carry any protocols. Alter a rather large number of use sites to use ObjCObjectType instead of ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather than hashing them in a FoldingSet. Remove some number of methods that are no longer used, at least after this patch. By simplifying ObjCObjectPointerType, we are now able to easily remove and apply pointers to Objective-C types, which is crucial for a certain kind of ObjC++ metaprogramming common in WebKit. llvm-svn: 103870
* Minor refactoring of my last patch.Fariborz Jahanian2010-05-111-4/+5
| | | | llvm-svn: 103475
* Objective-C++ Code gen. Handle code gen. for propertyFariborz Jahanian2010-05-101-1/+10
| | | | | | | reference dot-syntax notation in a varierty of cases. Fixes radar 7964490. llvm-svn: 103440
* Add the same 'ForVirtualBase' parameter to EmitCXXDestructorCall.Anders Carlsson2010-05-021-0/+2
| | | | llvm-svn: 102882
* Change CodeGenFunction::GetAddressOfDerivedClass to take a BasePath.Anders Carlsson2010-04-241-7/+2
| | | | llvm-svn: 102273
* Convert more call sites over to the new GetAddressOfBaseClass.Anders Carlsson2010-04-241-10/+6
| | | | llvm-svn: 102272
* Handle compound assignment expressions (i += j) as lvalues, which isDouglas Gregor2010-04-231-0/+2
| | | | | | | permitted in C++ but not in C. Fixes PR6900. Clang can now handle all of Boost.Lambda's regression tests. llvm-svn: 102170
* Call PerformCopyInitialization to properly initialize the exception temporaryJohn McCall2010-04-221-0/+7
| | | | | | | | | in a throw expression. Use EmitAnyExprToMem to emit the throw expression, which magically elides the final copy-constructor call (which raises a new strict-compliance bug, but baby steps). Give __cxa_throw a destructor pointer if the exception type has a non-trivial destructor. llvm-svn: 102039
* Miscellaneous codegen cleanups. Mostly, don't create new basic blocksJohn McCall2010-04-211-6/+18
| | | | | | | just to save the current insertion state! This change significantly simplifies the IR CFG in exceptions code. llvm-svn: 101996
* Some renaming of methods, fixes typoFariborz Jahanian2010-04-191-2/+3
| | | | | | (related to PR6769). llvm-svn: 101794
* Local static variables must be available module-wiseFariborz Jahanian2010-04-181-0/+2
| | | | | | | as they are accessible in static methods in a class local to the same function. Fixes PR6769. llvm-svn: 101756
* Fix an assert when assigning a boolean value to a bitfield of type _Bool.Anders Carlsson2010-04-171-1/+5
| | | | llvm-svn: 101678
* IRgen: (Reapply 101222, with fixes) Move EmitStoreThroughBitfieldLValue to ↵Daniel Dunbar2010-04-151-88/+84
| | | | | | | | | | | | | | | | use new CGBitfieldInfo::AccessInfo decomposition, instead of computing the access policy itself. - Sadly, this doesn't seem to give any .ll size win so far. It is possible to make this routine significantly smarter & avoid various shifting, masking, and zext/sext, but I'm not really convinced it is worth it. It is tricky, and this is really instcombine's job. - No intended functionality change; the test case is just to increase coverage & serves as a demo file, it worked before this commit. The new fixes from r101222 are: 1. The shift to the target position needs to occur after the value is extended to the correct size. This broke Clang bootstrap, among other things no doubt. 2. Swap the order of arguments to OR, to get a tad more constant folding. llvm-svn: 101339
* Speculatively revert "IRgen: Move EmitStoreThroughBitfieldLValue to use new ↵Daniel Dunbar2010-04-141-82/+88
| | | | | | CGBitfieldInfo::AccessInfo decomposition, instead of computing the access policy itself.", I think it might be breaking bootstrap. llvm-svn: 101235
* IRgen: Move EmitStoreThroughBitfieldLValue to use new ↵Daniel Dunbar2010-04-141-88/+82
| | | | | | | | | | CGBitfieldInfo::AccessInfo decomposition, instead of computing the access policy itself. - Sadly, this doesn't seem to give any .ll size win so far. It is possible to make this routine significantly smarter & avoid various shifting, masking, and zext/sext, but I'm not really convinced it is worth it. It is tricky, and this is really instcombine's job. - No intended functionality change; the test case is just to increase coverage & serves as a demo file, it worked before this commit. llvm-svn: 101222
* IRgen: Move EmitLoadOfBitfieldLValue to use new CGBitfieldInfo::AccessInfo ↵Daniel Dunbar2010-04-131-51/+61
| | | | | | | | | | | | decomposition, instead of computing the access policy itself. - This lets the method focus slightly more on emitting clean IR to honor the policy which has been selected. On 403.gcc's combine.c, x86_64, -O0, this reduces the number of lines in the .ll file (~= # of instructions) by 2.5%. - No intended functionality change -- at -O3 this should produce equivalent if not identical output. On 403.gcc's combine.c, x86_64, -O3, this isn't quite true and some of the changes are regressions, but I'm not going to worry about that until we move to a new access policy. - There is still some room for improvement in the generated IR, in particular we can usually fold the sign-extension of the bit-field into one of the component access. See the FIXME. llvm-svn: 101192
* fix PR6805: llvm.objectsize changed to take an i1 instead of an i32.Chris Lattner2010-04-101-8/+5
| | | | llvm-svn: 100938
* IRgen: Move the bit-field access type into CGBitFieldInfo, and change ↵Daniel Dunbar2010-04-081-15/+18
| | | | | | bit-field LValues to just store the base address of object containing the bit-field. llvm-svn: 100745
* IRgen: Move BitFieldIsSigned bit into CGBitFieldInfo.Daniel Dunbar2010-04-061-7/+9
| | | | llvm-svn: 100513
* Simplify.Daniel Dunbar2010-04-061-6/+2
| | | | llvm-svn: 100511
* IRgen: Move BitField LValues to just hold a reference to the CGBitFieldInfo.Daniel Dunbar2010-04-051-15/+14
| | | | | | | | | - Unfortunately, this requires some horrible code in CGObjCMac which always allocats a CGBitFieldInfo because we don't currently build a proper layout for Objective-C classes. It needs to be cleaned up, but I don't want the bit-field cleanups to be blocked on that. llvm-svn: 100474
* IRgen: Lift BitFieldInfo to CGBitFieldInfo at namespace level.Daniel Dunbar2010-04-051-1/+1
| | | | llvm-svn: 100433
* IRGen: Move the auxiliary data structures tracking AST -> LLVM mappings out ↵Daniel Dunbar2010-03-311-3/+10
| | | | | | | | of CodeGenTypes, to per-record CGRecordLayout structures. - I did a cursory check that this was perf neutral, FWIW. llvm-svn: 99978
* Introduce a new kind of derived-to-base cast which bypasses the need forJohn McCall2010-03-301-0/+1
| | | | | | | null checks, and make sure we elide null checks when accessing base class members. llvm-svn: 99963
* Minor formatting/FIXME cleanups.Daniel Dunbar2010-03-301-1/+0
| | | | llvm-svn: 99944
* Fix PR6473.Rafael Espindola2010-03-041-0/+10
| | | | | | | | | Clang's support for weakref is now better than llvm-gcc's :-) We don't introduce a new symbol and we correctly mark undefined references weak only if there is no definition or regular undefined references in the same file. llvm-svn: 97733
* IRgen: Add CreateIRTemp, which creates a temporary alloca but with type ↵Daniel Dunbar2010-02-161-1/+11
| | | | | | converted "not-for-memory". Dunno a better name. llvm-svn: 96374
* IRgen: Switch EmitCompoundLiteralLValue to use CreateMemTemp.Daniel Dunbar2010-02-161-3/+1
| | | | llvm-svn: 96373
* When emitting an aggregate into a temporary, make sure we set the alignmentJohn McCall2010-02-151-1/+1
| | | | | | | | | on the alloca. The fact that codegen makes this class of bug so wonderfully easy to make is embarrassing. llvm-svn: 96204
* More vtable layout dumper improvements. Handle destructors, dump the ↵Anders Carlsson2010-02-111-2/+1
| | | | | | complete function type of the member functions (using PredefinedExpr::ComputeName. llvm-svn: 95887
* IRgen: Add CreateMemTemp, for creating an temporary memory object for a ↵Daniel Dunbar2010-02-091-11/+15
| | | | | | | | | | particular type, and flood fill. - CreateMemTemp sets the alignment on the alloca correctly, which fixes a great many places in IRgen where we were doing the wrong thing. - This fixes many many more places than the test case, but my feeling is we need to audit alignment systematically so I'm not inclined to try hard to test the individual fixes in this patch. If this bothers you, patches welcome! PR6240. llvm-svn: 95648
* Reapply r95393, without the change to CGExpr. I was wrong in assuming that theDaniel Dunbar2010-02-081-0/+2
| | | | | | element type always matched the converted LLVM type for ExprType. llvm-svn: 95596
* Standardize the parsing of function type attributes in a way thatJohn McCall2010-02-051-14/+4
| | | | | | | | | | | | follows (as conservatively as possible) gcc's current behavior: attributes written on return types that don't apply there are applied to the function instead, etc. Only parse CC attributes as type attributes, not as decl attributes; don't accepet noreturn as a decl attribute on ValueDecls, either (it still needs to apply to other decls, like blocks). Consistently consume CC/noreturn information throughout codegen; enforce this by removing their default values in CodeGenTypes::getFunctionInfo(). llvm-svn: 95436
* Revert r95393, which broke Clang's self-host.Douglas Gregor2010-02-051-2/+3
| | | | llvm-svn: 95430
* IRgen: A few more ConvertType cleanups.Daniel Dunbar2010-02-051-11/+6
| | | | llvm-svn: 95423
* IRgen: Factor out EmitAggExprToLValue.Daniel Dunbar2010-02-051-14/+6
| | | | llvm-svn: 95416
* IRgen: Fix some CreateTempAlloca calls to use ConvertTypeForMem when that isDaniel Dunbar2010-02-051-1/+2
| | | | | | conceptually correct. Review appreciated (Chris, Eli, Anders). llvm-svn: 95401
* Now that we store calling conventions in the types, use them instead ofCharles Davis2010-02-051-6/+10
| | | | | | | getting the calling convention from the target function, which may or may not exist. Fixes PR5280. llvm-svn: 95399
* IRgen: Use hasAggregateLLVMType instead of isSingleValueType() for cases thatDaniel Dunbar2010-02-051-3/+2
| | | | | | | | need to deal with aggregates specially; this is consistent with the rest of IRgen. Also, simplify EmitParmDecl and don't worry about using Decl::getNameAsString. llvm-svn: 95393
* When binding an lvalue to a reference, we always need to pop temporaries.Anders Carlsson2010-02-041-1/+9
| | | | | | | | | | | | | 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
* Fix a bug where we would not mark temporaries as conditional when emitting a ↵Anders Carlsson2010-02-041-1/+7
| | | | | | conditional operator as an lvalue. llvm-svn: 95311
* Revert the new reference binding code; I came up with a way simpler solution ↵Anders Carlsson2010-02-031-25/+0
| | | | | | for the reference binding bug that is preventing self-hosting. llvm-svn: 95223
* Move pointer to data member emission to CodeGenModule and use it in ↵Anders Carlsson2010-02-021-16/+5
| | | | | | CGExprConstant. Fixes PR5674. llvm-svn: 95063
* Start creating CXXBindReferenceExpr nodes when binding complex types to ↵Anders Carlsson2010-01-311-0/+22
| | | | | | references. llvm-svn: 94964
OpenPOWER on IntegriCloud