summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Single- and zero-element initializer lists to scalars are ↵Sebastian Redl2012-02-281-0/+1
| | | | | | list-initializations. Fixes PR12118. llvm-svn: 151666
* Implement a FIXME for conversion sequence distinction. Should fix PR12092.Sebastian Redl2012-02-271-2/+10
| | | | llvm-svn: 151577
* ArrayRef'ize various functions in the AST/Parser/Sema.Ahmed Charles2012-02-251-120/+135
| | | | llvm-svn: 151447
* Fix a regression from r151117: ADL requires that we attempt to complete anyRichard Smith2012-02-251-6/+5
| | | | | | | | associated classes, since it can find friend functions declared within them, but overload resolution does not otherwise require argument types to be complete. llvm-svn: 151434
* Implement C++11 [over.match.copy]p1b2, which allows the use ofDouglas Gregor2012-02-241-5/+9
| | | | | | | | | | | explicit conversion functions to initialize the argument to a copy/move constructor that itself is the subject of direct initialization. Since we don't have that much context in overload resolution, we end up threading more flags :(. Fixes <rdar://problem/10903741> / PR10456. llvm-svn: 151409
* Teach overload resolution to prefer user-defined conversion via aDouglas Gregor2012-02-221-0/+48
| | | | | | | | | | lambda closure type's function pointer conversion over user-defined conversion via a lambda closure type's block pointer conversion, always. This is a preference for more-standard code (since blocks are an extension) and a nod to efficiency, since function pointers don't require any memory management. Fixes PR12063. llvm-svn: 151170
* Implement C++11 [expr.call]p11: If the operand to a decltype-specifier is aRichard Smith2012-02-221-0/+2
| | | | | | | | | | | | | | | | | | function call (or a comma expression with a function call on its right-hand side), possibly parenthesized, then the return type is not required to be complete and a temporary is not bound. Other subexpressions inside a decltype expression do not get this treatment. This is implemented by deferring the relevant checks for all calls immediately within a decltype expression, then, when the expression is fully-parsed, checking the relevant constraints and stripping off any top-level temporary binding. Deferring the completion of the return type exposed a bug in overload resolution where completion of the argument types was not attempted, which is also fixed by this change. llvm-svn: 151117
* Add a bunch of missing calls to DiagnoseSentinelCalls. ↵Eli Friedman2012-02-181-0/+4
| | | | | | | | <rdar://problem/10885993>. This should probably be refactored... but it isn't completely obvious what refactoring is best. llvm-svn: 150869
* When overload resolution picks an implicitly-deleted special memberDouglas Gregor2012-02-151-5/+18
| | | | | | | | | function, provide a specialized diagnostic that indicates the kind of special member function (default constructor, copy assignment operator, etc.) and that it was implicitly deleted. Add a hook where we can provide more detailed information later. llvm-svn: 150611
* Fix parsing new expressions using init lists. Probably still do the wrong ↵Sebastian Redl2012-02-111-4/+82
| | | | | | | | thing in cases involving array new. Show that many cases using initializer list constructors work, in that they parse and pass semantic analysis. llvm-svn: 150316
* Implement the conversion to a function pointer for lambda expressions,Douglas Gregor2012-02-101-3/+5
| | | | | | per C++ [expr.prim.lambda]p6. llvm-svn: 150236
* [libclang] For CXXOperatorCallExprs, give a valid source location to the ↵Argyrios Kyrtzidis2012-02-081-7/+12
| | | | | | | | | | DeclRefExpr that is referencing the member function, so we can index the referenced function. Fixes rdar://10762375&10324915 & http://llvm.org/PR11192 llvm-svn: 150033
* Revise the SplitQualType interface to make it its own thing instead ofJohn McCall2012-02-081-1/+1
| | | | | | | | | | | | | | a typedef of std::pair. This slightly improves type-safety, but mostly makes code using it clearer to read as well as making it possible to add methods to the type. Add such a method for efficiently single-step desugaring a split type. Add a method to single-step desugaring a locally-unqualified type. Implement both the SplitQualType and QualType methods in terms of that. Also, fix a typo ("ObjCGLifetime"). llvm-svn: 150028
* Fixed instantiation of DependentScopeDeclRefExpr.Abramo Bagnara2012-02-061-2/+2
| | | | llvm-svn: 149868
* In C++11 mode, when an integral constant expression is desired and we have aRichard Smith2012-02-041-6/+9
| | | | | | | | | | | | | | | | | | value of class type, look for a unique conversion operator converting to integral or unscoped enumeration type and use that. Implements [expr.const]p5. Sema::VerifyIntegerConstantExpression now performs the conversion and returns the converted result. Some important callers of Expr::isIntegralConstantExpr have been switched over to using it (including all of those required for C++11 conformance); this switch brings a side-benefit of improved diagnostics and, in several cases, simpler code. However, some language extensions and attributes have not been moved across and will not perform implicit conversions on constant expressions of literal class type where an ICE is required. In passing, fix static_assert to perform a contextual conversion to bool on its argument. llvm-svn: 149776
* Don't allow a value of a scoped enumeration to be used as the first bound for anRichard Smith2012-02-041-6/+19
| | | | | | | array new expression. This lays some groundwork for the implicit conversion to integral or unscoped enumeration which C++11 ICEs undergo. llvm-svn: 149772
* Initialize the user defined conversion function to null if this is an ↵Benjamin Kramer2012-02-021-0/+1
| | | | | | | | aggregate initialization from an initializer list. Found by valgrind. llvm-svn: 149627
* Split Sema::MarkDeclarationReferenced into multiple functions; the ↵Eli Friedman2012-02-021-11/+11
| | | | | | additional entry points are needed to implement C++11 odr-use marking correctly. No functional change in this patch; I'll actually make the change which fixes the odr-use marking in a followup patch. llvm-svn: 149586
* constexpr: disallow signed integer overflow in integral conversions in constantRichard Smith2012-01-301-4/+14
| | | | | | expressions in C++11. llvm-svn: 149286
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-3/+8
| | | | llvm-svn: 149127
* Slight refactoring; catch yet another case where we were missing an ↵Eli Friedman2012-01-261-2/+9
| | | | | | lvalue-to-rvalue conversion. llvm-svn: 149003
* Allow typo correction to be disabled in BuildOverloadedCallExpr variant.Kaelyn Uhrain2012-01-251-5/+27
| | | | | | | This suppresses typo correction for auto-generated call expressions such as to 'begin' or 'end' within a C++0x for-range statement. llvm-svn: 148979
* Add custom callback object for typo correction in BuildRecoveryCallExpr.Kaelyn Uhrain2012-01-251-3/+49
| | | | | | | | | The new callback, in addition to limiting which keywords to include in the pool of typo correction candidates, also filters out non-keyword candidates that don't refer to (template) functions that accept the number of arguments that are present for the call being recovered. llvm-svn: 148962
* Minor fixups for auto deduction of initializer lists.Sebastian Redl2012-01-231-1/+1
| | | | | | | | Fix some review comments. Add a test for deduction when std::initializer_list isn't available yet. Fix redundant error messages. This fixes and outstanding FIXME too. llvm-svn: 148735
* constexpr: converted constant expression handling for enumerator values, caseRichard Smith2012-01-181-2/+164
| | | | | | | | | | values and non-type template arguments of integral and enumeration types. This change causes some legal C++98 code to no longer compile in C++11 mode, by enforcing the C++11 rule that narrowing integral conversions are not permitted in the final implicit conversion sequence for the above cases. llvm-svn: 148439
* Convert DiagnoseEmptyLookup to use correction callbacks.Kaelyn Uhrain2012-01-181-1/+4
| | | | | | | | | | | | No new unit tests yet as there is no behavioral change (except for slightly more specific filtering in Sema::ActOnStartOfLambdaDefinition). Tests will be added as the code paths are traced in greater depth to determine how to improve the results--there are at least one or two known bugs that require those improvements. This commit lays the groundwork for those changes. llvm-svn: 148382
* Move narrowing conversion detection code from SemaInit to SemaOverload, readyRichard Smith2012-01-181-0/+157
| | | | | | | | | | | | | for it to be used in converted constant expression checking, and fix a couple of issues: - Conversion operators implicitly invoked prior to the narrowing conversion were not being correctly handled when determining whether a constant value was narrowed. - For conversions from floating-point to integral types, the diagnostic text incorrectly always claimed that the source expression was not a constant expression. llvm-svn: 148381
* Basic overloading support for std::initializer_list.Sebastian Redl2012-01-171-3/+29
| | | | llvm-svn: 148350
* Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie2012-01-171-9/+6
| | | | | | appropriate or when GCC requires it) llvm-svn: 148292
* Use a smaller vector than SmallVector.Benjamin Kramer2012-01-141-3/+2
| | | | | | Shrinks OverloadCandidate from 208 to 168 bytes. llvm-svn: 148204
* Clear ImplicitConversionSequence the obvious way which turns out to be less ↵Benjamin Kramer2012-01-141-4/+3
| | | | | | fragile. llvm-svn: 148200
* Give OverloadCandidateSet the responsibility for destroying the implicit ↵Benjamin Kramer2012-01-141-1/+5
| | | | | | conversion sequences so we don't get double frees when the vector reallocates. llvm-svn: 148198
* Pool allocate ImplicitConversionSequences.Benjamin Kramer2012-01-141-9/+10
| | | | | | | | | | | | | | | | To avoid malloc thrashing give OverloadCandidateSet an inline capacity for conversion sequences. We use the fact that OverloadCandidates never outlive the OverloadCandidateSet and have a fixed amount of conversion sequences. This eliminates the oversized SmallVector from OverloadCandidate shrinking it from 752 to 208 bytes. On the test case from the "Why is CLANG++ so freaking slow" thread on llvmdev this avoids one gig of vector reallocation (including memcpy) which translates into 5-10% speedup on Lion/x86_64. Overload candidate computation is still the biggest malloc contributor when compiling templated c++ code. llvm-svn: 148186
* OverloadCandidateSet: Stop exposing SmallVector internalsBenjamin Kramer2012-01-141-22/+9
| | | | | | | Replace push_back with addCandidate which will let us make use of the fixed size of the conversion sequence vector soon. llvm-svn: 148185
* More lambda work: semantic analysis of capturing 'this'. It's a bit ↵Eli Friedman2012-01-071-0/+1
| | | | | | complicated, but we have to be careful about when exactly captures are marked given PotentiallyPotentiallyEvaluated contexts. (Actually, it's not 100% correct yet, but it's close enough for the moment.) llvm-svn: 147723
* Overloading for initializer list construction.Sebastian Redl2011-12-221-80/+126
| | | | llvm-svn: 147156
* Two null Decl*'s don't refer to the same declaration, because theyDouglas Gregor2011-12-151-3/+4
| | | | | | | | don't refer to anything. Amusingly, we were relying on this in one place. Thanks to Chandler for noticing the weirdness in declaresSameEntity. llvm-svn: 146659
* Replace all comparisons between ObjCInterfaceDecl pointers with callsDouglas Gregor2011-12-151-1/+2
| | | | | | | | to declaresSameEntity(), as a baby step toward tracking forward declarations of Objective-C classes precisely. Part of <rdar://problem/10583531>. llvm-svn: 146618
* Make the diagnostic message more consistant. Update the type comparison toRichard Trieu2011-12-131-11/+16
| | | | | | | handle non-pointer types. This is for the extra info printed when function types are compared. llvm-svn: 146525
* Implement overload resolution for reference-typed parameters supplied with ↵Sebastian Redl2011-12-031-3/+65
| | | | | | initializer lists. llvm-svn: 145769
* In Microsoft mode, make "Unqualified lookup into dependent bases of class ↵Francois Pichet2011-11-251-1/+1
| | | | | | | | | | templates" works inside a friend function definition at class scope. Basically we have to look into the parent *lexical* DeclContext for friend functions at class scope. That's because calling GetParent() return the namespace or file DeclContext. This fixes all remaining cases of "Unqualified lookup into dependent bases of class templates" when parsing MFC code with clang. llvm-svn: 145127
* Add feature to diagnostics that will provide more information on functionRichard Trieu2011-11-231-14/+121
| | | | | | | | | | pointer mismatch. Cases covered are: initialization, assignment, and function arguments. Additional text will give the extra information about the nature of the mismatch: different classes for member functions, wrong number of parameters, different parameter type, different return type, and function qualifier mismatch. llvm-svn: 145114
* Fixed HadMultipleCandidates loading.Abramo Bagnara2011-11-191-9/+15
| | | | llvm-svn: 144995
* In Microsoft mode, make "Unqualified lookup into dependent bases of class ↵Francois Pichet2011-11-171-1/+1
| | | | | | | | | | templates" works inside default argument instantiation. This is a little bit tricky because during default argument instantiation the CurContext points to a CXXMethodDecl but we can't use the keyword this or have an implicit member call generated. This fixes 2 errors when parsing MFC code with clang. llvm-svn: 144881
* Added missing ImplicitCastExpr around conversion operator call.Abramo Bagnara2011-11-161-4/+14
| | | | llvm-svn: 144850
* Move "Unqualified lookup into dependent bases of class templates" Microsoft ↵Francois Pichet2011-11-111-1/+1
| | | | | | specific behavior from -fms-extensions to -fms-compatibility. llvm-svn: 144341
* Implicit casts from rvalue to lvalue are not meaningful. Don't accidentally addRichard Smith2011-11-101-1/+1
| | | | | | | | | | them when performing a const conversion on the implicit object argument for a member operator call on an rvalue. No change to the testsuite: the test for this change is that the added assertion does not fire any more. llvm-svn: 144333
* In C++ keep unavailable function calls in the AST, like in C/ObjC.Argyrios Kyrtzidis2011-11-041-0/+7
| | | | | | This allows the migrator to visit and fix them. llvm-svn: 143699
* Enable function call and some overload resolution with parameters of ↵Sebastian Redl2011-11-011-7/+40
| | | | | | aggregate class type and initializer list arguments. llvm-svn: 143462
* Restore r142914 and r142915, now with missing file and apparentJohn McCall2011-10-251-44/+12
| | | | | | GCC compiler workaround. llvm-svn: 142931
OpenPOWER on IntegriCloud