summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Implemented an implicit conversion from "noreturn" function types (andDouglas Gregor2009-12-091-3/+29
| | | | | | | | | | | | | | pointers thereof) to their corresponding non-noreturn function types. This conversion is considered an exact match for overload-resolution purposes. Note that we are a little more strict that GCC is, because we encode noreturn in the type system, but that's a Good Thing (TM) because it does not allow us to pretend that potentially-returning function pointers are non-returning function pointers. Fxies PR5620. llvm-svn: 90913
* Honor using declarations in overload resolution. Most of the code forJohn McCall2009-12-031-56/+86
| | | | | | | | | | | overloaded-operator resolution is wildly untested, but the parallel code for methods seems to satisfy some trivial tests. Also change some overload-resolution APIs to take a type instead of an expression, which lets us avoid creating a spurious CXXThisExpr when resolving implicit member accesses. llvm-svn: 90410
* r90313, in which OverloadedFunctionDecl is removed and never spoken of again.John McCall2009-12-021-22/+23
| | | | llvm-svn: 90313
* Rework how we support C++ implicit member accesses. If we can resolve anJohn McCall2009-12-011-42/+75
| | | | | | | | | | | | | | | implicit member access to a specific declaration, go ahead and create it as a DeclRefExpr or a MemberExpr (with implicit CXXThisExpr base) as appropriate. Otherwise, create an UnresolvedMemberExpr or DependentScopeMemberExpr with a null base expression. By representing implicit accesses directly in the AST, we get the ability to correctly delay the decision about whether it's actually an instance member access or not until resolution is complete. This permits us to correctly avoid diagnosing the 'problem' of 'MyType::foo()' where the relationship to the type isn't really known until instantiation. llvm-svn: 90266
* Eliminate the use of OverloadedFunctionDecl in member expressions.John McCall2009-11-301-51/+41
| | | | | | | | Create a new UnresolvedMemberExpr for these lookups. Assorted hackery around qualified member expressions; this will all go away when we implement the correct (i.e. extremely delayed) implicit-member semantics. llvm-svn: 90161
* Remove remaining VISIBILITY_HIDDEN from anonymous namespaces.Benjamin Kramer2009-11-281-1/+0
| | | | llvm-svn: 90044
* Rip out TemplateIdRefExpr and make UnresolvedLookupExpr and John McCall2009-11-241-61/+30
| | | | | | | | | | | | DependentScopeDeclRefExpr support storing templateids. Unite the common code paths between ActOnDeclarationNameExpr and ActOnTemplateIdExpr. This gets us to a point where we don't need to store function templates in the AST using TemplateNames, which is critical to ripping out OverloadedFunction. Also resolves a few FIXMEs. llvm-svn: 89785
* Do not mark declarations as used when performing overload resolution. Fixes ↵Douglas Gregor2009-11-231-0/+15
| | | | | | PR5541 llvm-svn: 89652
* Centralize and complete the computation of value- and type-dependence for ↵Douglas Gregor2009-11-231-10/+5
| | | | | | DeclRefExprs llvm-svn: 89649
* Encapsulate "an array of TemplateArgumentLocs and two angle bracket ↵John McCall2009-11-231-71/+56
| | | | | | | | | | locations" into a new class. Use it pervasively throughout Sema. My fingers hurt. llvm-svn: 89638
* Consider a FunctionTemplate to be an overload all on its lonesome. TrackJohn McCall2009-11-221-3/+8
| | | | | | this information through lookup rather than rederiving it. llvm-svn: 89570
* Overload resolution doesn't decide whether to do ADL or not anymore; stoppingJohn McCall2009-11-211-12/+3
| | | | | | threading that state. llvm-svn: 89557
* "Incremental" progress on using expressions, by which I mean totally rippingJohn McCall2009-11-211-158/+138
| | | | | | | | | | | | | | | | | | | | | | into pretty much everything about overload resolution in order to wean BuildDeclarationNameExpr off LookupResult::getAsSingleDecl(). Replace UnresolvedFunctionNameExpr with UnresolvedLookupExpr, which generalizes the idea of a non-member lookup that we haven't totally resolved yet, whether by overloading, argument-dependent lookup, or (eventually) the presence of a function template in the lookup results. Incidentally fixes a problem with argument-dependent lookup where we were still performing ADL even when the lookup results contained something from a block scope. Incidentally improves a diagnostic when using an ObjC ivar from a class method. This just fell out from rewriting BuildDeclarationNameExpr's interaction with lookup, and I'm too apathetic to break it out. The only remaining uses of OverloadedFunctionDecl that I know of are in TemplateName and MemberExpr. llvm-svn: 89544
* Teach FixOverloadedFunctionReference to build new expression ASTs ratherDouglas Gregor2009-11-201-45/+112
| | | | | | | than tweaking existing ASTs, since we were (*gasp*) stomping on ASTs within templates. I'm glad we found this little stick of TNT early... llvm-svn: 89475
* Do overload resolution for compound assignment even if only the RHS is ↵Sebastian Redl2009-11-181-5/+7
| | | | | | overloadable. Compound assignment may be overloaded as a non-member, and anyway the overload resolution is necessary because it triggers implicit (used-defined) conversions. Fixes PR5512, but not really the deeper issues lurking. Those are standard defects. llvm-svn: 89268
* Overhaul previous-declaration and overload checking to work on lookup resultsJohn McCall2009-11-181-83/+85
| | | | | | | rather than NamedDecl*. This is a major step towards eliminating OverloadedFunctionDecl. llvm-svn: 89263
* Pretend destructors are const and volatile. This allows calling them with ↵Sebastian Redl2009-11-181-3/+6
| | | | | | const and/or volatile objects. Fixes PR5548. llvm-svn: 89244
OpenPOWER on IntegriCloud