summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Extract a method to check whether a function is the global placementJohn McCall2010-08-231-10/+21
| | | | | | operator new[]. llvm-svn: 111788
* Go back to asking CodeGenTypes whether a type is zero-initializable.John McCall2010-08-221-2/+1
| | | | | | | | | Make CGT defer to the ABI on all member pointer types. This requires giving CGT a handle to the ABI. It's way easier to make that work if we avoid lazily creating the ABI. Make it so. llvm-svn: 111786
* When performing value-initialization for a class with a non-trivial,Douglas Gregor2010-08-221-19/+15
| | | | | | | | | | | | implicitly-defined default constructor, zero-initialize the memory before calling the default constructor. Previously, we would only zero-initialize in the case of a trivial default constructor. Also, simplify the hideous logic that determines when we have a trivial default constructor and, therefore, don't need to emit any call at all. llvm-svn: 111779
* Experiment with using first-class aggregates to represent member functionJohn McCall2010-08-221-2/+1
| | | | | | | | | | pointers. I find the resulting code to be substantially cleaner, and it makes it very easy to use the same APIs for data member pointers (which I have conscientiously avoided here), and it avoids a plethora of potential inefficiencies due to excessive memory copying, but we'll have to see if it actually works. llvm-svn: 111776
* Abstract more member-pointerness out.John McCall2010-08-221-1/+1
| | | | llvm-svn: 111771
* Extract calls to method pointers out as an ABI routine.John McCall2010-08-221-65/+4
| | | | | | No functionality change. llvm-svn: 111752
* IRgen: Change Emit{Load,Store}OfScalar to take a required Alignment argument andDaniel Dunbar2010-08-211-2/+5
| | | | | | | | update callers as best I can. - This is a work in progress, our alignment handling is very horrible / sketchy -- I am just aiming for monotonic improvement. - Serious review appreciated. llvm-svn: 111707
* Fix a major regression with value-initialization of class types withDouglas Gregor2010-08-201-1/+7
| | | | | | | | trivial default constructors. We're weren't zero-initializing them, which manifested as <rdar://problem/8320532> (a regression in the GCC test suite) and is likely to have caused significant other breakage. llvm-svn: 111650
* Implement zero-initialization for array new when there is anDouglas Gregor2010-07-211-13/+61
| | | | | | | | | initializer of (). Make sure to use a simple memset() when we can, or fall back to generating a loop when a simple memset will not suffice. Fixes <rdar://problem/8212208>, a regression due to my work in r107857. llvm-svn: 108977
* in 'new int[4]', constant fold the 4*4=16 instead of Chris Lattner2010-07-201-34/+56
| | | | | | doing an overflow check. llvm-svn: 108943
* Follow the implementation approach suggested by PR6687,Chris Lattner2010-07-201-5/+16
| | | | | | | | | | | | | | | | | | | | | | which generates more efficient and more obviously conformant code. We now test for overflow of the multiply then force the result to -1 if so. On X86, this generates nice code like this: __Z4testl: ## @_Z4testl ## BB#0: ## %entry subl $12, %esp movl $4, %eax mull 16(%esp) testl %edx, %edx movl $-1, %ecx cmovel %eax, %ecx movl %ecx, (%esp) call __Znam addl $12, %esp ret llvm-svn: 108927
* implement rdar://5739832 - operator new should check for overflow in multiply,Chris Lattner2010-07-201-5/+21
| | | | | | | | | | | | | | | | | | | | causing clang to compile this code into something that correctly throws a length error, fixing a potential integer overflow security attack: void *test(long N) { return new int[N]; } int main() { test(1L << 62); } We do this even when exceptions are disabled, because it is better for the code to abort than for the attack to succeed. This is heavily based on a patch that Fariborz wrote. llvm-svn: 108915
* delete a loop that just generates dead code. In an exampleChris Lattner2010-07-201-10/+0
| | | | | | | | | | | | | | | | | | | | like this: void *test(long N) { return new int[N][42][42]; } the loop generates two dead mul instructions: %tmp = load i64* %N.addr ; <i64> [#uses=2] %0 = mul i64 %tmp, 7056 ; <i64> [#uses=1] %1 = mul i64 %tmp, 42 ; <i64> [#uses=1] %2 = mul i64 %1, 42 ; <i64> [#uses=0] %call = call noalias i8* @_Znam(i64 %0) ; <i8*> [#uses=1] The scale of these multiplies is already handled by the typesize stuff. llvm-svn: 108884
* remove the special case for constant array sizes from Chris Lattner2010-07-201-24/+2
| | | | | | | EmitCXXNewAllocSize. This code uses IRBuilder, which does constant folding already. llvm-svn: 108882
* Reinstate the fix for PR7556. A silly use of isTrivial() wasDouglas Gregor2010-07-081-0/+8
| | | | | | 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-12/+3
| | | | | | breaking bootstrap on Linux. llvm-svn: 107837
* Do not use CXXZeroValueInitExpr for class types. Instead, useDouglas Gregor2010-07-071-3/+12
| | | | | | | | | 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
* Remove unnecessary ASTContext parameter fromDouglas Gregor2010-07-011-1/+1
| | | | | | CXXRecordDecl::getDestructor(); no functionality change. llvm-svn: 107394
* Minor change to my last patch to fix PR7490.Fariborz Jahanian2010-06-251-4/+8
| | | | llvm-svn: 106875
* IRGen for trivial initialization of dynamiccaly allocatedFariborz Jahanian2010-06-251-19/+77
| | | | | | array of other done c++ objects. Fixes PR7490. llvm-svn: 106869
* Patch adds support for copying of thoseFariborz Jahanian2010-06-151-4/+1
| | | | | | | | objective-c++ class objects which have GC'able objc object pointers and need to use ObjC's objc_memmove_collectable API (radar 8070772). llvm-svn: 106061
* Adds support for generation of objc_memmove_collectable APIFariborz Jahanian2010-05-201-1/+5
| | | | | | in Objective-C++ mode. llvm-svn: 104281
* Copy construction of non-trivial properties must notFariborz Jahanian2010-05-201-6/+3
| | | | | | be turned into a setter call (fixes radar 8008649). llvm-svn: 104235
* Minor twik to my last patch. (for radar 7986354).Fariborz Jahanian2010-05-161-2/+2
| | | | llvm-svn: 103889
* Fix API gen for objc_msgSend property of aggregate typesFariborz Jahanian2010-05-151-6/+10
| | | | | | in Objective-c++ mode. Fixes radar 7986354. llvm-svn: 103887
* Recognize when the named return value optimization applies in aDouglas Gregor2010-05-151-4/+6
| | | | | | | | | | "return" statement and mark the corresponding CXXConstructExpr as elidable. Teach CodeGen that eliding a temporary is different from eliding an object construction. This is just a baby step toward NRVO. llvm-svn: 103849
* When a failed dynamic_cast<T&> (which is an lvalue) results in aDouglas Gregor2010-05-141-3/+11
| | | | | | | | throw, it should use invoke when needed. The fixes the Boost.Statechrt failures that motivated PR7132, but there are a few side issues to tackle as well. llvm-svn: 103803
* 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
* Minor mod. to my last patch.Fariborz Jahanian2010-05-071-1/+2
| | | | llvm-svn: 103280
* Fixes a Code gen crash trying to use a dot-syntax forFariborz Jahanian2010-05-071-2/+8
| | | | | | a property of a c++ class object (radar 7957369). llvm-svn: 103279
* Don't build an aggregate constructor loop when the constructor is trivial.Anders Carlsson2010-05-031-5/+7
| | | | llvm-svn: 102912
* Add the same 'ForVirtualBase' parameter to EmitCXXDestructorCall.Anders Carlsson2010-05-021-1/+2
| | | | llvm-svn: 102882
* Revert my last change and add a 'ForVirtualBase' parameter to ↵Anders Carlsson2010-05-021-4/+11
| | | | | | EmitCXXConstructorCall instead. llvm-svn: 102881
* Pass the construction kind down to EmitCXXConstructorCall.Anders Carlsson2010-05-021-4/+2
| | | | llvm-svn: 102880
* Simplify EmitClassAggrMemberwiseCopy.Anders Carlsson2010-05-011-1/+1
| | | | llvm-svn: 102848
* Vtable -> VTable renames across the board.Anders Carlsson2010-04-171-8/+8
| | | | llvm-svn: 101666
* Rework our handling of copy construction of temporaries, which was aDouglas Gregor2010-04-021-17/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | poor (and wrong) approximation of the actual rules governing when to build a copy and when it can be elided. The correct implementation is actually simpler than the approximation. When we only enumerate constructors as part of initialization (e.g., for direct initialization or when we're copying from a class type or one of its derived classes), we don't create a copy. When we enumerate all conversion functions, we do create a copy. Before, we created some extra copies and missed some others. The new test copy-initialization.cpp shows a case where we missed creating a (required, non-elidable) copy as part of a user-defined conversion, which resulted in a miscompile. This commit also fixes PR6757, where the missing copy made us reject well-formed code in the ternary operator. This commit also cleans up our handling of copy elision in the case where we create an extra copy of a temporary object, which became necessary now that we produce the right copies. The code that seeks to find the temporary object being copied has moved into Expr::getTemporaryObject(); it used to have two different not-quite-the-same implementations, one in Sema and one in CodeGen. Note that we still do not attempt to perform the named return value optimization, so we miss copy elisions for return values and throw expressions. llvm-svn: 100196
* the big refactoring bits of PR3782.Rafael Espindola2010-03-301-3/+2
| | | | | | | | This introduces FunctionType::ExtInfo to hold the calling convention and the noreturn attribute. The next patch will extend it to include the regparm attribute and fix the bug. llvm-svn: 99920
* Code gen for multi-dimensional dynamic allocations.Fariborz Jahanian2010-03-241-6/+37
| | | | | | Fixes PR6641. llvm-svn: 99404
* IRgen: Add CreateMemTemp, for creating an temporary memory object for a ↵Daniel Dunbar2010-02-091-2/+1
| | | | | | | | | | 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
* Standardize the parsing of function type attributes in a way thatJohn McCall2010-02-051-7/+8
| | | | | | | | | | | | 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
* IRgen: Fix some CreateTempAlloca calls to use ConvertTypeForMem when that isDaniel Dunbar2010-02-051-1/+1
| | | | | | conceptually correct. Review appreciated (Chris, Eli, Anders). llvm-svn: 95401
* Fix another pointer-to-member function miscompile, this time when trying to ↵Anders Carlsson2010-02-041-11/+11
| | | | | | call a virtual member function. llvm-svn: 95307
* Provide a real fix for PR6199, reverting the old workaround. Here, weDouglas Gregor2010-02-031-3/+1
| | | | | | | | realize that CXXConstructExpr is always implicit, so we should just return its argument (if there is only one) rather than directly invoking the constructor. llvm-svn: 95192
* Check in a test case and a nasty workaround for PR6199.Anders Carlsson2010-02-021-1/+3
| | | | llvm-svn: 95076
* Switch expressions like T() and T(1,2) over to new-style initialization. I'mEli Friedman2010-01-311-1/+1
| | | | | | | not quite sure what we want to do about the AST representation; comments welcome. llvm-svn: 94967
* Rework base and member initialization in constructors, with severalDouglas Gregor2010-01-311-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (necessarily simultaneous) changes: - CXXBaseOrMemberInitializer now contains only a single initializer rather than a set of initialiation arguments + a constructor. The single initializer covers all aspects of initialization, including constructor calls as necessary but also cleanup of temporaries created by the initializer (which we never handled before!). - Rework + simplify code generation for CXXBaseOrMemberInitializers, since we can now just emit the initializer as an initializer. - Switched base and member initialization over to the new initialization code (InitializationSequence), so that it - Improved diagnostics for the new initialization code when initializing bases and members, to match the diagnostics produced by the previous (special-purpose) code. - Simplify the representation of type-checked constructor initializers in templates; instead of keeping the fully-type-checked AST, which is rather hard to undo at template instantiation time, throw away the type-checked AST and store the raw expressions in the AST. This simplifies instantiation, but loses a little but of information in the AST. - When type-checking implicit base or member initializers within a dependent context, don't add the generated initializers into the AST, because they'll look like they were explicit. - Record in CXXConstructExpr when the constructor call is to initialize a base class, so that CodeGen does not have to infer it from context. This ensures that we call the right kind of constructor. There are also a few "opportunity" fixes here that were needed to not regress, for example: - Diagnose default-initialization of a const-qualified class that does not have a user-declared default constructor. We had this diagnostic specifically for bases and members, but missed it for variables. That's fixed now. - When defining the implicit constructors, destructor, and copy-assignment operator, set the CurContext to that constructor when we're defining the body. llvm-svn: 94952
* Convert one last size variable to CharUnits (follow-on to 94577).Ken Dyck2010-01-261-2/+3
| | | | llvm-svn: 94579
* Use CharUnits for sizes, offsets, alignments, and padding amounts for valuesKen Dyck2010-01-261-35/+39
| | | | | | that are in character units. llvm-svn: 94577
* Correctly pass VTT parameters to constructors and destructors. The VTTs ↵Anders Carlsson2010-01-021-3/+11
| | | | | | aren't yet used in the ctors/dtors, but that will follow. llvm-svn: 92409
OpenPOWER on IntegriCloud