summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Implement C++0x nullptr.Sebastian Redl2009-05-101-1/+9
| | | | llvm-svn: 71405
* When determining whether an expression refers to a bit-field, lookDouglas Gregor2009-05-021-9/+8
| | | | | | | | | into the left-hand side of an assignment expression. This completes most of PR3500; the only remaining part is to deal with the GCC-specific implementation-defined behavior for "unsigned long" (and other) bit-fields. llvm-svn: 70623
* Get rid of the implicit deref call when calling member functions where the ↵Anders Carlsson2009-05-011-12/+22
| | | | | | base is a pointer. llvm-svn: 70562
* Implement semantic analysis for transparent unions. This is largelyDouglas Gregor2009-04-291-1/+5
| | | | | | | based on a patch from Anders Johnsen. CodeGen support is incomplete, in that we do not properly coerce to the first field's type. llvm-svn: 70419
* Conditional operator C++ checking complete. What issues remain are in more ↵Sebastian Redl2009-04-191-12/+67
| | | | | | general code. llvm-svn: 69555
* Fix a crash bug when comparing overload quality of conversion operators with ↵Sebastian Redl2009-04-161-12/+49
| | | | | | | | | | | conversion constructors. Remove an atrocious amount of trailing whitespace in the overloaded operator mangler. Sorry, couldn't help myself. Change the DeclType parameter of Sema::CheckReferenceInit to be passed by value instead of reference. It wasn't changed anywhere. Let the parser handle C++'s irregular grammar around assignment-expression and conditional-expression. And finally, the reason for all this stuff: implement C++ semantics for the conditional operator. The implementation is complete except for determining lvalueness. llvm-svn: 69299
* Parse deleted member functions. Parsing member declarations goes through a ↵Sebastian Redl2009-04-121-21/+39
| | | | | | | | | different code path that I forgot previously. Implement the rvalue reference overload dance for returning local objects. Returning a local object first tries to find a move constructor now. The error message when no move constructor is defined (or is not applicable) and the copy constructor is deleted is quite ugly, though. llvm-svn: 68902
* implement rdar://6780761, making sema reject some code that otherwiseChris Lattner2009-04-121-6/+8
| | | | | | crashes codegen. llvm-svn: 68891
* Propagate the ASTContext to various AST traversal and lookup functions.Douglas Gregor2009-04-091-4/+6
| | | | | | No functionality change (really). llvm-svn: 68726
* Hopefully fix the rval regressions. Thanks to Chris for pointing out that ↵Sebastian Redl2009-03-291-0/+2
| | | | | | valgrind complains. llvm-svn: 68021
* Reintroduce r67870 (rval ref overloading), since I can't reproduce any test ↵Sebastian Redl2009-03-291-7/+8
| | | | | | failures on i386 or x86_64. If this fails for someone, please contact me. llvm-svn: 67999
* QualType can go in SmallPtrSet now, simplify code that used to haveChris Lattner2009-03-291-42/+4
| | | | | | to work around this. llvm-svn: 67968
* Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for aChris Lattner2009-03-281-1/+1
| | | | | | | | | | | | | | | | | | | | pointer. Its purpose in life is to be a glorified void*, but which does not implicitly convert to void* or other OpaquePtr's with a different UID. Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>. Change the entire parser/sema interface to use DeclPtrTy instead of DeclTy*. This makes the C++ compiler enforce that these aren't convertible to other opaque types. We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc, but I don't plan to do that in the short term. The one outstanding known problem with this patch is that we lose the bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to bitmangle the success bit into the low bit of DeclPtrTy. I will rectify this with a subsequent patch. llvm-svn: 67952
* Revert Sebastian's rvalue patch (r67870) since it caused test failures inAnders Carlsson2009-03-281-8/+7
| | | | | | | | SemaCXX//overload-member-call.cpp SemaCXX//overloaded-operator.cpp SemaTemplate//instantiate-method.cpp llvm-svn: 67912
* Better overload resolution for rvalue references.Sebastian Redl2009-03-271-7/+8
| | | | llvm-svn: 67870
* Type::isObjectType now implements the (more sensible) C++ definitionDouglas Gregor2009-03-241-3/+2
| | | | | | | | | | | | | | | | | | of "object type" rather than the C definition of "object type". The difference is that C's "object type" excludes incomplete types such as struct X; However, C's definition also makes it far too easy to use isObjectType as a means to detect incomplete types when in fact we should use other means (e.g., Sema::RequireCompleteType) that cope with C++ semantics, including template instantiation. I've already audited every use of isObjectType and isIncompleteType to ensure that they are doing the right thing for both C and C++, so this is patch does not change any functionality. llvm-svn: 67648
* Disallow catching exceptions by rvalue reference.Sebastian Redl2009-03-221-6/+17
| | | | llvm-svn: 67492
* Almost complete implementation of rvalue references. One bug, and a few ↵Sebastian Redl2009-03-161-21/+30
| | | | | | unclear areas. Maybe Doug can shed some light on some of the fixmes. llvm-svn: 67059
* Implement template instantiation for the prefix unary operators. AsDouglas Gregor2009-03-131-1/+149
| | | | | | | | always, refactored the existing logic to tease apart the parser action and the semantic analysis shared by the parser and template instantiation. llvm-svn: 66987
* Refactor the way we handle operator overloading and templateDouglas Gregor2009-03-131-43/+206
| | | | | | | | | | | | | | | | | | | | | | | | | instantiation for binary operators. This change moves most of the operator-overloading code from the parser action ActOnBinOp to a new, parser-independent semantic checking routine CreateOverloadedBinOp. Of particular importance is the fact that CreateOverloadedBinOp does *not* perform any name lookup based on the current parsing context (it doesn't take a Scope*), since it has to be usable during template instantiation, when there is no scope information. Rather, it takes a pre-computed set of functions that are visible from the context or via argument-dependent lookup, and adds to that set any member operators and built-in operator candidates. The set of functions is computed in the parser action ActOnBinOp based on the current context (both operator name lookup and argument-dependent lookup). Within a template, the set computed by ActOnBinOp is saved within the type-dependent AST node and is augmented with the results of argument-dependent name lookup at instantiation time (see TemplateExprInstantiator::VisitCXXOperatorCallExpr). Sadly, we can't fully test this yet. I'll follow up with template instantiation for sizeof so that the real fun can begin. llvm-svn: 66923
* Improve the representation of operator expressions like "x + y" withinDouglas Gregor2009-03-131-106/+38
| | | | | | | | | | | | | | | | C++ templates. In particular, keep track of the overloaded operators that are visible from the template definition, so that they can be merged with those operators visible via argument-dependent lookup at instantiation time. Refactored the lookup routines for argument-dependent lookup and for operator name lookup, so they can be called without immediately adding the results to an overload set. Instantiation of these expressions is completely wrong. I'll work on that next. llvm-svn: 66851
* Eliminate CXXRecordTypeDouglas Gregor2009-02-281-36/+38
| | | | llvm-svn: 65671
* Create a new TypeNodes.def file that enumerates all of the types,Douglas Gregor2009-02-261-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | giving them rough classifications (normal types, never-canonical types, always-dependent types, abstract type representations) and making it far easier to make sure that we've hit all of the cases when decoding types. Switched some switch() statements on the type class over to using this mechanism, and filtering out those things we don't care about. For example, CodeGen should never see always-dependent or non-canonical types, while debug info generation should never see always-dependent types. More switch() statements on the type class need to be moved over to using this approach, so that we'll get warnings when we add a new type then fail to account for it somewhere in the compiler. As part of this, some types have been renamed: TypeOfExpr -> TypeOfExprType FunctionTypeProto -> FunctionProtoType FunctionTypeNoProto -> FunctionNoProtoType There shouldn't be any functionality change... llvm-svn: 65591
* Drop uses of getAsPointerLikeType.Daniel Dunbar2009-02-261-1/+3
| | | | | | - No functionality change. llvm-svn: 65563
* Provide a proper source location when building an implicit dereference. ↵Douglas Gregor2009-02-191-1/+1
| | | | | | Fixes PR3600 llvm-svn: 64993
* Downgrade complaints about calling unavailable functions to a warningDouglas Gregor2009-02-181-2/+51
| | | | | | | | | | | | | | | | | | (as GCC does), except when we've performed overload resolution and found an unavailable function: in this case, we actually error. Merge the checking of unavailable functions with the checking for deprecated functions. This unifies a bit of code, and makes sure that we're checking for unavailable functions in the right places. Also, this check can cause an error. We may, eventually, want an option to make "unavailable" warnings into errors. Implement much of the logic needed for C++0x deleted functions, which are effectively the same as "unavailable" functions (but always cause an error when referenced). However, we don't have the syntax to specify deleted functions yet :) llvm-svn: 64955
* remove "; candidates are/is:" from various ambiguity diagnostics.Chris Lattner2009-02-171-9/+5
| | | | | | 2 out of 2 people on irc prefer them gone :) llvm-svn: 64749
* Several cleanups:Steve Naroff2009-02-121-10/+10
| | | | | | | | - rename isObjCIdType/isObjCClassType -> isObjCIdStructType/isObjCClassStructType. The previous name didn't do what you would expect. - add back isObjCIdType/isObjCClassType to do what you would expect. Not currently used, however many of the isObjCIdStructType/isObjCClassStructType clients could be converted over time. - move static Sema function areComparableObjCInterfaces to ASTContext (renamed to areComparableObjCPointerTypes, since it now operates on pointer types). llvm-svn: 64385
* Expand the definition of a complex promotion to include complex ->Douglas Gregor2009-02-121-3/+7
| | | | | | | | complex conversions where the conversion between the real types is an integral promotion. This is how G++ handles complex promotions for its complex integer extension. llvm-svn: 64344
* Introduce _Complex conversions into the function overloadingDouglas Gregor2009-02-121-1/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | system. Since C99 doesn't have overloading and C++ doesn't have _Complex, there is no specification for this. Here's what I think makes sense. Complex conversions come in several flavors: - Complex promotions: a complex -> complex conversion where the underlying real-type conversion is a floating-point promotion. GCC seems to call this a promotion, EDG does something else. This is given "promotion" rank for determining the best viable function. - Complex conversions: a complex -> complex conversion that is not a complex promotion. This is given "conversion" rank for determining the best viable function. - Complex-real conversions: a real -> complex or complex -> real conversion. This is given "conversion" rank for determining the best viable function. These rules are the same for C99 (when using the "overloadable" attribute) and C++. However, there is one difference in the handling of floating-point promotions: in C99, float -> long double and double -> long double are considered promotions (so we give them "promotion" rank), while C++ considers these conversions ("conversion" rank). llvm-svn: 64343
* Initial implementation of function overloading in C.Douglas Gregor2009-02-111-21/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a new attribute, "overloadable", that enables C++ function overloading in C. The attribute can only be added to function declarations, e.g., int *f(int) __attribute__((overloadable)); If the "overloadable" attribute exists on a function with a given name, *all* functions with that name (and in that scope) must have the "overloadable" attribute. Sets of overloaded functions with the "overloadable" attribute then follow the normal C++ rules for overloaded functions, e.g., overloads must have different parameter-type-lists from each other. When calling an overloaded function in C, we follow the same overloading rules as C++, with three extensions to the set of standard conversions: - A value of a given struct or union type T can be converted to the type T. This is just the identity conversion. (In C++, this would go through a copy constructor). - A value of pointer type T* can be converted to a value of type U* if T and U are compatible types. This conversion has Conversion rank (it's considered a pointer conversion in C). - A value of type T can be converted to a value of type U if T and U are compatible (and are not both pointer types). This conversion has Conversion rank (it's considered to be a new kind of conversion unique to C, a "compatible" conversion). Known defects (and, therefore, next steps): 1) The standard-conversion handling does not understand conversions involving _Complex or vector extensions, so it is likely to get these wrong. We need to add these conversions. 2) All overloadable functions with the same name will have the same linkage name, which means we'll get a collision in the linker (if not sooner). We'll need to mangle the names of these functions. llvm-svn: 64336
* Add semantic checking for template arguments that correspond toDouglas Gregor2009-02-111-0/+19
| | | | | | | | | | | | | | non-type template parameters that are references to functions or pointers to member functions. Did a little bit of refactoring so that these two cases, along with the handling of non-type template parameters that are pointers to functions, are handled by the same path. Also, tweaked FixOverloadedFunctionReference to cope with member function pointers. This is a necessary step for getting all of the fun member pointer conversions working outside of template arguments, too. llvm-svn: 64277
* Add partial semantic checking of template arguments that are meant forDouglas Gregor2009-02-111-1/+1
| | | | | | | | | | | | | | | | | | | non-type template parameters of pointer-to-object and pointer-to-function type. The most fun part of this is the use of overload resolution to pick a function from the set of overloaded functions that comes in as a template argument. Also, fixed two minor bugs in this area: - We were allowing non-type template parameters of type pointer to void. - We weren't patching up an expression that refers to an overloaded function set via "&f" properly. We're still not performing complete checking of the expression to be sure that it is referring to an object or function with external linkage (C++ [temp.arg.nontype]p1). llvm-svn: 64266
* CallExpr now uses ASTContext's allocate to allocate/delete its array of ↵Ted Kremenek2009-02-091-4/+9
| | | | | | subexpressions. llvm-svn: 64162
* Overhaul of Stmt allocation:Ted Kremenek2009-02-071-17/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Made allocation of Stmt objects using vanilla new/delete a *compiler error* by making this new/delete "protected" within class Stmt. - Now the only way to allocate Stmt objects is by using the new operator that takes ASTContext& as an argument. This ensures that all Stmt nodes are allocated from the same (pool) allocator. - Naturally, these two changes required that *all* creation sites for AST nodes use new (ASTContext&). This is a large patch, but the majority of the changes are just this mechanical adjustment. - The above changes also mean that AST nodes can no longer be deallocated using 'delete'. Instead, one most do StmtObject->Destroy(ASTContext&) or do ASTContextObject.Deallocate(StmtObject) (the latter not running the 'Destroy' method). Along the way I also... - Made CompoundStmt allocate its array of Stmt* using the allocator in ASTContext (previously it used std::vector). There are a whole bunch of other Stmt classes that need to be similarly changed to ensure that all memory allocated for ASTs comes from the allocator in ASTContext. - Added a new smart pointer ExprOwningPtr to Sema.h. This replaces the uses of llvm::OwningPtr within Sema, as llvm::OwningPtr used 'delete' to free memory instead of a Stmt's 'Destroy' method. Big thanks to Doug Gregor for helping with the acrobatics of making 'new/delete' private and the new smart pointer ExprOwningPtr! llvm-svn: 63997
* Remove some non-ASCII in comment.Sebastian Redl2009-02-051-2/+2
| | | | llvm-svn: 63866
* Implement taking address of member functions, including overloaded ones.Sebastian Redl2009-02-041-6/+28
| | | | llvm-svn: 63779
* Bring operator name lookup (as required for C++ operator overloading)Douglas Gregor2009-02-041-51/+22
| | | | | | | into the general name-lookup fold. This cleans up some ugly, not-quite-working code in the handling of operator overloading. llvm-svn: 63735
* Fix our semantic analysis ofDouglas Gregor2009-02-041-9/+45
| | | | | | | | | | | | | | | | | | | | | unqualified-id '(' in C++. The unqualified-id might not refer to any declaration in our current scope, but declarations by that name might be found via argument-dependent lookup. We now do so properly. As part of this change, CXXDependentNameExpr, which was previously designed to express the unqualified-id in the above constructor within templates, has become UnresolvedFunctionNameExpr, which does effectively the same thing but will work for both templates and non-templates. Additionally, we cope with all unqualified-ids, since ADL also applies in cases like operator+(x, y) llvm-svn: 63733
* Initial implementation of argument dependent lookup (a.k.a. ADL,Douglas Gregor2009-02-041-9/+96
| | | | | | | | | | | | a.k.a. Koenig lookup) in C++. Most of the pieces are in place, but for two: - In an unqualified call g(x), even if the name does not refer to anything in the current scope, we can still find functions named "g" based on ADL. We don't yet have this ability. - ADL will need updating for friend functions and templates. llvm-svn: 63692
* Steve set me straight on this one. GCC was right, EDG was wrong: theDouglas Gregor2009-02-021-3/+5
| | | | | | | | | | direct-initialization following a user-defined conversion can select any constructor; it just can't employ any user-defined conversions. So we ban those conversions and classify the constructor call based on the relationship between the "from" and "to" types in the conversion. llvm-svn: 63554
* Improve our handling of the second step in a user-defined conversionDouglas Gregor2009-01-301-14/+34
| | | | | | | | | | | | | | sequence. Previously, we weren't permitting the second step to call copy constructors, which left user-defined conversion sequences surprisingly broken. Now, we perform overload resolution among all of the constructors, but only accept the result if it makes the conversion a standard conversion. Note that this behavior is different from both GCC and EDG (which don't agree with each other, either); I've submitted a core issue on the matter. llvm-svn: 63450
* Eliminated LookupCriteria, whose creation was causing a bottleneck forDouglas Gregor2009-01-301-3/+2
| | | | | | | | | | | | | | | | | | LookupName et al. Instead, use an enum and a bool to describe its contents. Optimized the C/Objective-C path through LookupName, eliminating any unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing some code and arguments that are no longer used. Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers over to LookupName, LookupQualifiedName, or LookupParsedName, as appropriate. All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and -disable-free. Plus, we're down to three name-lookup routines. llvm-svn: 63354
* Implement pointer to member handling in static_cast.Sebastian Redl2009-01-281-43/+42
| | | | | | | Fix a stupid mistake in UnwrapSimilarPointers that made any two member pointers compatible as long as the pointee was the same. Make a few style corrections as suggested by Chris. llvm-svn: 63215
* Implement implicit conversions for pointers-to-member.Sebastian Redl2009-01-251-6/+101
| | | | llvm-svn: 62971
* Remove ScopedDecl, collapsing all of its functionality into Decl, soDouglas Gregor2009-01-201-8/+5
| | | | | | | | | | | | | | | | that every declaration lives inside a DeclContext. Moved several things that don't have names but were ScopedDecls (and, therefore, NamedDecls) to inherit from Decl rather than NamedDecl, including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't store empty DeclarationNames for these things, nor do we try to insert them into DeclContext's lookup structure. The serialization tests are temporarily disabled. We'll re-enable them once we've sorted out the remaining ownership/serialiazation issues between DeclContexts and TranslationUnion, DeclGroups, etc. llvm-svn: 62562
* Convert more expression actions to smart pointers.Sebastian Redl2009-01-191-6/+8
| | | | | | Fix type of logical negation for C++. llvm-svn: 62475
* Use a single function for doing vararg argument promotion. Also, make sure ↵Anders Carlsson2009-01-161-7/+1
| | | | | | to do the promotion before checking the type - fixes PR3340. llvm-svn: 62323
* Introduce support for C++0x explicit conversion operators (N2437)Douglas Gregor2009-01-141-23/+71
| | | | | | | | | | Small cleanup in the handling of user-defined conversions. Also, implement an optimization when constructing a call. We avoid recomputing implicit conversion sequences and instead use those conversion sequences that we computed as part of overload resolution. llvm-svn: 62231
* Warn when someone tries to pass a variable with a non-POD type to a varargs ↵Anders Carlsson2009-01-131-0/+7
| | | | | | function/method/block. llvm-svn: 62148
OpenPOWER on IntegriCloud