summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add support for calls to dependent names within templates, e.g.,Douglas Gregor2008-12-061-2/+3
| | | | | | | | | | | | | | | | | | template<typename T> void f(T x) { g(x); // g is a dependent name, so don't even bother to look it up g(); // error: g is not a dependent name } Note that when we see "g(", we build a CXXDependentNameExpr. However, if none of the call arguments are type-dependent, we will force the resolution of the name "g" and replace the CXXDependentNameExpr with its result. GCC actually produces a nice error message when you make this mistake, and even offers to compile your code with -fpermissive. I'll do the former next, but I don't plan to do the latter. llvm-svn: 60618
* Add implicit conversions for Objective-C qualified ids, e.g.,Douglas Gregor2008-11-271-2/+18
| | | | | | | | | | | | id<P0> The intended overloading behavior of these entities isn't entirely clear, and GCC seems to have some strange limitations (e.g., the inability to overload on id<P0> vs. id<P1>). We'll want to revisit these semantics and determine just how Objective-C++ overloading should really work. llvm-svn: 60142
* Cleanup formattingDouglas Gregor2008-11-271-4/+8
| | | | llvm-svn: 60140
* Support block pointer conversions in C++. I'm storing the test case locally ↵Douglas Gregor2008-11-271-0/+15
| | | | | | until we can enable blocks in C++ llvm-svn: 60133
* Implement implicit conversions for Objective-C specific types, e.g., Douglas Gregor2008-11-261-46/+103
| | | | | | | | | | | | converting a pointer to one Objective-C interface into a pointer to another Objective-C interface, and conversions with 'id'. The semantics seems to match GCC, although they seem somewhat ad hoc. Fixed a few cases where we assumed the C++ definition of isObjectType, but were getting the C definition, causing failures in trouble with conversions to void pointers. llvm-svn: 60130
* Tweak the new ResolveOverloadedCallFn to just return a FunctionDecl. It ↵Douglas Gregor2008-11-261-13/+9
| | | | | | makes ActOnCallExpr simpler llvm-svn: 60094
* Move the overloading logic of Sema::ActOnCallExpr to a separate functionDouglas Gregor2008-11-261-0/+46
| | | | llvm-svn: 60093
* Change a whole lot of diagnostics to take QualType's directly Chris Lattner2008-11-241-10/+7
| | | | | | | | instead of converting them to strings first. This also fixes a bunch of minor inconsistencies in the diagnostics emitted by clang and adds a bunch of FIXME's to DiagnosticKinds.def. llvm-svn: 59948
* Rename NamedDecl::getName() to getNameAsString(). Replace a bunch of Chris Lattner2008-11-241-11/+11
| | | | | | | | | | | uses of getName() with uses of getDeclName(). This upgrades a bunch of diags to take DeclNames instead of std::strings. This also tweaks a couple of diagnostics to be cleaner and changes CheckInitializerTypes/PerformInitializationByConstructor to pass around DeclarationNames instead of std::strings. llvm-svn: 59947
* Implement a %plural modifier for complex plural forms in diagnostics. Use it ↵Sebastian Redl2008-11-221-11/+7
| | | | | | in the overload diagnostics. llvm-svn: 59871
* Fix overloading of non-static member functions that differ in their ↵Douglas Gregor2008-11-211-1/+1
| | | | | | cv-qualifiers llvm-svn: 59819
* Cleanup memory management in overloading of operator->, slightlyDouglas Gregor2008-11-211-8/+9
| | | | llvm-svn: 59791
* Don't print canonical types in overloading-related diagnosticsDouglas Gregor2008-11-211-5/+25
| | | | llvm-svn: 59789
* Add support for overloaded operator-> when used in a member accessDouglas Gregor2008-11-201-0/+80
| | | | | | expression (smart_ptr->mem). llvm-svn: 59732
* Fix strange quote charactersDouglas Gregor2008-11-201-4/+4
| | | | llvm-svn: 59729
* Implement the rest of C++ [over.call.object], which permits the objectDouglas Gregor2008-11-191-8/+153
| | | | | | | | | | being called to be converted to a reference-to-function, pointer-to-function, or reference-to-pointer-to-function. This is done through "surrogate" candidate functions that model the conversions from the object to the function (reference/pointer) and the conversions in the arguments. llvm-svn: 59674
* Support for calling overloaded function call operators (operator())Douglas Gregor2008-11-191-0/+150
| | | | | | | | | | | | | | with function call syntax, e.g., Functor f; f(x, y); This is the easy part of handling calls to objects of class type (C++ [over.call.object]). The hard part (coping with conversions from f to function pointer or reference types) will come later. Nobody uses that stuff anyway, right? :) llvm-svn: 59663
* Added operator overloading for unary operators, post-increment, andDouglas Gregor2008-11-191-33/+209
| | | | | | | | | | | | | post-decrement, including support for generating all of the built-in operator candidates for these operators. C++ and C have different rules for the arguments to the builtin unary '+' and '-'. Implemented both variants in Sema::ActOnUnaryOp. In C++, pre-increment and pre-decrement return lvalues. Update Expr::isLvalue accordingly. llvm-svn: 59638
* Switch several more Sema Diag methods over. This simplifies theChris Lattner2008-11-191-5/+5
| | | | | | | | __builtin_prefetch code to only emit one diagnostic per builtin_prefetch. While this has nothing to do with the rest of the patch, the code seemed like overkill when I was updating it. llvm-svn: 59588
* Built-in equality and relational operators have return type "bool" in C++,Douglas Gregor2008-11-191-12/+50
| | | | | | | | | | | | | | | | not "int". Fix a typo in the promotion of enumeration types that was causing some integral promotions to look like integral conversions (leading to extra ambiguities in overload resolution). Check for "acceptable" overloaded operators based on the types of the arguments. This is a somewhat odd check that is specified by the standard, but I can't see why it actually matters: the overload candidates it suppresses don't seem like they would ever be picked as the best candidates. llvm-svn: 59583
* Partial expansion of C++ operator overloading (for binary operators)Douglas Gregor2008-11-181-13/+272
| | | | | | | | | | | | | | | | | | | | | | | | to support operators defined as member functions, e.g., struct X { bool operator==(X&); }; Overloading with non-member operators is supported, and the special rules for the implicit object parameter (e.g., the ability for a non-const *this to bind to an rvalue) are implemented. This change also refactors and generalizes the code for adding overload candidates for overloaded operator calls (C++ [over.match.expr]), both to match the rules more exactly (name lookup of non-member operators actually ignores member operators) and to make this routine more reusable for the other overloaded operators. Testing for the initialization of the implicit object parameter is very light. More tests will come when we get support for calling member functions directly (e.g., o.m(a1, a2)). llvm-svn: 59564
* start converting Sema over to using its canonical Diag method.Chris Lattner2008-11-181-4/+3
| | | | llvm-svn: 59561
* Introduction the DeclarationName class, as a single, general method ofDouglas Gregor2008-11-171-1/+1
| | | | | | | | representing the names of declarations in the C family of languages. DeclarationName is used in NamedDecl to store the name of the declaration (naturally), and ObjCMethodDecl is now a NamedDecl. llvm-svn: 59441
* Some cleanup for the implementation of built-in operatorDouglas Gregor2008-11-131-7/+45
| | | | | | candidates. Thanks to Chris for the review! llvm-svn: 59260
* Implement support for operator overloading using candidate operatorDouglas Gregor2008-11-121-4/+581
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | functions for built-in operators, e.g., the builtin bool operator==(int const*, int const*) can be used for the expression "x1 == x2" given: struct X { operator int const*(); } x1, x2; The scheme for handling these built-in operators is relatively simple: for each candidate required by the standard, create a special kind of candidate function for the built-in. If overload resolution picks the built-in operator, we perform the appropriate conversions on the arguments and then let the normal built-in operator take care of it. There may be some optimization opportunity left: if we can reduce the number of built-in operator overloads we generate, overload resolution for these cases will go faster. However, one must be careful when doing this: GCC generates too few operator overloads in our little test program, and fails to compile it because none of the overloads it generates match. Note that we only support operator overload for non-member binary operators at the moment. The other operators will follow. As part of this change, ImplicitCastExpr can now be an lvalue. llvm-svn: 59148
* Basic support for taking the address of an overloaded functionDouglas Gregor2008-11-101-3/+112
| | | | llvm-svn: 59000
* Remove an out-of-date FIXMEDouglas Gregor2008-11-101-1/+0
| | | | llvm-svn: 58990
* Initial, partially-baked support for implicit user-defined conversions by ↵Douglas Gregor2008-11-071-3/+135
| | | | | | conversion functions llvm-svn: 58870
* Some cleanup of the cast checkers. Don't canonicalize types when not needed. ↵Sebastian Redl2008-11-041-0/+1
| | | | | | Use distinct diagnostics for distinct errors. llvm-svn: 58700
* Implicit support for direct initialization of objects of class type, e.g.,Douglas Gregor2008-11-031-2/+3
| | | | | | X x(5, 7); llvm-svn: 58641
* Standard conversion sequences now have a CopyConstructor field, toDouglas Gregor2008-11-031-30/+61
| | | | | | | | | | | | | | | cope with the case where a user-defined conversion is actually a copy construction, and therefore can be compared against other standard conversion sequences. While I called this a hack before, now I'm convinced that it's the right way to go. Compare overloads based on derived-to-base conversions that invoke copy constructors. Suppress user-defined conversions when attempting to call a user-defined conversion. llvm-svn: 58629
* Add implicitly-declared default and copy constructors to C++ classes,Douglas Gregor2008-11-031-15/+25
| | | | | | | | | | | when appropriate. Conversions for class types now make use of copy constructors. I've replaced the egregious hack allowing class-to-class conversions with a slightly less egregious hack calling these conversions standard conversions (for overloading reasons). llvm-svn: 58622
* Implement basic support for converting constructors in user-defined Douglas Gregor2008-10-311-32/+160
| | | | | | | | | | | | | conversions. Notes: - Overload resolution for converting constructors need to prohibit user-defined conversions (hence, the test isn't -verify safe yet). - We still use hacks for conversions from a class type to itself. This will be the case until we start implicitly declaring the appropriate special member functions. (That's next on my list) llvm-svn: 58513
* Implement semantic checking of static_cast and dynamic_cast.Sebastian Redl2008-10-311-13/+25
| | | | llvm-svn: 58509
* Implement overloading rules for reference bindingDouglas Gregor2008-10-291-15/+101
| | | | llvm-svn: 58381
* Tweak Sema::CheckReferenceInit so that it (optionally) computes an Douglas Gregor2008-10-291-5/+5
| | | | | | | | | | | ImplicitConversionSequence and, when doing so, following the specific rules of [over.best.ics]. The computation of the implicit conversion sequences implements C++ [over.ics.ref], but we do not (yet) have ranking for implicit conversion sequences that use reference binding. llvm-svn: 58357
* Implement initialization of a reference (C++ [dcl.init.ref]) as partDouglas Gregor2008-10-291-33/+82
| | | | | | | | | | | | | | | | | | | of copy initialization. Other pieces of the puzzle: - Try/Perform-ImplicitConversion now handles implicit conversions that don't involve references. - Try/Perform-CopyInitialization uses CheckSingleAssignmentConstraints for C. PerformCopyInitialization is now used for all argument passing and returning values from a function. - Diagnose errors with declaring references and const values without an initializer. (Uses a new Action callback, ActOnUninitializedDecl). We do not yet have implicit conversion sequences for reference binding, which means that we don't have any overloading support for reference parameters yet. llvm-svn: 58353
* Some cleanups for the ambiguous derived-to-base conversion checksDouglas Gregor2008-10-241-3/+3
| | | | llvm-svn: 58096
* First non-embarrassing cut at checking for ambiguous derived-to-base Douglas Gregor2008-10-241-1/+30
| | | | | | | | | | conversions. Added PerformImplicitConversion, which follows an implicit conversion sequence computed by TryCopyInitialization and actually performs the implicit conversions, including the extra check for ambiguity mentioned above. llvm-svn: 58071
* Add support for conversions from a pointer-to-derived to aDouglas Gregor2008-10-231-7/+138
| | | | | | | | | | | | pointer-to-base. Also, add overload ranking for pointer conversions (for both pointer-to-void and derived-to-base pointer conversions). Note that we do not yet diagnose derived-to-base pointer conversion errors that stem from ambiguous or inacessible base classes. These aren't handled during overload resolution; rather, when the conversion is actually used we go ahead and diagnose the error. llvm-svn: 58017
* Add representation of base classes in the AST, and verify that weDouglas Gregor2008-10-221-2/+2
| | | | | | | | don't have duplicated direct base classes. Seriliazation of base class specifiers is not yet implemented. llvm-svn: 57991
* QualType::isMoreQualifiedThan and isAtLeastAsQualifiedAs assert that weDouglas Gregor2008-10-221-0/+1
| | | | | | | | | aren't trying to compare with address-space qualifiers (for now). Clean up handing of DeclRefExprs in Expr::isLvalue and refactor part of the check into a static DeclCanBeLvalue. llvm-svn: 57980
* Implement ranking of standard conversion sequences by their qualificationDouglas Gregor2008-10-221-36/+116
| | | | | | | | | | | | conversions (e.g., comparing int* -> const int* against int* -> const volatile int*); see C++ 13.3.3.2p3 bullet 3. Add Sema::UnwrapSimilarPointerTypes to simplify the control flow of IsQualificationConversion and CompareQualificationConversion (and fix the handling of the int* -> volatile int* conversion in the former). llvm-svn: 57978
* Fix a thinko in the qualification-conversion check when the qualificaitons ↵Douglas Gregor2008-10-221-1/+1
| | | | | | are disjoint, and add some overloading-based tests of qualification conversions llvm-svn: 57942
* Initial step toward supporting qualification conversions (C++ 4.4).Douglas Gregor2008-10-211-4/+95
| | | | | | | | | | | | | | | | | | | | Changes: - Sema::IsQualificationConversion determines whether we have a qualification conversion. - Sema::CheckSingleAssignment constraints now follows the C++ rules in C++, performing an implicit conversion from the right-hand side to the type of the left-hand side rather than checking based on the C notion of "compatibility". We now rely on the implicit-conversion code to determine whether the conversion can happen or not. Sema::TryCopyInitialization has an ugly reference-related hack to cope with the initialization of references, for now. - When building DeclRefExprs, strip away the reference type, since there are no expressions whose type is a reference. We'll need to do this throughout Sema. - Expr::isLvalue now permits functions to be lvalues in C++ (but not in C). llvm-svn: 57935
* Preliminary support for function overloadingDouglas Gregor2008-10-211-0/+903
llvm-svn: 57909
OpenPOWER on IntegriCloud