summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rename Diagnostic to DiagnosticsEngine as per issue 5397David Blaikie2011-09-251-2/+3
| | | | llvm-svn: 140478
* Add a special note for overload resolution when an initializer list argumentSebastian Redl2011-09-241-0/+11
| | | | | | | | | cannot be converted. This is in preparation for overload resolution of initializer lists. Currently, you will always get this message when you try to pass an init list to an overloaded function. llvm-svn: 140461
* Give InitListChecker a verification-only mode, where it neither emits ↵Sebastian Redl2011-09-241-15/+19
| | | | | | | | | | | diagnostics nor builds a semantic (structured) initializer list, just reports on whether it can match the given list to the target type. Use this mode for doing init list checking in the initial step of initialization, which will eventually allow us to do overload resolution based on the outcome. llvm-svn: 140457
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-2/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-6/+7
| | | | llvm-svn: 140367
* Enforce access control for conversion operators used in contextualJohn McCall2011-09-211-5/+4
| | | | | | conversions (rather than just call-arguments). llvm-svn: 140244
* In Microsoft mode(-fms-compatibility), prefer an integral conversion to a ↵Francois Pichet2011-09-181-0/+19
| | | | | | | | | | | | | | | | floating-to-integral conversion if the integral conversion is between types of the same size. For example: void f(float); void f(int); int main { long a; f(a); } Here, MSVC will call f(int) instead of generating a compile error as clang will do in standard mode. This fixes a few errors when parsing MFC code with clang. llvm-svn: 140007
* Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear ↵Francois Pichet2011-09-171-3/+3
| | | | | | | | that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag. Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag. llvm-svn: 139987
* Silence "end of non-void function" warnings with llvm_unreachable and add an ↵Benjamin Kramer2011-09-101-2/+5
| | | | | | assert. llvm-svn: 139474
* Fix a -Wreturn-type warning due to this field not explicitly having theChandler Carruth2011-09-101-1/+1
| | | | | | enumeration type. llvm-svn: 139445
* Add smarter sorting of overload candidates that failed template deduction.Kaelyn Uhrain2011-09-091-0/+37
| | | | llvm-svn: 139417
* Contextually converting to 'id' is not a useful operation. ContextuallyJohn McCall2011-09-091-14/+46
| | | | | | | | | | | | converting to an arbitrary Objective-C pointer type is. Without significantly re-implementing anything, change the API to reflect this, and as a minor optimization, strip the pointer conversion off before potentially building it. Mostly, this removes a really bizarre-looking bit of code from BuildInstanceMessage. llvm-svn: 139354
* Give conversions of block pointers to ObjC pointers a different cast kindJohn McCall2011-09-091-6/+13
| | | | | | | | than conversions of C pointers to ObjC pointers. In order to ensure that we've caught every case, add asserts to CastExpr that strictly determine which cast kind is used for which kind of bit cast. llvm-svn: 139352
* In Microsoft mode, if we are inside a template class member function and we ↵Francois Pichet2011-09-071-1/+14
| | | | | | | | can't resolve a function call then create a type-dependent CallExpr even if the function has no type dependent arguments. The goal is to postpone name lookup to instantiation time to be able to search into type dependent base classes. With this patch in, clang will generate only 37 errors (down from 212) when parsing a typical MFC source file. llvm-svn: 139210
* Be sure to emit lvalue-to-rvalue casts for loads from x-values.John McCall2011-08-301-4/+4
| | | | | | | Doing this happens to disrupt the pattern that ARC was looking for for move optimizations, so we need to fix that simultaneously. llvm-svn: 138789
* Make sure we don't crash printing builtin candidates for overloads of ↵Eli Friedman2011-08-261-4/+5
| | | | | | deleted operators. Fixes PR10757. llvm-svn: 138645
* Teach reference initialization from the result of a user-definedDouglas Gregor2011-08-151-5/+5
| | | | | | | conversion to initialize the standard conversion *after* the user-defined conversion properly. Fixes PR10644. llvm-svn: 137608
* Have the typo correction in DiagnoseEmptyLookup properly handle templateKaelyn Uhrain2011-08-051-1/+1
| | | | | | functions when performing function overload resolution. llvm-svn: 136948
* Improve overloaded function handling in the typo correction code.Kaelyn Uhrain2011-08-031-1/+2
| | | | | | | | Change TypoCorrection to store a set of NamedDecls instead of a single NamedDecl. Also add initial support for performing function overload resolution to Sema::DiagnoseEmptyLookup. llvm-svn: 136807
* Refactor the */& mismatch fixit generation out of SemaOverload and provide a ↵Anna Zaks2011-07-281-113/+16
| | | | | | simple conversion checking function. llvm-svn: 136376
* Tests for explicit conversion operators, along with a fix to avoidDouglas Gregor2011-07-231-12/+15
| | | | | | | | | | considering explicit conversion operators when determining surrogate functions. Fixes PR10453. Note that there are a few test cases where Clang is still wrong because it does not implement DR899; see PR10456. Patch by Jonathan Sauer! llvm-svn: 135857
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-10/+10
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* kill a FIXME in IsIntegralPromotionDavid Majnemer2011-07-221-4/+1
| | | | | | | | IsIntegralPromotion should consider the signedness of FromType when calculating promotions. This, as of now, cannot be exercised on any platform so there is no corresponding test. llvm-svn: 135803
* Addressing code review comments for commit 135509 - Add FixItHints in case a ↵Anna Zaks2011-07-211-8/+32
| | | | | | C++ function call is missing * or & operators on llvm-svn: 135643
* arc-objc++: Issue an arc specific diagnostic when overload resolutionFariborz Jahanian2011-07-201-1/+14
| | | | | | | fails because of lifetime differences of parameter and argument type. // rdar://9790531 llvm-svn: 135593
* Add FixItHints in case a C++ function call is missing * or & operators on ↵Anna Zaks2011-07-191-6/+125
| | | | | | one/several of it's parameters (addresses http://llvm.org/PR5941). llvm-svn: 135509
* Store bracket locations for array subscript expressions, from Erik Verbruggen!Douglas Gregor2011-07-151-3/+8
| | | | llvm-svn: 135275
* PR8800: When building a conversion to A& using a member operatorA&(), do not ↵Richard Smith2011-07-131-4/+4
| | | | | | require A to be a complete type. llvm-svn: 135101
* Fix missing braces around two statements that were intended to be partChandler Carruth2011-06-271-1/+2
| | | | | | | | | | | of a single if block. This is really annoying to track down and test. Silly changes to the test case caused it to stop showing up. I wish there were a more concrete way of asserting that a note attaches to the intended diagnostic. This fixes PR10195. llvm-svn: 133907
* Fix PR10187: when diagnosing a two-phase-lookup-related failure, don't ↵Richard Smith2011-06-261-8/+12
| | | | | | assert that any names we find are valid candidates for the call. llvm-svn: 133898
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-1/+1
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. llvm-svn: 133779
* Allow unavailable function calls inside unavailable functions in C++/ObjC++ ↵Argyrios Kyrtzidis2011-06-231-2/+13
| | | | | | as well. rdar://9660196 llvm-svn: 133672
* Accept no-return stripping conversions for pointer type arguments afterChandler Carruth2011-06-181-6/+6
| | | | | | | | | | | | | | | | | | | deducing template parameter types. Recently Clang began enforcing the more strict checking that the argument type and the deduced function parameter type (after substitution) match, but that only consideres qualification conversions. One problem with this patch is that we check noreturn conversions and qualification conversions independently. If a valid conversion would require *both*, perhaps interleaved with each other, it will be rejected. If this actually occurs (I'm not yet sure it does) and is in fact a problem (I'm not yet sure it is), there is a FIXME to implement more intelligent conversion checking. However, this step at least allows Clang to resume accepting valid code we're seeing in the wild. llvm-svn: 133327
* Automatic Reference Counting.John McCall2011-06-151-54/+244
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Fix a regression in the two-phase lookup diagnostics that switching theChandler Carruth2011-06-081-0/+3
| | | | | | | | namespace set algorithm (re-)introduced. We may not have seen the 'std' namespace, but we should still suggested associated namespaces. Easy fix, but a bit annoying to test. llvm-svn: 132744
* Richard Smith was correct about how the sets should be computed forChandler Carruth2011-06-051-11/+8
| | | | | | | | | this. My suggestion assumed a viable erase method for iterators on SmallPtrSet. This patch restores his original pattern. llvm-svn: 132673
* Fix PR10053: Improve diagnostics and error recovery for code which some ↵Richard Smith2011-06-051-8/+140
| | | | | | compilers incorrectly accept due to a lack of proper support for two-phase name lookup. llvm-svn: 132672
* Identity and non-identity standard conversion sequences can beDouglas Gregor2011-06-051-6/+4
| | | | | | | | | compared even when one is a reference binding and the other is not (<rdar://problem/9173984>), but the definition of an identity sequence does not involve lvalue-to-rvalue adjustments (PR9507). Fix both inter-related issues. llvm-svn: 132660
* Update our diagnostics to properly account for move operations.Alexis Hunt2011-05-251-2/+14
| | | | llvm-svn: 132096
* Audit and finish the implementation of C++0x nullptr, fixing twoDouglas Gregor2011-05-211-2/+21
| | | | | | | | | | | | | | minor issues along the way: - Non-type template parameters of type 'std::nullptr_t' were not permitted. - We didn't properly introduce built-in operators for nullptr ==, !=, <, <=, >=, or > as candidate functions . To my knowledge, there's only one (minor but annoying) part of nullptr that hasn't been implemented: catching a thrown 'nullptr' as a pointer or pointer-to-member, per C++0x [except.handle]p4. llvm-svn: 131813
* Allow implicit conversion from function pointer to void* in Microsoft mode. Francois Pichet2011-05-081-0/+9
| | | | | | Necessary to parse MFC code. llvm-svn: 131076
* Relax the conversion rules for Objective-C GC qualifiers aDouglas Gregor2011-05-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | bit by allowing __weak and __strong to be added/dropped as part of implicit conversions (qualification conversions in C++). A little history: GCC lets one add/remove/change GC qualifiers just about anywhere, implicitly. Clang did roughly the same before, but we recently normalized the semantics of qualifiers across the board to get a semantics that we could reason about (yay). Unfortunately, this tightened the screws a bit too much for GC qualifiers, where it's common to add/remove these qualifiers at will. Overall, we're still in better shape than we were before: we don't permit directly changing the GC qualifier (e.g., __weak -> __strong), so type safety is improved. More importantly, we're internally consistent in our handling of qualifiers, and the logic that allows adding/removing GC qualifiers (but not adding/removing address spaces!) only touches two obvious places. Fixes <rdar://problem/9402499>. llvm-svn: 131065
* Warn when trying to call a pure virtual member function in a class from the ↵Anders Carlsson2011-05-061-0/+13
| | | | | | class constructor/destructor. Fixes PR7966. llvm-svn: 130982
* With invalid overloaded operators, we can get into funny cases whereDouglas Gregor2011-05-051-0/+9
| | | | | | | | | | the overloading of member and non-member functions results in arity mismatches that don't fit well into our overload-printing scheme. This only happens for invalid code (which breaks the arity invariants for these cases), so just suppress the diagnostic rather than inventing anything new. Fixes <rdar://problem/9222009>. llvm-svn: 130902
* Add an optional field attached to a DeclRefExpr which points back to theChandler Carruth2011-05-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Decl actually found via name lookup & overload resolution when that Decl is different from the ValueDecl which is actually referenced by the expression. This can be used by AST consumers to correctly attribute references to the spelling location of a using declaration, and otherwise gain insight into the name resolution performed by Clang. The public interface to DRE is kept as narrow as possible: we provide a getFoundDecl() which always returns a NamedDecl, either the ValueDecl referenced or the new, more precise NamedDecl if present. This way AST clients can code against getFoundDecl without know when exactly the AST has a split representation. For an example of the data this provides consider: % cat x.cc namespace N1 { struct S {}; void f(const S&); } void test(N1::S s) { f(s); using N1::f; f(s); } % ./bin/clang -fsyntax-only -Xclang -ast-dump x.cc [...] void test(N1::S s) (CompoundStmt 0x5b02010 <x.cc:5:20, line:9:1> (CallExpr 0x5b01df0 <line:6:3, col:6> 'void' (ImplicitCastExpr 0x5b01dd8 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01d80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)')) (ImplicitCastExpr 0x5b01e20 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01d58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S'))) (DeclStmt 0x5b01ee0 <line:7:3, col:14> 0x5b01e40 "UsingN1::;") (CallExpr 0x5b01fc8 <line:8:3, col:6> 'void' (ImplicitCastExpr 0x5b01fb0 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01f80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)' (UsingShadow 0x5b01ea0 'f'))) (ImplicitCastExpr 0x5b01ff8 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01f58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S')))) Now we can tell that the second call is 'using' (no pun intended) the using declaration, and *which* using declaration it sees. Without this, we can mistake calls that go through using declarations for ADL calls, and have no way to attribute names looked up with using declarations to the appropriate UsingDecl. llvm-svn: 130670
* When determining whether two types are reference-compatible, checkDouglas Gregor2011-04-281-1/+6
| | | | | | | | non-CVR qualifiers as well as CVR qualifiers. For example, don't allow a reference to an integer in address space 1 to bind to an integer in address space 2. llvm-svn: 130411
* FixOverloadedFunctionReference needs to rebuild member accesses of John McCall2011-04-271-4/+11
| | | | | | | | instance methods to have bound-member type. Fixing that broke __unknown_anytype, which I've in turn fixed. llvm-svn: 130266
* When comparing Objective-C pointers during overload resolution toDouglas Gregor2011-04-271-12/+17
| | | | | | | | | | | determine which is a better conversion to "void*", be sure to perform the comparison using the safe-for-id ASTContext::canAssignObjCInterfaces() rather than the asserts-with-id ASTContext::canAssignObjCInterfaces(). Fixes <rdar://problem/9327203>. llvm-svn: 130259
* When computing Objective-C pointer conversions in C++, retainDouglas Gregor2011-04-261-5/+39
| | | | | | | | | | | the qualifiers (e.g., GC qualifiers) on the type we're converting from, rather than just blindly adopting the qualifiers of the type we're converting to or dropping qualifiers altogether. As an added bonus, properly diagnose GC qualifier mismatches to eliminate a crash in the overload resolution failure diagnostics. llvm-svn: 130255
* Make yet another placeholder type, this one marking that an expression is a ↵John McCall2011-04-261-52/+124
| | | | | | | | | | | bound member function, i.e. something of the form 'x.f' where 'f' is a non-static member function. Diagnose this in the general case. Some of the new diagnostics are probably worse than the old ones, but we now get this right much more universally, and there's certainly room for improvement in the diagnostics. llvm-svn: 130239
OpenPOWER on IntegriCloud