aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
AgeCommit message (Collapse)Author
2010-08-20Remove dead code.Fariborz Jahanian
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111693 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-20Rmove dead code.Fariborz Jahanian
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111680 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19We don't actually need to check the implicit object argument'sDouglas Gregor
conversion a second time for a conversion candidate (with the real acting context), because the only problems we would find are access or ambiguity issues that won't be diagnosed until we pick this candidate. Add a test case to prove it to myself. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111526 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19Properly implement the part of C++ [over.match.funcs]p4 that treatsDouglas Gregor
conversion functions as if their acting context were the class that we're converting from (the implicit object argument's type). Retroactively tweaking the implicit conversion sequence, as we were trying to do before, breaks the invariants of that implicit conversion sequence (e.g., the types and conversions don't match up). Fixes <rdar://problem/8018274>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111520 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-19Include a proper citation for the wacky hijinks involving conversion ↵Douglas Gregor
functions and the implicit object parameter type. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111519 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-18There is no pointer conversion between to similar types (i.e., sameDouglas Gregor
type ignoring cv-qualifiers). These are qualification conversions. Fixes PR7934. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111428 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-12Move Sema's headers into include/clang/Sema, renaming a few along the way.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110945 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-12Handle the obvious case for diagnosing redeclarations of extern "C" functions.John McCall
Fixes PR7859. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110906 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-11Added locations and type source info for DeclarationName.Abramo Bagnara
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110860 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-11Improve our handling of user-defined conversions when computingDouglas Gregor
implicit conversion sequences. In particular, model the "standard conversion" from a class to its own type (or a base type) directly as a standard conversion in the normal path *without* trying to determine if there is a valid copy constructor. This appears to match the intent of C++ [over.best.ics]p6 and more closely matches GCC and EDG. As part of this, model non-lvalue reference initialization via user-defined conversion in overloading the same way we handle it in InitializationSequence, separating the "general user-defined conversion" and "conversion to compatible class type" cases. The churn in the overload-call-copycon.cpp test case is because the test case was originally wrong; it assumed that we should do more checking for copy constructors that we actually should, which affected overload resolution. Fixes PR7055. Bootstrapped okay. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110773 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-08Silence GCC warning about && and || without explicit grouping.Chandler Carruth
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110537 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-07Allow reference binding of a reference of Objective-C object type toDouglas Gregor
an lvalue of another, compatible Objective-C object type (e.g., a subclass). Introduce a new initialization sequence step kind to describe this binding, along with a new cast kind. Fixes PR7741. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110513 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-07Store inheritance paths after CastExprs instead of inside them.John McCall
This takes some trickery since CastExpr has subclasses (and indeed, is abstract). Also, smoosh the CastKind into the bitfield from Expr. Drops two words of storage from Expr in the common case of expressions which don't need inheritance paths. Avoids a separate allocation and another word of overhead in cases needing inheritance paths. Also has the advantage of not leaking memory, since destructors for AST nodes are never run. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110507 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-06Introduce implicit conversions between AltiVec vectors and GCCDouglas Gregor
vectors, from Anton Yartsev! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110437 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-05TDK_InconsistentQuals is really totally different from TDK_Inconsistent.John McCall
Rename it to TDK_Underqualified to avoid this sort of confusion and give it its own diagnostic. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110318 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-05Get rid of isObjectType; when C++ says "object type", it generallyEli Friedman
just means "not a function type", not "not a function type or void". This changes behavior slightly, but generally in a way which accepts more code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110303 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-25Remove the vast majority of the Destroy methods from the AST library,Douglas Gregor
since we aren't going to be calling them ever. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109377 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-20Update ImplicitCastExpr to be able to represent an XValue.Sebastian Redl
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108807 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-14When determining whether an overload set with explicit templateDouglas Gregor
arguments only resolves to a single specialization, make sure to look through using declarations. Fixes PR7641. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108376 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-13Whenever we're creating an expression that is typically an rvalueDouglas Gregor
(e.g., a call, cast, etc.), immediately adjust the expression's type to strip cv-qualifiers off of all non-class types (in C++) or all types (in C). This effectively extends my previous fix for PR7463, which was restricted to calls, to other kinds of expressions within similar characteristics. I've audited every use of getNonReferenceType() in the code base, switching to the newly-renamed getNonLValueExprType() where necessary. Big thanks to Eli for pointing out just how incomplete my original fix for PR7463 actually was. We've been handling cv-qualifiers on rvalues wrong for a very, very long time. Fixes PR7463. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108253 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-13When forming a function call or message send expression, be sure toDouglas Gregor
strip cv-qualifiers from the expression's type when the language calls for it: in C, that's all the time, while C++ only does it for non-class types. Centralized the computation of the call expression type in QualType::getCallResultType() and some helper functions in other nodes (FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant callers of getResultType() to getCallResultType(). Fixes PR7598 and PR7463, along with a bunch of getResultType() call sites that weren't stripping references off the result type (nothing stripped cv-qualifiers properly before this change). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108234 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-02Introduce a new routine, LookupConstructors(), and use it for allDouglas Gregor
constructor-name lookup. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107536 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-01Extend the "cannot convert from base class pointer to derived classDouglas Gregor
pointer" diagnostic to handle references, too. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107372 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30Improve diagnostic when we fail to pick an overload because it wouldDouglas Gregor
require a base-to-derived pointer conversion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107349 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30Add a return to silence a warning. Alternately a default: return falseEric Christopher
would work. Sebastian: figure out which one you want :) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107305 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30Make both old and new versions of reference binding use the new ↵Sebastian Redl
classification functions, and updated them for N3092. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107301 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-30Implement C++ DR299, which allows an implicit conversion from a classDouglas Gregor
type to an integral or enumeration type in the size of an array new expression, e.g., new int[ConvertibleToInt(10)]; This is a GNU and C++0x extension. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107229 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-29Re-improve recovery when the condition of a switch statement does notDouglas Gregor
have integral or enumeration type, so that we still check the contents of the switch body. My previous patch made this worse; now we're back to where we were previously. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107223 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-29Factor the conversion from a switch condition to an integral orDouglas Gregor
enumeration type out into a separate, reusable routine. The only functionality change here is that we recover a little more aggressively from ill-formed switch conditions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107222 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22Vector types are not arithmetic types, either. Note that we now banDouglas Gregor
__real myvec and __imag myvec, since they aren't all that useful (it's just an identity function) but we might want to use them in more restricted cases in the future (e.g., "__real mycomplexvec" could extract the real parts of a vector of complex numbers). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106601 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22Type Type::isRealFloatingType() that vectors are not floating-pointDouglas Gregor
types, updating callers of both isFloatingType() and isRealFloatingType() accordingly. Caught at least one issue where we allowed one to declare a vector of vectors (!), along with cleaning up the standard-conversion logic for C++. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106595 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22Change Type::isFloatingType() to reflect the actual definition of aDouglas Gregor
"floating type" in C, which does not include vector types. Introduce Type::hasFloatingRepresentation() for the places where we want to know whether the underlying representation is one or more floating-point values. Remove some hacks we had where the former behavior of Type::isFloatingType() was at odds with the language definition of the term. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106584 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22Don't allow vector conversions to sneak in under the guise ofDouglas Gregor
floating-point conversions or floating-integral conversions. We really, really, really need to make isFloatingType() and friends not apply to vector types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106551 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17Use UnaryOperator as the representation of dependent expressions whenDouglas Gregor
no overloaded operators were found in scope, mirroring what we already do for BinaryOperator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106222 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16Fix a point of semantics with using declaration hiding: method templatesJohn McCall
introduced by using decls are hidden even if their template parameter lists or return types differ from the "overriding" declaration. Propagate using shadow declarations around more effectively when looking up template-ids. Reperform lookup for template-ids in member expressions so that access control is properly set up. Fix some number of latent bugs involving template-ids with totally invalid base types. You can only actually get these with a scope specifier, since otherwise the template-id won't parse as a template-id. Fixes PR7384. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106093 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16Give Type::isIntegralType() an ASTContext parameter, so that itDouglas Gregor
provides C "integer type" semantics in C and C++ "integral type" semantics in C++. Note that I still need to update isIntegerType (and possibly other predicates) using the same approach I've taken for isIntegralType(). The two should have the same meaning, but currently don't (!). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106074 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16Introduce Type::isIntegralOrEnumerationType(), to cover those placesDouglas Gregor
in C++ that involve both integral and enumeration types. Convert all of the callers to Type::isIntegralType() that are meant to work with both integral and enumeration types over to Type::isIntegralOrEnumerationType(), to prepare to eliminate enumeration types as integral types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106071 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-11Conversions from Objective C object pointers to bool are "pointer conversionsJohn McCall
to bool" in the sense of C++ [over.ics.rank]p4 bullet 1. I have decreed it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105817 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-11Fix the 64-bit build. operator<<(DiagnosticBuilder, long) doesn't exist, soJeffrey Yasskin
ptrdiff_t (long on 64-bit, apparently) is ambiguous between the int and unsigned int overloads. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105816 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-11Add an option -fshow-overloads=best|all to limit the number of overloadJeffrey Yasskin
candidates printed. We default to 'all'. At the moment, 'best' prints only the first 4 overloads, but we'll improve that over time. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105815 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-09Tweak our handling of the notion of a standard conversion sequenceDouglas Gregor
being a subsequence of another standard conversion sequence. Instead of requiring exact type equality for the second conversion step, require type *similarity*, which is type equality with cv-qualifiers removed at all levels. This appears to match the behavior of EDG and VC++ (albeit not GCC), and feels more intuitive. Big thanks to John for the line of reasoning that supports this change: since cv-qualifiers are orthogonal to the second conversion step, we should ignore them in the type comparison. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105678 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-08A built-in overload candidate is consider a non-template function whenDouglas Gregor
determining whether one overload candidate is better than another. Fixes PR7319. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105642 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-08Implement a warning when converting the literal 'false' to aDouglas Gregor
pointer. Original patch by Troy D. Straszheim; fixes PR7283. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105621 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-25Make sure to strip off top-level cv-qualifiers as part of aDouglas Gregor
derived-to-base conversion on a pointer. Fixes PR7224. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104607 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-23An identity conversion is better than any non-identityDouglas Gregor
conversion. Fixes PR7095. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104476 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-23Provide the overloaded functions for UnresolvedLookupExpr andDouglas Gregor
UnresolvedMemberExpr in their constructors, rather than adding them after the fact. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104468 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-19Implement C++ builtin operator candidates for vector types.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104105 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18Misc. fixes to bring Objetive-C++'s handling ofFariborz Jahanian
gc attributes to be inline with Objective-C (for radar 7925141). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104084 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18Implement C++ support for vector and extended vector types. ThisDouglas Gregor
involves extending implicit conversion sequences to model vector conversions and vector splats, along with teaching the C++ conditional operator-checking code about vector types. Fixes <rdar://problem/7983501>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104081 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18Tweak typo-correction logic a bit regarding "super", so that weDouglas Gregor
consider "super" as a candidate whenever we're parsing an expression within an Objective-C method in an interface that has a superclass. At some point, we'd like to give "super" a little edge over non-local names; that will come later. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104022 91177308-0d34-0410-b5e6-96231b3b80d8