summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Handle the resolution of a reference to a function template (whichDouglas Gregor2011-02-191-200/+341
| | | | | | | | includes explicitly-specified template arguments) to a function template specialization in cases where no deduction is performed or deduction fails. Patch by Faisal Vali, fixes PR7505! llvm-svn: 126048
* Use hasSameType in one more, hopefully, last place.Fariborz Jahanian2011-02-131-2/+2
| | | | llvm-svn: 125468
* Some refactoring and using more modern APIs forFariborz Jahanian2011-02-131-57/+56
| | | | | | | implementation of co/contra-variance objc++ block pointers. // rdar://8979379. llvm-svn: 125467
* Implement objective-c++'s block pointer type matching involvingFariborz Jahanian2011-02-121-0/+88
| | | | | | | types which are contravariance in argument types and covariance in return types. // rdar://8979379. llvm-svn: 125445
* AST, Sema, Serialization: add CUDAKernelCallExpr and related semantic actionsPeter Collingbourne2011-02-091-3/+4
| | | | llvm-svn: 125217
* Basic implementation of inherited constructors. Only generates declarations, ↵Sebastian Redl2011-02-051-1/+32
| | | | | | and probably only works for very basic use cases. llvm-svn: 124970
* Implement reasonable conversion ranking for Objective-C pointerDouglas Gregor2011-01-311-22/+70
| | | | | | | | | | | | | | | | | | | | | | | | conversions (<rdar://problem/8592139>) for overload resolution. The conversion ranking mirrors C++'s conversion ranking fairly closely, except that we use a same pseudo-subtyping relationship employed by Objective-C pointer assignment rather than simple checking derived-to-base conversions. This change covers: - Conversions to pointers to a specific object type are better than conversions to 'id', 'Class', qualified 'id', or qualified 'Class' (note: GCC doesn't perform this ranking, but it matches C++'s rules for ranking conversions to void*). - Conversions to qualified 'id' or qualified 'Class' are better than conversions to 'id' or 'Class', respectively. - When two conversion sequences convert to the same type, rank the conversions based on the relationship between the types we're converting from. - When two conversion sequences convert from the same non-id, non-Class type, rank the conversions based on the relationship of the types we're converting to. (note: GCC allows this ranking even when converting from 'id', which is extremeley dangerous). llvm-svn: 124591
* Fix whitespace.NAKAMURA Takumi2011-01-271-321/+321
| | | | llvm-svn: 124364
* 7bit-ize.NAKAMURA Takumi2011-01-271-4/+4
| | | | llvm-svn: 124363
* Fix a horrible bug in our handling of C-style casting, where a C-styleDouglas Gregor2011-01-271-15/+26
| | | | | | | | | | | derived-to-base cast that also casts away constness (one of the cases for static_cast followed by const_cast) would be treated as a bit-cast rather than a derived-to-base class, causing miscompiles and heartburn. Fixes <rdar://problem/8913298>. llvm-svn: 124340
* Implement the restriction that a function with a ref-qualifier cannotDouglas Gregor2011-01-261-1/+17
| | | | | | | | overload a function without a ref-qualifier (C++0x [over.load]p2). This, apparently, completes the implementation of rvalue references for *this. llvm-svn: 124321
* Rvalue references for *this: explicitly keep track of whether aDouglas Gregor2011-01-261-8/+12
| | | | | | | | | reference binding is for the implicit object parameter of a member function with a ref-qualifier. My previous comment, that we didn't need to track this explicitly, was wrong: we do in fact get rvalue-references-prefer-rvalues overloading with ref-qualifiers. llvm-svn: 124313
* Rvalue references for *this: implement the implicit conversion rulesDouglas Gregor2011-01-261-43/+104
| | | | | | | for the implicit object argument to a non-static member function with a ref-qualifier (C++0x [over.match.funcs]p4). llvm-svn: 124311
* Rvalue references for *this: allow functions to be overloaded based onDouglas Gregor2011-01-261-2/+3
| | | | | | | | | the presence and form of a ref-qualifier. Note that we do *not* yet implement the restriction in C++0x [over.load]p2 that requires either all non-static functions with a given parameter-type-list to have a ref-qualifier or none of them to have a ref-qualifier. llvm-svn: 124297
* Reinstate r124236 (tweaking the rvalue-reference overload resolutionDouglas Gregor2011-01-261-18/+53
| | | | | | rules), now that we've actually have a clean build for me to sully. llvm-svn: 124290
* Speculatively revert r124236Douglas Gregor2011-01-251-53/+18
| | | | llvm-svn: 124247
* Speculatively implement a tweak to the C++0x overload resolution rulesDouglas Gregor2011-01-251-18/+53
| | | | | | | | | | | | | | for reference binding (C++ [over.rank.ics]p3b1sb4), so that we prefer the binding of an lvalue reference to a function lvalue over the binding of an rvalue reference. This change resolves the ambiguity with std::forward and lvalue references to function types in a way that seems consistent with the original rvalue references proposal. My proposed wording for this change is shown in isBetterReferenceBindingKind(); we'll try to get this change adopted in the C++0x working paper as well. llvm-svn: 124236
* Fix the ranking of reference bindings during overload resolutionDouglas Gregor2011-01-251-2/+2
| | | | | | | | | | | | | | | | | | (C++0x [over.ics.rank]p3) when one binding is an lvalue reference and the other is an rvalue reference that binds to an rvalue. In particular, we were using the predict "is an rvalue reference" rather than "is an rvalue reference that binds to an rvalue", which was incorrect in the one case where an rvalue reference can bind to an lvalue: function references. This particular issue cropped up with std::forward, where Clang was picking an std::forward overload while forwarding an (lvalue) reference to a function. However (and unfortunately!), the right answer for this code is that the call to std::forward is ambiguous. Clang now gets that right, but we need to revisit the std::forward implementation in libc++. llvm-svn: 124216
* Re-instate r123977/r123978, my updates of the reference-bindingDouglas Gregor2011-01-241-75/+57
| | | | | | | | | | | | | | | | implementation used by overload resolution to support rvalue references. The original commits caused PR9026 and some hard-to-reproduce self-host breakage. The only (crucial!) difference between this commit and the previous commits is that we now properly check the SuppressUserConversions flag before attempting to perform a second user-defined conversion in reference binding, breaking the infinite recursion chain of user-defined conversions. Rvalue references should be working a bit better now. llvm-svn: 124121
* revert r123977 and r123978 to fix PR9026.Rafael Espindola2011-01-221-58/+76
| | | | llvm-svn: 124033
* Add test for overload resolution's preference for binding an rvalueDouglas Gregor2011-01-211-3/+3
| | | | | | | reference to an rvalue rather than binding a const-qualified lvalue reference to that rvalue. llvm-svn: 123979
* Eliminate an unused variableDouglas Gregor2011-01-211-4/+0
| | | | llvm-svn: 123978
* Update the reference-binding implementation used for overloadDouglas Gregor2011-01-211-72/+58
| | | | | | | | resolution to match the latest C++0x working paper's semantics. The implementation now matching up with the reference-binding implementation used for initialization. llvm-svn: 123977
* Implement the special template argument deduction rule for T&& in aDouglas Gregor2011-01-211-3/+28
| | | | | | | | | | | call (C++0x [temp.deduct.call]p3). As part of this, start improving the reference-binding implementation used in the computation of implicit conversion sequences (for overload resolution) to reflect C++0x semantics. It still needs more work and testing, of course. llvm-svn: 123966
* When building a user-defined conversion sequence, keep track of theDouglas Gregor2011-01-201-0/+5
| | | | | | | declaration that name lookup actually found, so that we can use it for access checking later on. Fixes <rdar://problem/8876150>. llvm-svn: 123867
* Sema::BuildCXXMemberCallExpr() can fail due to access or ambiguities,Douglas Gregor2011-01-201-6/+15
| | | | | | | so allow it to propagate the failure outward. Fixes the crashing part of <rdar://problem/8876150>. llvm-svn: 123863
* Explicitly track the number of call arguments provided when performingDouglas Gregor2011-01-191-4/+13
| | | | | | | overload resolution, so that we only use that number of call arguments for partial ordering. Fixes PR9006, a recent regression. llvm-svn: 123861
* Change the canonical representation of array types to store qualifiers on theJohn McCall2011-01-191-5/+5
| | | | | | | | | | | | outermost array types and not on the element type. Move the CanonicalType member from Type to ExtQualsTypeCommonBase; the canonical type on an ExtQuals node includes the qualifiers on the ExtQuals. Assorted optimizations enabled by this change. getQualifiers(), hasQualifiers(), etc. should all now implicitly look through array types. llvm-svn: 123817
* Change QualType::getTypePtr() to return a const pointer, then change aJohn McCall2011-01-191-5/+5
| | | | | | thousand other things which were (generally inadvertantly) relying on that. llvm-svn: 123814
* Add support for explicit constructor calls in Microsoft mode.Francois Pichet2011-01-181-1/+5
| | | | | | | | | | | | | | | | | | | For example: class A{ public: A& operator=(const A& that) { if (this != &that) { this->A::~A(); this->A::A(that); // <=== explicit constructor call. } return *this; } }; More work will be needed to support an explicit call to a template constructor. llvm-svn: 123735
* Implement C++ [temp.func.order]p5 more directly, by passing down theDouglas Gregor2011-01-111-2/+3
| | | | | | | | | number of explicit call arguments. This actually fixes an erroneous test for [temp.deduct.partial]p11, where we were considering parameters corresponding to arguments beyond those that were explicitly provided. llvm-svn: 123244
* Implement template argument deduction from a call to a functionDouglas Gregor2011-01-061-2/+2
| | | | | | | | | | | | template whose last parameter is a parameter pack. This allows us to form a call to, e.g., template<typename ...Args1, typename ...Args2> void f(std::pair<Args1, Args2> ...pairs); given zero or more instances of "pair". llvm-svn: 122973
* Many of the built-in operator candidates introduced into overloadDouglas Gregor2011-01-051-1/+16
| | | | | | | resolution require that the pointed-to type be an object type, but we weren't filtering out non-object types. Do so, fixing PR7851. llvm-svn: 122853
* For member pointer conversions potentially involving derived-to-baseDouglas Gregor2010-12-211-2/+3
| | | | | | | | | conversions, make sure that the (possibly) derived type is complete before looking for base classes. Finishes the fix for PR8801. llvm-svn: 122363
* Fix the noreturn conversion to only strip off a single level of indirection.John McCall2010-12-211-6/+37
| | | | | | | Apply the noreturn attribute while creating a builtin function's type. Remove the getNoReturnType() API. llvm-svn: 122295
* Variadic templates: extend the Expr class with a bit that specifiesDouglas Gregor2010-12-151-5/+4
| | | | | | | | | | | | | | | | | | whether the expression contains an unexpanded parameter pack, in the same vein as the changes to the Type hierarchy. Compute this bit within all of the Expr subclasses. This change required a bunch of reshuffling of dependency calculations, mainly to consolidate them inside the constructors and to fuse multiple loops that iterate over arguments to determine type dependence, value dependence, and (now) containment of unexpanded parameter packs. Again, testing is painfully sparse, because all of the diagnostics will change and it is more important to test the to-be-written visitor that collects unexpanded parameter packs. llvm-svn: 121831
* Reduce the number of builtin operator overload candidates added in certainChandler Carruth2010-12-131-27/+89
| | | | | | | | | | | | cases. First, omit all builtin overloads when no non-record type is in the set of candidate types. Second, avoid arithmetic type overloads for non-arithmetic or enumeral types (counting vector types as arithmetic due to Clang extensions). When heavily using constructs such as STL's '<<' based stream logging, this can have a significant impact. One logging-heavy test case's compile time dropped by 10% with this. Self-host shows 1-2% improvement in compile time, but that's likely in the noise. llvm-svn: 121665
* Finish cleaning up the static utility code for adding builtin operator overloadChandler Carruth2010-12-121-62/+65
| | | | | | | candidates. They're now wrapped in nice APIs which hide the tables, etc. Also removes some repetitive code from clients. llvm-svn: 121634
* Clean up the helpers used to compute the usual arithmetic conversions' resultChandler Carruth2010-12-121-67/+56
| | | | | | | | | | | | type. Localize all of the logic within a single function rather than spreading it throughout the class. Also fixes a buglet where we failed to check for a RHS arithmetic type wider than the LHS and return its canonical type. I've yet to produce a test case that breaks because of this, but it was spotted by inspection by folks on the IRC channel and is obviously correct now. llvm-svn: 121633
* Add a comment to a helper function.Chandler Carruth2010-12-121-0/+2
| | | | llvm-svn: 121632
* Sink the logic to suppress builtin operator overloads in the presence ofChandler Carruth2010-12-121-52/+52
| | | | | | | | | | | user-defined operator overloads on the same enumeral types to the one place where it is used. In theory this removes wasted computation from several paths through this code, but I'm not aware of a case where it actually matters. This is mostly for cleanliness. llvm-svn: 121630
* Reorder the cases in the switch to be more logically grouped (to my mind). IfChandler Carruth2010-12-121-34/+34
| | | | | | | others have another ordering they would prefer, I'm all ears, but this one made it much easier for me to find the group of operators I'm interested in. llvm-svn: 121629
* Remove the final goto from this switch making it explict which overload set isChandler Carruth2010-12-121-2/+3
| | | | | | added for binary operator&. llvm-svn: 121628
* Fold away completely identical code with simple fallthrough.Chandler Carruth2010-12-121-7/+2
| | | | llvm-svn: 121627
* Move and copy function calls around to remove the indirection through gotosChandler Carruth2010-12-121-14/+10
| | | | | | from the switch statement. llvm-svn: 121626
* Simplify the flow through the switch by explicitly listing the added overloadsChandler Carruth2010-12-121-13/+7
| | | | | | for a few cases. llvm-svn: 121625
* Fix 80-column violations and reflowing some code to facilitate those fixes.Chandler Carruth2010-12-121-48/+59
| | | | llvm-svn: 121624
* Begin the refactoring of how builtin operators are added to the overloadChandler Carruth2010-12-121-736/+842
| | | | | | | | | | | | | | candidate set. This breaks apart a huge switch + goto system into distinct methods on a class. It also places the current mess of tables and other static state used in the process within that class. This is still a work in progress. I did a few simplifications that jumped out at me as I went, but I plan to iterate on this a bit before it's truly clean. However, this is easily the most invasive chunk. I benchmarked it on all-std-headers.cpp and an internal testcase that has a major hotspot in overload resolution and saw no real performance impact. llvm-svn: 121623
* It's kindof silly that ExtQuals has an ASTContext&, and we can use thatJohn McCall2010-12-101-3/+3
| | | | | | | | | | space better. Remove this reference. To make that work, change some APIs (most importantly, getDesugaredType()) to take an ASTContext& if they need to return a QualType. Simultaneously, diminish the need to return a QualType by introducing some useful APIs on SplitQualType, which is just a std::pair<const Type *, Qualifiers>. llvm-svn: 121478
* Objective-C pointer conversions to 'id' or qualified 'id' subsumeDouglas Gregor2010-12-061-0/+5
| | | | | | | | cv-qualification conversions. More specifically, there's an implicit cv-qualification conversion (even one that drops qualifiers) when converting to 'id' or qualified 'id'. Fixes <rdar://problem/8734046>. llvm-svn: 121047
OpenPOWER on IntegriCloud