summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix argument-passing bugs in a call to objectDouglas Gregor2009-01-131-10/+16
| | | | llvm-svn: 62147
* Add the proper restrictions on the left-hand argument of a built-inDouglas Gregor2009-01-131-9/+31
| | | | | | assignment operator candidate (C++ [over.match.oper]p4). llvm-svn: 62128
* Make sure we don't name a constructor or destructor with a qualifiedDouglas Gregor2009-01-131-1/+1
| | | | | | type. It leads to very weird errors. llvm-svn: 62124
* This is a large/messy diff that unifies the ObjC AST's with DeclContext.Steve Naroff2009-01-081-4/+4
| | | | | | | | | | | | | | | - ObjCContainerDecl's (ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl), ObjCCategoryImpl, & ObjCImplementation are all DeclContexts. - ObjCMethodDecl is now a ScopedDecl (so it can play nicely with DeclContext). - ObjCContainerDecl now does iteration/lookup using DeclContext infrastructure (no more linear search:-) - Removed ASTContext argument to DeclContext::lookup(). It wasn't being used and complicated it's use from an ObjC AST perspective. - Added Sema::ProcessPropertyDecl() and removed Sema::diagnosePropertySetterGetterMismatch(). - Simplified Sema::ActOnAtEnd() considerably. Still more work to do. - Fixed an incorrect casting assumption in Sema::getCurFunctionOrMethodDecl(), now that ObjCMethodDecl is a ScopedDecl. - Removed addPropertyMethods from ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl. This passes all the tests on my machine. Since many of the changes are central to the way ObjC finds it's methods, I expect some fallout (and there are still a handful of FIXME's). Nevertheless, this should be a step in the right direction. llvm-svn: 61929
* Initial implementation of anonymous unions (and, as a GNU extension,Douglas Gregor2009-01-071-1/+1
| | | | | | | | | | | | structures and classes) in C++. Covers name lookup and the synthesis and member access for the unnamed objects/fields associated with anonymous unions. Some C++ semantic checks are still missing (anonymous unions can't have function members, static data members, etc.), and there is no support for anonymous structs or unions in C. llvm-svn: 61840
* Don't push OverloadedFunctionDecls onto the chain of declarationsDouglas Gregor2008-12-231-17/+15
| | | | | | | | attached to an identifier. Instead, all overloaded functions will be pushed into scope, and we'll synthesize an OverloadedFunctionDecl on the fly when we need it. llvm-svn: 61386
* Add some block-pointer conversions in C++Douglas Gregor2008-12-231-11/+20
| | | | llvm-svn: 61359
* Don't explicitly represent OverloadedFunctionDecls withinDouglas Gregor2008-12-231-64/+22
| | | | | | | | | | | | | | | | | | | | | | | | DeclContext. Instead, just keep the list of currently-active declarations and only build the OverloadedFunctionDecl when we absolutely need it. This is a half-step toward eliminating the need to explicitly build OverloadedFunctionDecls that store sets of overloaded functions. This was suggested by Argiris a while back, and it's a good thing for several reasons: first, it eliminates the messy logic that currently tries to keep the OverloadedFunctionDecl in sync with the declarations that are being added. Second, it will (eventually) eliminate the need to allocate memory for overload sets, which could help performance. Finally, it helps set us up for when name lookup can return multiple (possibly ambiguous) results, as can happen with lookup of class members in C++. Next steps: make the IdentifierResolver store overloads as separate entries in its list rather than replacing them with an OverloadedFunctionDecl now, then see how far we can go toward eliminating OverloadedFunctionDecl entirely. llvm-svn: 61357
* Support conversion from a null pointer constant o any Objective-C object ↵Douglas Gregor2008-12-221-0/+7
| | | | | | pointer type. Fixes rdar://problem/6463298 llvm-svn: 61340
* Add support for calls to overloaded member functions. Things to note:Douglas Gregor2008-12-221-12/+136
| | | | | | | | | | | | - Overloading has to cope with having both static and non-static member functions in the overload set. - The call may or may not have an implicit object argument, depending on the syntax (x.f() vs. f()) and the context (static vs. non-static member function). - We now generate MemberExprs for implicit member access expression. - We now cope with mutable whenever we're building MemberExprs. llvm-svn: 61329
* Add support for member references (E1.E2, E1->E2) with C++ semantics,Douglas Gregor2008-12-201-19/+20
| | | | | | | | | | which can refer to static data members, enumerators, and member functions as well as to non-static data members. Implement correct lvalue computation for member references in C++. Compute the result type of non-static data members of reference type properly. llvm-svn: 61294
* Support more implicit conversions for Objective-C types. Addresses ↵Douglas Gregor2008-12-191-9/+110
| | | | | | <rdar://problem/6458293>. llvm-svn: 61255
* Allow downcasts of pointers to Objective-C interfaces, with aDouglas Gregor2008-12-191-4/+25
| | | | | | | warning. This matches GCC's behavior and addresses <rdar://problem/6458293>. llvm-svn: 61246
* Add some more implicit conversions for Objective-C++Douglas Gregor2008-12-181-0/+20
| | | | llvm-svn: 61229
* Place constructors and destructors into the DeclContext of the class,Douglas Gregor2008-12-151-5/+19
| | | | | | | | | | | | just like all other members, and remove the special variables in CXXRecordDecl to store them. This eliminates a lot of special-case code for constructors and destructors, including ActOnConstructor/ActOnDeclarator and special lookup rules in LookupDecl. The result is far more uniform and manageable. Diagnose the redeclaration of member functions. llvm-svn: 61048
* In C++, set the type of each of the enumerators in an enumeration toDouglas Gregor2008-12-121-3/+5
| | | | | | | | | | | | | | | the type of the enumeration once the enumeration has been defined. Fix the overloading test-case to properly create enums that promote the way we want them to. Implement C++0x promotions from enumeration types to long long/unsigned long long. We're using these promotions in Carbon.h (since long long is a common extension). Fixes PR clang/2954: http://llvm.org/bugs/show_bug.cgi?id=2954 llvm-svn: 60917
* Address some comments on the name lookup/DeclContext patch from ChrisDouglas Gregor2008-12-111-3/+3
| | | | llvm-svn: 60897
* Unifies the name-lookup mechanisms used in various parts of the ASTDouglas Gregor2008-12-111-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and separates lexical name lookup from qualified name lookup. In particular: * Make DeclContext the central data structure for storing and looking up declarations within existing declarations, e.g., members of structs/unions/classes, enumerators in C++0x enums, members of C++ namespaces, and (later) members of Objective-C interfaces/implementations. DeclContext uses a lazily-constructed data structure optimized for fast lookup (array for small contexts, hash table for larger contexts). * Implement C++ qualified name lookup in terms of lookup into DeclContext. * Implement C++ unqualified name lookup in terms of qualified+unqualified name lookup (since unqualified lookup is not purely lexical in C++!) * Limit the use of the chains of declarations stored in IdentifierInfo to those names declared lexically. * Eliminate CXXFieldDecl, collapsing its behavior into FieldDecl. (FieldDecl is now a ScopedDecl). * Make RecordDecl into a DeclContext and eliminates its Members/NumMembers fields (since one can just iterate through the DeclContext to get the fields). llvm-svn: 60878
* 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
OpenPOWER on IntegriCloud