summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Pass access specifiers around in overload resolution.John McCall2010-01-261-31/+53
| | | | llvm-svn: 94485
* Produce a special diagnostic when users call a function with an argument ofJohn McCall2010-01-231-1/+16
| | | | | | | | | | | | | | | | incomplete type (or a pointer/reference to such). The causes of this problem are different enough to justify a different "design" for the diagnostic. Most notably, it doesn't give an operand index: it's usually pretty obvious which operand is the problem, it adds a lot of clutter to mention it, and the fix is usually in a different part of the file anyway. This is yet another diagnostic that should really have an analogue in the non-overloaded case --- which should be much easier to write because of the weaker space constraints. llvm-svn: 94303
* During overload resolution diagnostics, sort non-viable candidates by the ↵John McCall2010-01-231-4/+112
| | | | | | | | | | | | | quality of their conversions. To make this work, fill out all conversions for all candidates (but only when diagnosing overload failure). Split out a few cases from ovl_fail_bad_conversion which didn't actually involve a failed argument conversion. I'm pretty sure this is not a well-founded ordering, but I'm not sure it matters. llvm-svn: 94283
* Use raw_ostream instead of cstdio.Daniel Dunbar2010-01-221-19/+21
| | | | llvm-svn: 94136
* Fixes comments.Fariborz Jahanian2010-01-211-2/+2
| | | | llvm-svn: 94053
* Also allow cast of block pointer type toFariborz Jahanian2010-01-211-0/+7
| | | | | | | pointer to an any object. Another variation of radar 7562285. llvm-svn: 94052
* In objective-c++ land, a block pointer is another object pointer.Fariborz Jahanian2010-01-201-1/+9
| | | | | | | So, casting a generic object pointer ('id' or 'Class') to the block pointer is allowed. Fixes radar 7562285. llvm-svn: 94045
* Give UnresolvedSet the ability to store access specifiers for each declaration.John McCall2010-01-201-8/+8
| | | | | | | Change LookupResult to use UnresolvedSet. Also extract UnresolvedSet into its own header and make it templated over an inline capacity. llvm-svn: 93959
* Allow conversion of pointer to an objective-c pointer toFariborz Jahanian2010-01-181-1/+11
| | | | | | a similar pointer. Fixes radar 7552179. llvm-svn: 93803
* Fix a use of uninitialized memory in overload diagnostics.John McCall2010-01-161-1/+4
| | | | llvm-svn: 93629
* Candidates with arity mismatches are extra-special non-viable and need toJohn McCall2010-01-151-16/+32
| | | | | | | | stand at the back of the line. Thanks to Oliver Hunt for reminding me to do this. llvm-svn: 93583
* Improve overload diagnostics some more by calling out qualifier mismatchesJohn McCall2010-01-141-3/+55
| | | | | | | for special diagnostics. Unfortunately, the non-overload diagnostics are not this good. llvm-svn: 93420
* Improve the diagnostic for bad conversions in overload resolution to talkJohn McCall2010-01-141-1/+1
| | | | | | about 'object argument' vs. 'nth argument'. llvm-svn: 93395
* Don't report ambiguities in the user-defined conversion if we weren't supposedJohn McCall2010-01-131-1/+1
| | | | | | | | | | | | to be considering user-defined conversions in the first place. Doug, please review; I'm not sure what we should be doing if we see a real ambiguity in selecting a copy constructor when otherwise suppressing user-defined conversions. Fixes PR6014. llvm-svn: 93365
* Record some basic information about bad conversion sequences. Use thatJohn McCall2010-01-131-60/+89
| | | | | | | information to feed diagnostics instead of regenerating it. Much room for improvement here, but fixes some unfortunate problems reporting on method calls. llvm-svn: 93316
* Improve the reporting of non-viable overload candidates by noting the reasonJohn McCall2010-01-131-44/+107
| | | | | | | | why the candidate is non-viable. There's a lot we can do to improve this, but it's a good start. Further improvements should probably be integrated with the bad-initialization reporting routines. llvm-svn: 93277
* So I was sitting around, trying vainly to think of something to commit, and thenJohn McCall2010-01-121-21/+22
| | | | | | | | I said to myself, self, why don't you go add a couple of parameters to a method and then fail to use them, and I thought that sounded like a pretty good idea, so I did it. llvm-svn: 93233
* Reorganize some of the code to note overload candidates. Improves theJohn McCall2010-01-121-39/+56
| | | | | | | fidelity with which we note them as functions/constructors and templates thereof. Also will be helpful when reporting bad conversions (next). llvm-svn: 93224
* Sort overload results by viability.John McCall2010-01-121-10/+19
| | | | llvm-svn: 93215
* Introduce a specific representation for the ambiguous implicit conversionJohn McCall2010-01-121-135/+132
| | | | | | | sequence. Lots of small relevant changes. Fixes some serious problems with ambiguous conversions; also possibly improves associated diagnostics. llvm-svn: 93214
* When computing surrogates for calls to a value of object type, lookDouglas Gregor2010-01-111-2/+1
| | | | | | for all visible conversion functions. llvm-svn: 93173
* Remove some pointless FIXMEs. No functionality changeDouglas Gregor2010-01-111-5/+0
| | | | llvm-svn: 93168
* Implement name lookup for conversion function template specializationsDouglas Gregor2010-01-111-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | (C++ [temp.mem]p5-6), which involves template argument deduction based on the type named, e.g., given struct X { template<typename T> operator T*(); } x; when we call x.operator int*(); we perform template argument deduction to determine that T=int. This template argument deduction is needed for template specialization and explicit instantiation, e.g., template<> X::operator float*() { /* ... */ } and when calling or otherwise naming a conversion function (as in the first example). This fixes PR5742 and PR5762, although there's some remaining ugliness that's causing out-of-line definitions of conversion function templates to fail. I'll look into that separately. llvm-svn: 93162
* Change the printing of OR_Deleted overload results to print all the candidates,John McCall2010-01-081-36/+80
| | | | | | | | | | | | | | | not just the viable ones. This is reasonable because the most common use of deleted functions is to exclude some implicit conversion during calls; users therefore will want to figure out why some other options were excluded. Started sorting overload results. Right now it just sorts by location in the translation unit (after putting viable functions first), but we can do better than that. Changed bool OnlyViable parameter to PrintOverloadCandidates to an enum for better self-documentation. llvm-svn: 92990
* Reorganize PrintOverloadCandidates. No functionality change.John McCall2010-01-081-113/+144
| | | | llvm-svn: 92979
* Add an "implicit" bit to CXXThisExpr, so that we can trackDouglas Gregor2010-01-071-3/+8
| | | | | | | implicitness without losing track of the (logical or actual) location where "this" would occur in the source. llvm-svn: 92958
* Improve the lead diagnostic for C++ object subscript expressions withJohn McCall2010-01-071-13/+19
| | | | | | | | | no viable overloads. Use a different message when the class provides no operator[] overloads at all; use it for operator(), too. Partially addresses PR 5900. llvm-svn: 92894
* Improve the diagnostics used to report implicitly-generated class membersJohn McCall2010-01-061-11/+49
| | | | | | | | | as parts of overload sets. Also, refer to constructors as 'constructors' rather than functions. Adjust a lot of tests. llvm-svn: 92832
* Implement typo correction for id-expressions, e.g.,Douglas Gregor2009-12-311-1/+1
| | | | | | | | | | | | | typo.cpp:22:10: error: use of undeclared identifier 'radious'; did you mean 'radius'? return radious * pi; ^~~~~~~ radius This was super-easy, since we already had decent recovery by looking for names in dependent base classes. llvm-svn: 92341
* Correctly refer to element CVR qualifications when determining if a type isChandler Carruth2009-12-291-2/+21
| | | | | | | | | | more or less cv-qualified than another during implicit conversion and overload resolution ([basic.type.qualifier] p5). Factors the logic out of template deduction and into the ASTContext so it can be shared. This fixes several aspects of PR5542, but not all of them. llvm-svn: 92248
* Handle using declarations in overloaded and template functions during ADL andChandler Carruth2009-12-291-3/+6
| | | | | | | | | | address resolution. This fixes PR5751. Also, while we're here, remove logic from ADL which mistakenly included the definition namespaces of overloaded and/or templated functions whose name or address is used as an argument. llvm-svn: 92245
* move a few more symbols to .rodata/.data.rel.roNuno Lopes2009-12-231-1/+1
| | | | llvm-svn: 92012
* Fix DISABLE_SMART_POINTERS buildDouglas Gregor2009-12-231-5/+6
| | | | llvm-svn: 92008
* Switch Sema::CreateOverloadedUnaryOp over to InitializationSequence.Douglas Gregor2009-12-231-3/+8
| | | | llvm-svn: 91948
* Switch parameter passing for overloaded binary operators toDouglas Gregor2009-12-221-7/+31
| | | | | | | InitializationSequence. Fixes the -fsyntax-only failure in llvm/lib/Transforms/Scalar/InstructionCombining.cpp. llvm-svn: 91921
* Eliminate the ASTContext argument to CXXConstructorDecl::isCopyConstructor, ↵Douglas Gregor2009-12-221-1/+1
| | | | | | since the context is available in the Decl llvm-svn: 91862
* When converting from a type to itself or one of its base classes via aDouglas Gregor2009-12-221-1/+2
| | | | | | | | | constructor call, the conversion is only a standard conversion sequence if that constructor is a copy constructor. This fixes PR5834 in a semi-lame way, because the "real" fix will be to move over to InitializationSequence. That will happen "soonish", but not now. llvm-svn: 91861
* When a template-id refers to a single function template, and theDouglas Gregor2009-12-211-0/+87
| | | | | | | | | | explicitly-specified template arguments are enough to determine the instantiation, and either template argument deduction fails or is not performed in that context, we can resolve the template-id down to a function template specialization (so sayeth C++0x [temp.arg.explicit]p3). Fixes PR5811. llvm-svn: 91852
* Allow pointer convesion of an objective-c pointer toFariborz Jahanian2009-12-161-2/+28
| | | | | | 'void *' to mimic gcc's behavior. (fixes radar 7477351). llvm-svn: 91570
* Shift things around so that it's easier to recover from a missingJohn McCall2009-12-161-54/+105
| | | | | | | | | function in a C++ call using an arbitrary call-expression type. Actually exploit this to fix the recovery implemented earlier. The diagnostic is still iffy, though. llvm-svn: 91538
* Introduce a centralized routine in Sema for diagnosing failed lookups (whenJohn McCall2009-12-161-1/+49
| | | | | | | | | used as expressions). In dependent contexts, try to recover by doing a lookup in previously-dependent base classes. We get better diagnostics out, but unfortunately the recovery fails: we need to turn it into a method call expression, not a bare call expression. Thus this is still a WIP. llvm-svn: 91525
* Fix semantic diagnostics that embed English works, from Nicola Gigante!Douglas Gregor2009-12-161-16/+16
| | | | llvm-svn: 91503
* Fix PR5756 a different, better way: we don't have a "pointerDouglas Gregor2009-12-131-25/+20
| | | | | | | conversion to void*" according to C++ [over.ics.rank]p4b2 if the type we're converting from is not a pointer. llvm-svn: 91254
* Don't assume that all conversions to a void pointer are convertingDouglas Gregor2009-12-131-20/+25
| | | | | | from a PointerType. Fixes PR5756. llvm-svn: 91253
* Consider conversion of objective-c pointer to 'bool' a Fariborz Jahanian2009-12-111-1/+1
| | | | | | valid standard conversion to match g++'s behaviour. llvm-svn: 91157
* Implement redeclaration checking and hiding semantics for using ↵John McCall2009-12-101-4/+11
| | | | | | | | | | | declarations. There are a couple of O(n^2) operations in this, some analogous to the usual O(n^2) redeclaration problem and some not. In particular, retroactively removing shadow declarations when they're hidden by later decls is pretty unfortunate. I'm not yet convinced it's worse than the alternative, though. llvm-svn: 91045
* Reimplement reference initialization (C++ [dcl.init.ref]) using theDouglas Gregor2009-12-091-11/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | new notion of an "initialization sequence", which encapsulates the computation of the initialization sequence along with diagnostic information and the capability to turn the computed sequence into an expression. At present, I've only switched one CheckReferenceInit callers over to this new mechanism; more will follow. Aside from (hopefully) being much more true to the standard, the diagnostics provided by this reference-initialization code are a bit better than before. Some examples: p5-var.cpp:54:12: error: non-const lvalue reference to type 'struct Derived' cannot bind to a value of unrelated type 'struct Base' Derived &dr2 = b; // expected-error{{non-const lvalue reference to ... ^ ~ p5-var.cpp:55:9: error: binding of reference to type 'struct Base' to a value of type 'struct Base const' drops qualifiers Base &br3 = bc; // expected-error{{drops qualifiers}} ^ ~~ p5-var.cpp:57:15: error: ambiguous conversion from derived class 'struct Diamond' to base class 'struct Base': struct Diamond -> struct Derived -> struct Base struct Diamond -> struct Derived2 -> struct Base Base &br5 = diamond; // expected-error{{ambiguous conversion from ... ^~~~~~~ p5-var.cpp:59:9: error: non-const lvalue reference to type 'long' cannot bind to a value of unrelated type 'int' long &lr = i; // expected-error{{non-const lvalue reference to type ... ^ ~ p5-var.cpp:74:9: error: non-const lvalue reference to type 'struct Base' cannot bind to a temporary of type 'struct Base' Base &br1 = Base(); // expected-error{{non-const lvalue reference to ... ^ ~~~~~~ p5-var.cpp:102:9: error: non-const reference cannot bind to bit-field 'i' int & ir1 = (ib.i); // expected-error{{non-const reference cannot ... ^ ~~~~~~ p5-var.cpp:98:7: note: bit-field is declared here int i : 17; // expected-note{{bit-field is declared here}} ^ llvm-svn: 90992
* First pass at implementing C++ enum semantics: calculate (and store) anJohn McCall2009-12-091-9/+11
| | | | | | | | | | | | "integer promotion" type associated with an enum decl, and use this type to determine which type to promote to. This type obeys C++ [conv.prom]p2 and is therefore generally signed unless the range of the enumerators forces it to be unsigned. Kills off a lot of false positives from -Wsign-compare in C++, addressing rdar://7455616 llvm-svn: 90965
* Whitespace fix.Eli Friedman2009-12-091-2/+1
| | | | llvm-svn: 90949
* Rename Sema::IsOverload to Sema::CheckOverload. Teach it to ignore unresolvedJohn McCall2009-12-091-13/+15
| | | | | | | | using value decls; we optimistically assume they won't turn into conflicts. Teach it to tell the caller *why* the function doesn't overload with the returned decl; this will be useful for using hiding. llvm-svn: 90939
OpenPOWER on IntegriCloud