summaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGExpr.cpp
AgeCommit message (Collapse)Author
2010-05-21Rename CodeGenFunction::EmitMemSetToZero to EmitNullInitialization. Handle ↵Anders Carlsson
setting null data member pointers correctly. Fixes PR7139. llvm-svn: 104387
2010-05-21When emitting an lvalue for an anonymous struct or union member duringJohn McCall
class initialization, drill down through an arbitrary number of anonymous records. llvm-svn: 104310
2010-05-20Rework our handling of binding a reference to a temporaryDouglas Gregor
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
2010-05-15Substantially alter the design of the Objective C type AST by introducingJohn McCall
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
2010-05-11Minor refactoring of my last patch.Fariborz Jahanian
llvm-svn: 103475
2010-05-10Objective-C++ Code gen. Handle code gen. for propertyFariborz Jahanian
reference dot-syntax notation in a varierty of cases. Fixes radar 7964490. llvm-svn: 103440
2010-05-02Add the same 'ForVirtualBase' parameter to EmitCXXDestructorCall.Anders Carlsson
llvm-svn: 102882
2010-04-24Change CodeGenFunction::GetAddressOfDerivedClass to take a BasePath.Anders Carlsson
llvm-svn: 102273
2010-04-24Convert more call sites over to the new GetAddressOfBaseClass.Anders Carlsson
llvm-svn: 102272
2010-04-23Handle compound assignment expressions (i += j) as lvalues, which isDouglas Gregor
permitted in C++ but not in C. Fixes PR6900. Clang can now handle all of Boost.Lambda's regression tests. llvm-svn: 102170
2010-04-22Call PerformCopyInitialization to properly initialize the exception temporaryJohn McCall
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
2010-04-21Miscellaneous codegen cleanups. Mostly, don't create new basic blocksJohn McCall
just to save the current insertion state! This change significantly simplifies the IR CFG in exceptions code. llvm-svn: 101996
2010-04-19Some renaming of methods, fixes typoFariborz Jahanian
(related to PR6769). llvm-svn: 101794
2010-04-18Local static variables must be available module-wiseFariborz Jahanian
as they are accessible in static methods in a class local to the same function. Fixes PR6769. llvm-svn: 101756
2010-04-17Fix an assert when assigning a boolean value to a bitfield of type _Bool.Anders Carlsson
llvm-svn: 101678
2010-04-15IRgen: (Reapply 101222, with fixes) Move EmitStoreThroughBitfieldLValue to ↵Daniel Dunbar
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
2010-04-14Speculatively revert "IRgen: Move EmitStoreThroughBitfieldLValue to use new ↵Daniel Dunbar
CGBitfieldInfo::AccessInfo decomposition, instead of computing the access policy itself.", I think it might be breaking bootstrap. llvm-svn: 101235
2010-04-14IRgen: Move EmitStoreThroughBitfieldLValue to use new ↵Daniel Dunbar
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
2010-04-13IRgen: Move EmitLoadOfBitfieldLValue to use new CGBitfieldInfo::AccessInfo ↵Daniel Dunbar
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
2010-04-10fix PR6805: llvm.objectsize changed to take an i1 instead of an i32.Chris Lattner
llvm-svn: 100938
2010-04-08IRgen: Move the bit-field access type into CGBitFieldInfo, and change ↵Daniel Dunbar
bit-field LValues to just store the base address of object containing the bit-field. llvm-svn: 100745
2010-04-06IRgen: Move BitFieldIsSigned bit into CGBitFieldInfo.Daniel Dunbar
llvm-svn: 100513
2010-04-06Simplify.Daniel Dunbar
llvm-svn: 100511
2010-04-05IRgen: Move BitField LValues to just hold a reference to the CGBitFieldInfo.Daniel Dunbar
- 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
2010-04-05IRgen: Lift BitFieldInfo to CGBitFieldInfo at namespace level.Daniel Dunbar
llvm-svn: 100433
2010-03-31IRGen: Move the auxiliary data structures tracking AST -> LLVM mappings out ↵Daniel Dunbar
of CodeGenTypes, to per-record CGRecordLayout structures. - I did a cursory check that this was perf neutral, FWIW. llvm-svn: 99978
2010-03-30Introduce a new kind of derived-to-base cast which bypasses the need forJohn McCall
null checks, and make sure we elide null checks when accessing base class members. llvm-svn: 99963
2010-03-30Minor formatting/FIXME cleanups.Daniel Dunbar
llvm-svn: 99944
2010-03-04Fix PR6473.Rafael Espindola
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
2010-02-16IRgen: Add CreateIRTemp, which creates a temporary alloca but with type ↵Daniel Dunbar
converted "not-for-memory". Dunno a better name. llvm-svn: 96374
2010-02-16IRgen: Switch EmitCompoundLiteralLValue to use CreateMemTemp.Daniel Dunbar
llvm-svn: 96373
2010-02-15When emitting an aggregate into a temporary, make sure we set the alignmentJohn McCall
on the alloca. The fact that codegen makes this class of bug so wonderfully easy to make is embarrassing. llvm-svn: 96204
2010-02-11More vtable layout dumper improvements. Handle destructors, dump the ↵Anders Carlsson
complete function type of the member functions (using PredefinedExpr::ComputeName. llvm-svn: 95887
2010-02-09IRgen: Add CreateMemTemp, for creating an temporary memory object for a ↵Daniel Dunbar
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
2010-02-08Reapply r95393, without the change to CGExpr. I was wrong in assuming that theDaniel Dunbar
element type always matched the converted LLVM type for ExprType. llvm-svn: 95596
2010-02-05Standardize the parsing of function type attributes in a way thatJohn McCall
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
2010-02-05Revert r95393, which broke Clang's self-host.Douglas Gregor
llvm-svn: 95430
2010-02-05IRgen: A few more ConvertType cleanups.Daniel Dunbar
llvm-svn: 95423
2010-02-05IRgen: Factor out EmitAggExprToLValue.Daniel Dunbar
llvm-svn: 95416
2010-02-05IRgen: Fix some CreateTempAlloca calls to use ConvertTypeForMem when that isDaniel Dunbar
conceptually correct. Review appreciated (Chris, Eli, Anders). llvm-svn: 95401
2010-02-05Now that we store calling conventions in the types, use them instead ofCharles Davis
getting the calling convention from the target function, which may or may not exist. Fixes PR5280. llvm-svn: 95399
2010-02-05IRgen: Use hasAggregateLLVMType instead of isSingleValueType() for cases thatDaniel Dunbar
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
2010-02-04When binding an lvalue to a reference, we always need to pop temporaries.Anders Carlsson
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-04Fix a bug where we would not mark temporaries as conditional when emitting a ↵Anders Carlsson
conditional operator as an lvalue. llvm-svn: 95311
2010-02-03Revert the new reference binding code; I came up with a way simpler solution ↵Anders Carlsson
for the reference binding bug that is preventing self-hosting. llvm-svn: 95223
2010-02-02Move pointer to data member emission to CodeGenModule and use it in ↵Anders Carlsson
CGExprConstant. Fixes PR5674. llvm-svn: 95063
2010-01-31Start creating CXXBindReferenceExpr nodes when binding complex types to ↵Anders Carlsson
references. llvm-svn: 94964
2010-01-29Add a new EmitLValueForFieldInitialization that will be used for ↵Anders Carlsson
initializing fields (and reference type fields in particular). llvm-svn: 94799
2010-01-29Simplify EmitLValueForField - we can get whether the field is part of a ↵Anders Carlsson
union or not from the FieldDecl (through its DeclContext). llvm-svn: 94798
2010-01-29Add an CXXBindReferenceExpr (not used just yet).Anders Carlsson
llvm-svn: 94791