summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Handle constructors and destructors a bit more uniformly in CodeGen.Rafael Espindola2014-09-081-4/+4
| | | | | | | | | There were code paths that are duplicated for constructors and destructors just because we have both CXXCtorType and CXXDtorsTypes. This patch introduces an unified enum and reduces code deplication a bit. llvm-svn: 217383
* Reverting r216675. This breaks some bots. Before this can be committed ↵Aaron Ballman2014-08-281-7/+7
| | | | | | again, I have to explore runtime ABI requirements with libc++abi. llvm-svn: 216677
* Throw a std::bad_array_new_length exception when the expression (or ↵Aaron Ballman2014-08-281-7/+7
| | | | | | constant-expression) passed to operator new[] results in overflow in conformance with [expr.new]p7. Fixes PR11644. llvm-svn: 216675
* [C++11] Support for capturing of variable length arrays in lambda expression.Alexey Bataev2014-08-281-7/+11
| | | | | | Differential Revision: http://reviews.llvm.org/D4368 llvm-svn: 216649
* Kill one of EmitCallArgs overloads. NFC.Alexey Samsonov2014-08-281-5/+3
| | | | llvm-svn: 216635
* Pass actual CXXConstructExpr instead of argument iteratorsAlexey Samsonov2014-08-251-5/+5
| | | | | | into EmitSynthesizedCXXCopyCtorCall. No functionality change. llvm-svn: 216410
* Pass actual CallExpr instead of CallExpr-specific iteratorsAlexey Samsonov2014-08-251-23/+33
| | | | | | | | | | | into EmitCXXMemberOrOperatorCall methods. In the end we want to make declaration visible in EmitCallArgs() method, that would allow us to alter CodeGen depending on function/parameter attributes. No functionality change. llvm-svn: 216404
* Pass expressions instead of argument ranges to EmitCall/EmitCXXConstructorCall.Alexey Samsonov2014-08-211-8/+5
| | | | | | | | | | | | | | | | | | | | | | | Summary: This is a first small step towards passing generic "Expr" instead of ArgBeg/ArgEnd pair into EmitCallArgs() family of methods. Having "Expr" will allow us to get the corresponding FunctionDecl and its ParmVarDecls, thus allowing us to alter CodeGen depending on the function/parameter attributes. No functionality change. Test Plan: regression test suite Reviewers: rnk Reviewed By: rnk Subscribers: aemerson, cfe-commits Differential Revision: http://reviews.llvm.org/D4915 llvm-svn: 216214
* CodeGen: Properly null-check typeid expressionsDavid Majnemer2014-07-191-6/+38
| | | | | | | | | | | | Thoroughly check for a pointer dereference which yields a glvalue. Look through casts, comma operators, conditional operators, paren expressions, etc. This was originally D4416. Differential Revision: http://reviews.llvm.org/D4592 llvm-svn: 213434
* Revert "CodeGen: Properly null-check typeid expressions"David Majnemer2014-07-181-35/+6
| | | | | | | | | This reverts commit r213401, r213402, r213403, and r213404. I accidently committed these changes instead of updating the differential. llvm-svn: 213405
* Address Richard's latest feedback.David Majnemer2014-07-181-8/+7
| | | | llvm-svn: 213404
* Address Richard's commentsDavid Majnemer2014-07-181-7/+15
| | | | llvm-svn: 213403
* Address Richard's comments.David Majnemer2014-07-181-0/+3
| | | | llvm-svn: 213402
* CodeGen: Properly null-check typeid expressionsDavid Majnemer2014-07-181-6/+25
| | | | | | | | | | | | | | | Summary: Thoroughly check for a pointer dereference which yields a glvalue. Look through casts, comma operators, conditional operators, paren expressions, etc. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4416 llvm-svn: 213401
* Revert "Revert r211402 (and r211408,r211410), "CodeGen: Refactor ↵David Majnemer2014-06-221-366/+52
| | | | | | | | | dynamic_cast and typeid" It crashes msvc codegen in clang/test/SemaCXX/undefined-internal.cpp." This reverts commit r211467 which reverted r211408,r211410, it caused crashes in test/SemaCXX/undefined-internal.cpp for i686-win32 targets. llvm-svn: 211473
* Revert r211402 (and r211408,r211410), "CodeGen: Refactor dynamic_cast and ↵NAKAMURA Takumi2014-06-221-52/+366
| | | | | | | | | | typeid" It crashes msvc codegen in clang/test/SemaCXX/undefined-internal.cpp. It is reproducible with: $ clang -cc1 -triple i686-win32 -emit-llvm-only clang/test/SemaCXX/undefined-internal.cpp llvm-svn: 211467
* CodeGen: Refactor dynamic_cast and typeidDavid Majnemer2014-06-201-366/+52
| | | | | | | | | | | This refactors the emission of dynamic_cast and typeid expressions so that ABI specific knowledge lives in appropriate places. There are quite a few benefits for having the two implementations share a common core like sharing logic for optimization opportunities. While we are at it, clean up the tests. llvm-svn: 211402
* [MS-ABI] Implement typeidWarren Hunt2014-06-181-2/+35
| | | | | | | This patch enables clang to generate calls to __RTtypeid when lowering typeid on win32 targets. Test cases are included. llvm-svn: 211223
* Fix typosAlp Toker2014-06-161-1/+1
| | | | llvm-svn: 211025
* [MS-ABI] Implement dynamic_castWarren Hunt2014-06-061-4/+135
| | | | | | | | | | This patch implements call lower from dynamic_cast to __RTDynamicCast and __RTCastToVoid. Test cases are included. A feature of note is that helper function getPolymorphicOffset is placed in such a way that it can be used by EmitTypeid (to be implemented in a later patch) without being moved. Details are included as comments directly in the code. llvm-svn: 210377
* Bugfix: don't assert if someone manages to declare an operator new/delete ↵Richard Smith2014-06-051-2/+3
| | | | | | template before the builtin operator new/delete. llvm-svn: 210230
* Add __builtin_operator_new and __builtin_operator_delete, which act like callsRichard Smith2014-06-031-0/+17
| | | | | | | to the normal non-placement ::operator new and ::operator delete, but allow optimizations like new-expressions and delete-expressions do. llvm-svn: 210137
* Implement DR990 and DR1070. Aggregate initialization initializes uninitializedRichard Smith2014-06-031-11/+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
* When emitting a multidimensional array new, emit the initializers for theRichard Smith2014-06-031-136/+171
| | | | | | | | | trailing elements as a single loop, rather than sometimes emitting a nest of several loops. This fixes a bug where CodeGen would sometimes try to emit an expression with the wrong type for the element being initialized. Plus various other minor cleanups to the IR produced for array new initialization. llvm-svn: 210079
* [C++11] Use 'nullptr'. CodeGen edition.Craig Topper2014-05-211-27/+27
| | | | llvm-svn: 209272
* [leaks] Re-shuffle code such that we don't create a basic block forChandler Carruth2014-05-031-9/+11
| | | | | | | | | | initializing an array unless we need it. Specifically, position the creation of a new basic block after we've checked all of the cases that bypass the need for it. Fixes another leak in test/CodeGen* found by LSan. llvm-svn: 207900
* Fix PR19104: Incorrect handling of non-virtual calls of virtual methodsTimur Iskhodzhanov2014-03-141-2/+4
| | | | | | Reviewed at http://llvm-reviews.chandlerc.com/D3054 llvm-svn: 203949
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-4/+4
| | | | | | class. llvm-svn: 203643
* [Modules] Update to reflect the move of CallSite into the IR library inChandler Carruth2014-03-041-1/+1
| | | | | | LLVM r202816. llvm-svn: 202817
* Sema: Do not assert when dereferencing member pointer using virtual ↵David Majnemer2014-02-201-1/+1
| | | | | | | | | | | | | | inheritance with an incomplete class type The MS ABI requires that we determine the vbptr offset if have a virtual inheritance model. Instead, raise an error pointing to the diagnostic when this happens. This fixes PR18583. Differential Revision: http://llvm-reviews.chandlerc.com/D2842 llvm-svn: 201824
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-2/+2
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-18/+18
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
* [ms-abi] Refactor Microsoft Record LayoutWarren Hunt2014-01-091-1/+1
| | | | | | | | | This patch refactors microsoft record layout to be more "natural". The most dominant change is that vbptrs and vfptrs are injected after the fact. This simplifies the implementation and the math for the offest for the first base/field after the vbptr. llvm-svn: 198818
* Quick-Fix pointer arithmetic when performing multi-D new-array initialization.Faisal Vali2013-12-141-3/+23
| | | | | | | | | | | | | | | | | | clang still doesn't emit the right llvm code when initializing multi-D arrays it seems. For e.g. the following code would still crash for me on Windows 7, 64 bit: auto f4 = new int[100][200][300]{{{1,2,3}, {4, 5, 6}}, {{10, 20, 30}}}; It seems that the final new loop that iterates through each outermost array and memsets it to zero gets confused with its final ptr arithmetic. This patch ensures that it converts the pointer to the allocated type (int [200][300]) before incrementing it (instead of using the base type: 'int'). Richard somewhat squeamishly approved the patch (as a quick fix to potentially make it into 3.4) - while exhorting for a more optimized fix in the future. http://llvm-reviews.chandlerc.com/D2398 Thanks Richard! llvm-svn: 197294
* When performing an array new of a multidimensional array with an initializerRichard Smith2013-12-111-3/+19
| | | | | | | | list, each element of the initializer list may provide more than one of the base elements of the array. Be sure to initialize the right type and bump the array pointer by the right amount. llvm-svn: 196995
* [ms-cxxabi] Construct and destroy call arguments in the correct orderReid Kleckner2013-12-041-27/+4
| | | | | | | | | | | | | | | | | | | Summary: MSVC destroys arguments in the callee from left to right. Because C++ objects have to be destroyed in the reverse order of construction, Clang has to construct arguments from right to left and destroy arguments from left to right. This patch fixes the ordering by reversing the order of evaluation of all call arguments under the MS C++ ABI. Fixes PR18035. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D2275 llvm-svn: 196402
* Add CodeGenABITypes.h for use in LLDB.Mark Lacey2013-10-301-0/+1
| | | | | | | | | | | | | | | | | | CodeGenABITypes is a wrapper built on top of CodeGenModule that exposes some of the functionality of CodeGenTypes (held by CodeGenModule), specifically methods that determine the LLVM types appropriate for function argument and return values. I addition to CodeGenABITypes.h, CGFunctionInfo.h is introduced, and the definitions of ABIArgInfo, RequiredArgs, and CGFunctionInfo are moved into this new header from the private headers ABIInfo.h and CGCall.h. Exposing this functionality is one part of making it possible for LLDB to determine the actual ABI locations of function arguments and return values, making it possible for it to determine this for any supported target without hard-coding ABI knowledge in the LLDB code. llvm-svn: 193717
* Revert "This patch causes clang to reject alias attributes that point to ↵Rafael Espindola2013-10-221-1/+2
| | | | | | | | | | | | | | | | undefined names. For example, with this patch we now reject" This reverts commit r193161. It broke void foo() __attribute__((alias("bar"))); void bar() {} void zed() __attribute__((alias("foo"))); Looks like we have to fix pr17639 first :-( llvm-svn: 193162
* This patch causes clang to reject alias attributes that point to undefinedRafael Espindola2013-10-221-2/+1
| | | | | | | | | | | | names. For example, with this patch we now reject void f1(void) __attribute__((alias("g1"))); This patch is implemented in CodeGen. It is quiet a bit simpler and more compatible with gcc than implementing it in Sema. The downside is that the errors only fire during -emit-llvm. llvm-svn: 193161
* Implement function type checker for the undefined behavior sanitizer.Peter Collingbourne2013-10-201-1/+2
| | | | | | | | | This uses function prefix data to store function type information at the function pointer. Differential Revision: http://llvm-reviews.chandlerc.com/D1338 llvm-svn: 193058
* No functionality change. Reflow lines that could fit on one line. Break linesNick Lewycky2013-10-011-4/+3
| | | | | | that had 80-column violations. Remove spurious emacs mode markers on .cpp files. llvm-svn: 191797
* AST: Handle qualified array types in typeid() expressionsDavid Majnemer2013-09-271-2/+2
| | | | | | | | | | | | The intent of getTypeOperand() was to yield an unqualified type. However QualType::getUnqualifiedType() does not strip away qualifiers on arrays. N.B. This worked fine when typeid() was applied to an expression because we would inject as implicit cast to the unqualified array type in the AST. llvm-svn: 191487
* CodeGen: Unify two implementations of canDevirtualizeMemberFunctionCall.Benjamin Kramer2013-08-251-95/+1
| | | | | | | | | They were mostly copy&paste of each other, move it to CodeGenFunction. Of course the two implementations have diverged over time; the one in CGExprCXX seems to be the more modern one so I picked that one and moved it to CGClass which feels like a better home for it. No intended functionality change. llvm-svn: 189203
* Abstract out virtual calls and virtual function prologue code generation; ↵Timur Iskhodzhanov2013-08-211-1/+4
| | | | | | implement them for -cxx-abi microsoft llvm-svn: 188870
* PR16715: Fix assert in verifier: only mark call to 'operator new' as ↵Richard Smith2013-07-291-2/+5
| | | | | | | | 'builtin' if corresponding 'operator new' was actually emitted as a function marked 'nobuiltin'. llvm-svn: 187374
* [ms-cxxabi] Emit linkonce complete dtors in TUs that need themReid Kleckner2013-07-221-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on Peter Collingbourne's destructor patches. Prior to this change, clang was considering ?1 to be the complete destructor and the base destructor, which was wrong. This lead to crashes when clang tried to emit two LLVM functions with the same name. In this ABI, TUs with non-inline dtors might not emit a complete destructor. They are emitted as inline thunks in TUs that need them, and they always delegate to the base dtors of the complete class and its virtual bases. This change uses the DeferredDecls machinery to emit complete dtors as needed. Currently in clang try body destructors can catch exceptions thrown by virtual base destructors. In the Microsoft C++ ABI, clang may not have the destructor definition, in which case clang won't wrap the virtual virtual base destructor calls in a try-catch. Diagnosing this in user code is TODO. Finally, for classes that don't use virtual inheritance, MSVC always calls the base destructor (?1) directly. This is a useful code size optimization that avoids emitting lots of extra thunks or aliases. Implementing it also means our existing tests continue to pass, and is consistent with MSVC's output. We can do the same for Itanium by tweaking GetAddrOfCXXDestructor, but it will require further testing. Reviewers: rjmccall CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1066 llvm-svn: 186828
* Tighten up the set of operator new/operator delete calls we're permitted toRichard Smith2013-07-211-16/+37
| | | | | | | | | optimize, to follow the permissions granted in N3664. Under those rules, only calls generated by new-expressions and delete-expressions are permitted to be optimized, and direct calls to ::operator new and ::operator delete must be treated as normal calls. llvm-svn: 186799
* PR16214, PR14467: DebugInfo: use "RequireCompleteType" to decide when to ↵David Blaikie2013-07-131-11/+0
| | | | | | | | | | | | | | | emit the full definition of a type in -flimit-debug-info This simplifies the core benefit of -flimit-debug-info by taking a more systematic approach to avoid emitting debug info definitions for types that only require declarations. The previous ad-hoc approach (3 cases removed in this patch) had many holes. The general approach (adding a bit to TagDecl and callback through ASTConsumer) has been discussed with Richard Smith - though always open to revision. llvm-svn: 186262
* Restore r184205 and associated commits (after commit of r185290)Stephen Lin2013-06-301-12/+14
| | | | | | This allows clang to use the backend parameter attribute 'returned' when generating 'this'-returning constructors and destructors in ARM and MSVC C++ ABIs. llvm-svn: 185291
* Revert r184205 and associated patches while investigating issue with broken ↵Stephen Lin2013-06-191-14/+12
| | | | | | | | buildbot (possible interaction with LTO) <rdar://problem/14209661> llvm-svn: 184384
OpenPOWER on IntegriCloud