summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaOverload.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Store bracket locations for array subscript expressions, from Erik Verbruggen!Douglas Gregor2011-07-151-3/+8
| | | | llvm-svn: 135275
* PR8800: When building a conversion to A& using a member operatorA&(), do not ↵Richard Smith2011-07-131-4/+4
| | | | | | require A to be a complete type. llvm-svn: 135101
* Fix missing braces around two statements that were intended to be partChandler Carruth2011-06-271-1/+2
| | | | | | | | | | | of a single if block. This is really annoying to track down and test. Silly changes to the test case caused it to stop showing up. I wish there were a more concrete way of asserting that a note attaches to the intended diagnostic. This fixes PR10195. llvm-svn: 133907
* Fix PR10187: when diagnosing a two-phase-lookup-related failure, don't ↵Richard Smith2011-06-261-8/+12
| | | | | | assert that any names we find are valid candidates for the call. llvm-svn: 133898
* Rename objc_lifetime -> objc_ownership, and modify diagnostics to talk about ↵Argyrios Kyrtzidis2011-06-241-1/+1
| | | | | | | | 'ownership', not 'lifetime'. rdar://9477613. llvm-svn: 133779
* Allow unavailable function calls inside unavailable functions in C++/ObjC++ ↵Argyrios Kyrtzidis2011-06-231-2/+13
| | | | | | as well. rdar://9660196 llvm-svn: 133672
* Accept no-return stripping conversions for pointer type arguments afterChandler Carruth2011-06-181-6/+6
| | | | | | | | | | | | | | | | | | | deducing template parameter types. Recently Clang began enforcing the more strict checking that the argument type and the deduced function parameter type (after substitution) match, but that only consideres qualification conversions. One problem with this patch is that we check noreturn conversions and qualification conversions independently. If a valid conversion would require *both*, perhaps interleaved with each other, it will be rejected. If this actually occurs (I'm not yet sure it does) and is in fact a problem (I'm not yet sure it is), there is a FIXME to implement more intelligent conversion checking. However, this step at least allows Clang to resume accepting valid code we're seeing in the wild. llvm-svn: 133327
* Automatic Reference Counting.John McCall2011-06-151-54/+244
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Fix a regression in the two-phase lookup diagnostics that switching theChandler Carruth2011-06-081-0/+3
| | | | | | | | namespace set algorithm (re-)introduced. We may not have seen the 'std' namespace, but we should still suggested associated namespaces. Easy fix, but a bit annoying to test. llvm-svn: 132744
* Richard Smith was correct about how the sets should be computed forChandler Carruth2011-06-051-11/+8
| | | | | | | | | this. My suggestion assumed a viable erase method for iterators on SmallPtrSet. This patch restores his original pattern. llvm-svn: 132673
* Fix PR10053: Improve diagnostics and error recovery for code which some ↵Richard Smith2011-06-051-8/+140
| | | | | | compilers incorrectly accept due to a lack of proper support for two-phase name lookup. llvm-svn: 132672
* Identity and non-identity standard conversion sequences can beDouglas Gregor2011-06-051-6/+4
| | | | | | | | | compared even when one is a reference binding and the other is not (<rdar://problem/9173984>), but the definition of an identity sequence does not involve lvalue-to-rvalue adjustments (PR9507). Fix both inter-related issues. llvm-svn: 132660
* Update our diagnostics to properly account for move operations.Alexis Hunt2011-05-251-2/+14
| | | | llvm-svn: 132096
* Audit and finish the implementation of C++0x nullptr, fixing twoDouglas Gregor2011-05-211-2/+21
| | | | | | | | | | | | | | minor issues along the way: - Non-type template parameters of type 'std::nullptr_t' were not permitted. - We didn't properly introduce built-in operators for nullptr ==, !=, <, <=, >=, or > as candidate functions . To my knowledge, there's only one (minor but annoying) part of nullptr that hasn't been implemented: catching a thrown 'nullptr' as a pointer or pointer-to-member, per C++0x [except.handle]p4. llvm-svn: 131813
* Allow implicit conversion from function pointer to void* in Microsoft mode. Francois Pichet2011-05-081-0/+9
| | | | | | Necessary to parse MFC code. llvm-svn: 131076
* Relax the conversion rules for Objective-C GC qualifiers aDouglas Gregor2011-05-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | bit by allowing __weak and __strong to be added/dropped as part of implicit conversions (qualification conversions in C++). A little history: GCC lets one add/remove/change GC qualifiers just about anywhere, implicitly. Clang did roughly the same before, but we recently normalized the semantics of qualifiers across the board to get a semantics that we could reason about (yay). Unfortunately, this tightened the screws a bit too much for GC qualifiers, where it's common to add/remove these qualifiers at will. Overall, we're still in better shape than we were before: we don't permit directly changing the GC qualifier (e.g., __weak -> __strong), so type safety is improved. More importantly, we're internally consistent in our handling of qualifiers, and the logic that allows adding/removing GC qualifiers (but not adding/removing address spaces!) only touches two obvious places. Fixes <rdar://problem/9402499>. llvm-svn: 131065
* Warn when trying to call a pure virtual member function in a class from the ↵Anders Carlsson2011-05-061-0/+13
| | | | | | class constructor/destructor. Fixes PR7966. llvm-svn: 130982
* With invalid overloaded operators, we can get into funny cases whereDouglas Gregor2011-05-051-0/+9
| | | | | | | | | | the overloading of member and non-member functions results in arity mismatches that don't fit well into our overload-printing scheme. This only happens for invalid code (which breaks the arity invariants for these cases), so just suppress the diagnostic rather than inventing anything new. Fixes <rdar://problem/9222009>. llvm-svn: 130902
* Add an optional field attached to a DeclRefExpr which points back to theChandler Carruth2011-05-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Decl actually found via name lookup & overload resolution when that Decl is different from the ValueDecl which is actually referenced by the expression. This can be used by AST consumers to correctly attribute references to the spelling location of a using declaration, and otherwise gain insight into the name resolution performed by Clang. The public interface to DRE is kept as narrow as possible: we provide a getFoundDecl() which always returns a NamedDecl, either the ValueDecl referenced or the new, more precise NamedDecl if present. This way AST clients can code against getFoundDecl without know when exactly the AST has a split representation. For an example of the data this provides consider: % cat x.cc namespace N1 { struct S {}; void f(const S&); } void test(N1::S s) { f(s); using N1::f; f(s); } % ./bin/clang -fsyntax-only -Xclang -ast-dump x.cc [...] void test(N1::S s) (CompoundStmt 0x5b02010 <x.cc:5:20, line:9:1> (CallExpr 0x5b01df0 <line:6:3, col:6> 'void' (ImplicitCastExpr 0x5b01dd8 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01d80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)')) (ImplicitCastExpr 0x5b01e20 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01d58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S'))) (DeclStmt 0x5b01ee0 <line:7:3, col:14> 0x5b01e40 "UsingN1::;") (CallExpr 0x5b01fc8 <line:8:3, col:6> 'void' (ImplicitCastExpr 0x5b01fb0 <col:3> 'void (*)(const struct N1::S &)' <FunctionToPointerDecay> (DeclRefExpr 0x5b01f80 <col:3> 'void (const struct N1::S &)' lvalue Function 0x5b01a20 'f' 'void (const struct N1::S &)' (UsingShadow 0x5b01ea0 'f'))) (ImplicitCastExpr 0x5b01ff8 <col:5> 'const struct N1::S' lvalue <NoOp> (DeclRefExpr 0x5b01f58 <col:5> 'N1::S':'struct N1::S' lvalue ParmVar 0x5b01b60 's' 'N1::S':'struct N1::S')))) Now we can tell that the second call is 'using' (no pun intended) the using declaration, and *which* using declaration it sees. Without this, we can mistake calls that go through using declarations for ADL calls, and have no way to attribute names looked up with using declarations to the appropriate UsingDecl. llvm-svn: 130670
* When determining whether two types are reference-compatible, checkDouglas Gregor2011-04-281-1/+6
| | | | | | | | non-CVR qualifiers as well as CVR qualifiers. For example, don't allow a reference to an integer in address space 1 to bind to an integer in address space 2. llvm-svn: 130411
* FixOverloadedFunctionReference needs to rebuild member accesses of John McCall2011-04-271-4/+11
| | | | | | | | instance methods to have bound-member type. Fixing that broke __unknown_anytype, which I've in turn fixed. llvm-svn: 130266
* When comparing Objective-C pointers during overload resolution toDouglas Gregor2011-04-271-12/+17
| | | | | | | | | | | determine which is a better conversion to "void*", be sure to perform the comparison using the safe-for-id ASTContext::canAssignObjCInterfaces() rather than the asserts-with-id ASTContext::canAssignObjCInterfaces(). Fixes <rdar://problem/9327203>. llvm-svn: 130259
* When computing Objective-C pointer conversions in C++, retainDouglas Gregor2011-04-261-5/+39
| | | | | | | | | | | the qualifiers (e.g., GC qualifiers) on the type we're converting from, rather than just blindly adopting the qualifiers of the type we're converting to or dropping qualifiers altogether. As an added bonus, properly diagnose GC qualifier mismatches to eliminate a crash in the overload resolution failure diagnostics. llvm-svn: 130255
* Make yet another placeholder type, this one marking that an expression is a ↵John McCall2011-04-261-52/+124
| | | | | | | | | | | bound member function, i.e. something of the form 'x.f' where 'f' is a non-static member function. Diagnose this in the general case. Some of the new diagnostics are probably worse than the old ones, but we now get this right much more universally, and there's certainly room for improvement in the diagnostics. llvm-svn: 130239
* Minor tweak to avoid having to dig through canonical types multiple times ↵Douglas Gregor2011-04-251-3/+6
| | | | | | when checking a qualification conversion llvm-svn: 130136
* In IsUserDefinedConversion try to recover from RequireCompleteType returning ↵Argyrios Kyrtzidis2011-04-221-1/+5
| | | | | | | | true. Fixes an assertion later on, rdar://9122862 & http://llvm.org/PR9460. llvm-svn: 130000
* For the purposes of overload resolution, consider a conversion from anDouglas Gregor2011-04-151-1/+1
| | | | | | | | | Objective-C pointer to void* as a "conversion to void*". This allows us to prefer an Objective-C object pointer conversion to a superclass object pointer over an Objective-C object pointer conversion to cv-void*. Fixes PR9735. llvm-svn: 129603
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-4/+9
| | | | | | draft standard (N3291). llvm-svn: 129541
* Match pointer of compatible vection types. Fariborz Jahanian2011-04-141-0/+8
| | | | | | // rdar://9208404 llvm-svn: 129536
* Clean up the bool conversion warning. Group it with other conversionChandler Carruth2011-04-091-1/+2
| | | | | | | warnings, and make its text appropriate for constant bool expressions other than 'false'. This should finish off PR9612. llvm-svn: 129205
* Add support for warning on general null pointer expressions of booleanChandler Carruth2011-04-091-5/+5
| | | | | | | type rather than just the literal 'false'. This begins fixing PR9612, but the message is now wrong. WIP, the cleanup of the messaging is next. llvm-svn: 129204
* Use ExprResult& instead of Expr *& in SemaJohn Wiegley2011-04-081-130/+208
| | | | | | | | | | | | | | | | | | | | | | | | | This patch authored by Eric Niebler. Many methods on the Sema class (e.g. ConvertPropertyForRValue) take Expr pointers as in/out parameters (Expr *&). This is especially true for the routines that apply implicit conversions to nodes in-place. This design is workable only as long as those conversions cannot fail. If they are allowed to fail, they need a way to report their failures. The typical way of doing this in clang is to use an ExprResult, which has an extra bit to signal a valid/invalid state. Returning ExprResult is de riguour elsewhere in the Sema interface. We suggest changing the Expr *& parameters in the Sema interface to ExprResult &. This increases interface consistency and maintainability. This interface change is important for work supporting MS-style C++ properties. For reasons explained here <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013180.html>, seemingly trivial operations like rvalue/lvalue conversions that formerly could not fail now can. (The reason is that given the semantics of the feature, getter/setter method lookup cannot happen until the point of use, at which point it may be found that the method does not exist, or it may have the wrong type, or overload resolution may fail, or it may be inaccessible.) llvm-svn: 129143
* PR9615: make sure we destroy any temporaries returned by operator->.Eli Friedman2011-04-041-1/+2
| | | | | | | I'm pretty sure this is the right fix, but I would appreciate it if someone else would double-check. llvm-svn: 128806
* Fix an unused variable warning in release builds and make theChandler Carruth2011-03-291-3/+3
| | | | | | assert-less codepath marginally more efficient. llvm-svn: 128472
* Fix a bug in how we were resolving the address of overloaded functionsChandler Carruth2011-03-291-17/+38
| | | | | | | | | | | | | | | | | | | | | | | | when the resolution took place due to a single template specialization being named with an explicit template argument list. In this case, the "resolution" doesn't take into account the target type at all, and therefore can take place for functions, static member functions, and *non-static* member functions. The latter weren't being properly checked and their proper form enforced in this scenario. We now do so. The result of this last form slipping through was some confusing logic in IsStandardConversion handling of these resolved address-of expressions which eventually exploded in an assert. Simplify this logic a bit and add some more aggressive asserts to catch improperly formed expressions getting into this routine. Finally add systematic testing of member functions, both static and non-static, in the various forms they can take. One of these is essentially PR9563, and this commit fixes the crash in that PR. However, the diagnostics for this are still pretty terrible. We at least are now accepting the correct constructs and rejecting the invalid ones rather than accepting invalid or crashing as before. llvm-svn: 128456
* Support for Transparent unions used as overloadableFariborz Jahanian2011-03-231-2/+41
| | | | | | | function parameter. // rdar:// 9129552 and PR9406. llvm-svn: 128159
* Implement a new 'availability' attribute, that allows one to specifyDouglas Gregor2011-03-231-17/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which versions of an OS provide a certain facility. For example, void foo() __attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6))); says that the function "foo" was introduced in 10.2, deprecated in 10.4, and completely obsoleted in 10.6. This attribute ties in with the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that we want to deploy back to Mac OS X 10.1). There are several concrete behaviors that this attribute enables, as illustrated with the function foo() above: - If we choose a deployment target >= Mac OS X 10.4, uses of "foo" will result in a deprecation warning, as if we had placed attribute((deprecated)) on it (but with a better diagnostic) - If we choose a deployment target >= Mac OS X 10.6, uses of "foo" will result in an "unavailable" warning (in C)/error (in C++), as if we had placed attribute((unavailable)) on it - If we choose a deployment target prior to 10.2, foo() is weak-imported (if it is a kind of entity that can be weak imported), as if we had placed the weak_import attribute on it. Naturally, there can be multiple availability attributes on a declaration, for different platforms; only the current platform matters when checking availability attributes. The only platforms this attribute currently works for are "ios" and "macosx", since we already have -mxxxx-version-min flags for them and we have experience there with macro tricks translating down to the deprecated/unavailable/weak_import attributes. The end goal is to open this up to other platforms, and even extension to other "platforms" that are really libraries (say, through a #pragma clang define_system), but that hasn't yet been designed and we may want to shake out more issues with this narrower problem first. Addresses <rdar://problem/6690412>. As a drive-by bug-fix, if an entity is both deprecated and unavailable, we only emit the "unavailable" diagnostic. llvm-svn: 128127
* Clean up our handling of template-ids that resolve down to a singleDouglas Gregor2011-03-161-6/+10
| | | | | | | | | overload, so that we actually do the resolution for full expressions and emit more consistent, useful diagnostics. Also fixes an IRGen crasher, where Sema wouldn't diagnose a resolvable bound member function template-id used in a full-expression (<rdar://problem/9108698>). llvm-svn: 127747
* Fixes for some more expressions containing function templateids thatDouglas Gregor2011-03-121-0/+38
| | | | | | should be resolvable, from Faisal Vali! llvm-svn: 127521
* When we use the default template arguments of a template templateDouglas Gregor2011-03-031-5/+5
| | | | | | | | | | | | | parameter, save the instantiated default template arguments along with the explicitly-specified template argument list. That way, we prefer the default template template arguments corresponding to the template template parameter rather than those of its template template argument. This addresses the likely direction of C++ core issue 150, and fixes PR9353/<rdar://problem/9069136>, bringing us closer to the behavior of EDG and GCC. llvm-svn: 126920
* Move the bool-conversions behind the DiagRuntimeBehavior logic. It'sChandler Carruth2011-03-011-2/+2
| | | | | | | | | possible for these to show up due to metaprogramming both in unevaluated contexts and compile-time dead branches. Those aren't the bugs we're looking for. llvm-svn: 126739
* Push nested-name-specifier location information into DeclRefExpr andDouglas Gregor2011-02-281-9/+3
| | | | | | MemberExpr, the last of the expressions with qualifiers! llvm-svn: 126688
* Push nested-name-specifier source location information intoDouglas Gregor2011-02-281-12/+14
| | | | | | | | | | | | | UnresolvedLookupExpr and UnresolvedMemberExpr. Also, improve the computation that checks whether the base of a member expression (either unresolved or dependent-scoped) is implicit. The previous check didn't cover all of the cases we use in our representation, which threw off source-location information for these expressions (which, in turn, caused some breakage in libclang's token annotation). llvm-svn: 126681
* Sprinkle optional text of the "unavailable' attributeFariborz Jahanian2011-02-251-18/+24
| | | | | | where ever such attribute causes an error diagnostic. llvm-svn: 126509
* Remove the FIXME I introduced last night, and pull the logic forChandler Carruth2011-02-251-17/+17
| | | | | | | | | | marking selected overloads into the callers. This allows a few callers to skip it altogether (they would have anyways because they weren't interested in successful overloads) or defer until after further checks take place much like the check required for PR9323 to avoid marking unused copy constructors. llvm-svn: 126503
* Print optional message for attr(unavailable) in C++ mode.Fariborz Jahanian2011-02-251-5/+18
| | | | | | // rdar://9046492 llvm-svn: 126499
* Rough fix for PR9323 that prevents Clang from marking copy constructorChandler Carruth2011-02-251-2/+9
| | | | | | | | | | | | | | | | declarations as referenced when in fact we're not going to even form a call in the AST. This is significant because we attempt to allow as an extension classes with intentionally private and undefined copy constructors to have temporaries bound to references, and so shouldn't warn about the lack of definition for that copy constructor when the class is internal. Doug, John wasn't really satisfied with the presence of overloading at all. This is a stop-gap and there may be a better solution. If you can give me some hints for how you'd prefer to see this solved, I'll happily switch things over. llvm-svn: 126480
* Retain complete source-location information for C++Douglas Gregor2011-02-241-1/+2
| | | | | | | | | | | | nested-name-specifiers throughout the parser, and provide a new class (NestedNameSpecifierLoc) that contains a nested-name-specifier along with its type-source information. Right now, this information is completely useless, because we don't actually store the source-location information anywhere in the AST. Call this Step 1/N. llvm-svn: 126391
* Tweak the CXXScopeSpec API a bit, so that we require theDouglas Gregor2011-02-241-4/+2
| | | | | | nested-name-specifier and source range to be set at the same time. llvm-svn: 126347
* Remove unused function.Benjamin Kramer2011-02-201-10/+0
| | | | llvm-svn: 126084
OpenPOWER on IntegriCloud