aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
AgeCommit message (Collapse)Author
2010-03-30Propagate the "found declaration" (i.e. the using declaration instead ofJohn McCall
the underlying/instantiated decl) through a lot of API, including "intermediate" MemberExprs required for (e.g.) template instantiation. This is necessary because of the access semantics of member accesses to using declarations: only the base class *containing the using decl* need be accessible from the naming class. This allows us to complete an access-controlled selfhost, if there are no recent regressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99936 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-29Optimize PartialDiagnostic's memory-allocation behavior by placing aDouglas Gregor
cache of PartialDiagnostic::Storage objects into an allocator within the ASTContext. This eliminates a significant amount of malloc traffic, for a 10% performance improvement in -fsyntax-only wall-clock time with 403.gcc's combine.c. Also, eliminate the RequireNonAbstractType hack I put in earlier, which was but a symptom of this larger problem. Fixes <rdar://problem/7806091>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99849 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-26Eliminate the non-InitializedEntity PerformCopyInitialization() andDouglas Gregor
re-route its only caller to the newer PerformCopyInitialization(). We're down to one remaining caller of Sema::CheckReferenceInit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99650 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-19Remember the "found declaration" for an overload candidate, which is theJohn McCall
entity (if applicable) which was actually looked up. If a candidate was found via a using declaration, this is the UsingShadowDecl; otherwise, if the candidate is template specialization, this is the template; otherwise, this is the function. The point of this exercise is that "found declarations" are the entities we do access control for, not their underlying declarations. Broadly speaking, this patch fixes access control for using declarations. There is a *lot* of redundant code calling into the overload-resolution APIs; we really ought to clean that up. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98945 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-16Perform access control for the implicit base and member destructor callsJohn McCall
required when emitting a destructor definition. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98609 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-15objective-c++ must take into account qualifiers when Fariborz Jahanian
considering valid objc pointer converions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98557 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03Reinstate r97674 with a fix for the assertion that was firing in <list>Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97686 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03Revert r97674; it's causing failuresDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97677 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03Implement disambiguation of base class members via aDouglas Gregor
nested-name-specifier. For example, this allows member access in diamond-shaped hierarchies like: struct Base { void Foo(); int Member; }; struct D1 : public Base {}; struct D2 : public Base {}; struct Derived : public D1, public D2 { } void Test(Derived d) { d.Member = 17; // error: ambiguous cast from Derived to Base d.D1::Member = 17; // error: okay, modify D1's Base's Member } Fixes PR5820 and <rdar://problem/7535045>. Also, eliminate some redundancy between Sema::PerformObjectMemberConversion() and Sema::PerformObjectArgumentInitialization() -- the latter now calls the former. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97674 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-28Warn about the deprecated string literal -> char* conversion. Fixes PR6428.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97404 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25Allow us to compare derived-to-base conversions between a referenceDouglas Gregor
binding and a copy-construction. Fixes an overloading problem in the Clang-on-Clang build. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97161 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25When comparing two method overload candidates during overload diagnostics,John McCall
skip the object argument conversion if either of the candidates didn't initialize it. Fixes PR6421, which is such a very straightforward extension of PR6398 that I should have worked it into the last test case (and therefore caught it then). Ah well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97135 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25Add a new conversion rank to classify conversions between complex and scalarChandler Carruth
types. Rank these conversions below other conversions. This allows overload resolution when the only distinction is between a complex and scalar type. It also brings the complex overload resolutin in line with GCC's. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97128 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25Catch more uses of uninitialized implicit conversion sequences.John McCall
When diagnosing bad conversions, skip the conversion for ignored object arguments. Fixes PR 6398. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97090 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22Do not require a complete type when checking for a pointer conversionDouglas Gregor
between cv1 T* and cv2 T*. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96787 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-21A constructor template cannot be used to copy to an object of the same class ↵Douglas Gregor
type (per C++ [class.copy]p3). Make sure that includes copies that involve a derived-to-base conversion. Fixes PR6141. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96742 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-10Improve access control diagnostics. Perform access control on member-pointerJohn McCall
conversions. Fix an access-control bug where privileges were not considered at intermediate points along the inheritance path. Prepare for friends. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95775 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-08Thread a source location into the template-argument deduction routines. ThereJohn McCall
may be some other places that could take advantage of this new information, but I haven't really looked yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95600 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05When adding ADL candidates for overloadedDouglas Gregor
post-increment/post-decrement operators, be sure to consider both arguments. Fixes PR6237. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95361 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-04Extract a common structure for holding information about the definitionJohn McCall
of a C++ record. Exposed a lot of problems where various routines were silently doing The Wrong Thing (or The Acceptable Thing in The Wrong Order) when presented with a non-definition. Also cuts down on memory usage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95330 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-03Top-level const changes do not make a qualification conversion. Fixes PR6089.Sebastian Redl
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95239 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02Implement promotion for enumeration types.Douglas Gregor
WHAT!?! It turns out that Type::isPromotableIntegerType() was not considering enumeration types to be promotable, so we would never do the promotion despite having properly computed the promotion type when the enum was defined. Various operations on values of enum type just "worked" because we could still compute the integer rank of an enum type; the oddity, however, is that operations such as "add an enum and an unsigned" would often have an enum result type (!). The bug actually showed up as a spurious -Wformat diagnostic (<rdar://problem/7595366>), but in theory it could cause miscompiles. In this commit: - Enum types with a promotion type of "int" or "unsigned int" are promotable. - Tweaked the computation of promotable types for enums - For all of the ABIs, treat enum types the same way as their underlying types (*not* their promotion types) for argument passing and return values - Extend the ABI tester with support for enumeration types git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95117 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02Extract a common base class between UnresolvedLookupExpr andJohn McCall
UnresolvedMemberExpr and employ it in a few places where it's useful. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95072 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-02Improve the diagnostic used when an incompatible overload set is passedJohn McCall
as an argument during overload resolution. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95057 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-01Note that an overload candidate was non-viable because template argumentJohn McCall
deduction failed. Right now there's a very vague diagnostic for most cases and a good diagnostic for incomplete deduction. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94988 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29And yet another call.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94824 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-29Another PerformCopyInitialization call bites the dust.Anders Carlsson
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94823 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-28Access control for surrogate function calls. Required a moderately gross hackJohn McCall
to get the access bits set properly in conversion sets. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94744 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-28Access control for overloaded call operators. Not for surrogates yet,John McCall
mostly because we're going to want a better diagnostic for conversions. Also this API needs to go back to sanity. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94730 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-28Access checking for overloaded operators.John McCall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94725 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-27Fix a major oversight in the comparison of standard conversionDouglas Gregor
sequences, where we would occasionally determine (incorrectly) that one standard conversion sequence was a proper subset of another when, in fact, they contained completely incomparable conversions. This change records the types in each step within a standard conversion sequence, so that we can check the specific comparison types to determine when one sequence is a proper subset of the other. Fixes this testcase (thanks, Anders!), which was distilled from PR6095 (also thanks to Anders). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94660 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-27Implement access control for overloaded functions. Suppress access controlJohn McCall
diagnostics in "early" lookups, such as during typename checks and when building unresolved lookup expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94647 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Avoid some unnecessary copying of unresolved lookup results.John McCall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94531 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Handle redeclarations found by ADL deterministically and reasonably.John McCall
This solution relies on an O(n) scan of redeclarations, which means it might scale poorly in crazy cases with tons of redeclarations brought in by a ton of distinct associated namespaces. I believe that avoiding this is not worth the common-case cost. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94530 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Allow ADL to find functions imported by using decls. Leave wordy commentJohn McCall
about interaction between ADL and default arguments. Shrug shoulders, commit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94524 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Preserve access bits through overload resolution much better. SomeJohn McCall
general refactoring in operator resolution. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94498 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Pass access specifiers around in overload resolution.John McCall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94485 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23Produce a special diagnostic when users call a function with an argument ofJohn McCall
incomplete type (or a pointer/reference to such). The causes of this problem are different enough to justify a different "design" for the diagnostic. Most notably, it doesn't give an operand index: it's usually pretty obvious which operand is the problem, it adds a lot of clutter to mention it, and the fix is usually in a different part of the file anyway. This is yet another diagnostic that should really have an analogue in the non-overloaded case --- which should be much easier to write because of the weaker space constraints. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94303 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-23During overload resolution diagnostics, sort non-viable candidates by the ↵John McCall
quality of their conversions. To make this work, fill out all conversions for all candidates (but only when diagnosing overload failure). Split out a few cases from ovl_fail_bad_conversion which didn't actually involve a failed argument conversion. I'm pretty sure this is not a well-founded ordering, but I'm not sure it matters. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94283 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22Use raw_ostream instead of cstdio.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94136 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21Fixes comments.Fariborz Jahanian
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94053 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21Also allow cast of block pointer type toFariborz Jahanian
pointer to an any object. Another variation of radar 7562285. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94052 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20In objective-c++ land, a block pointer is another object pointer.Fariborz Jahanian
So, casting a generic object pointer ('id' or 'Class') to the block pointer is allowed. Fixes radar 7562285. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94045 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20Give UnresolvedSet the ability to store access specifiers for each declaration.John McCall
Change LookupResult to use UnresolvedSet. Also extract UnresolvedSet into its own header and make it templated over an inline capacity. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93959 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18Allow conversion of pointer to an objective-c pointer toFariborz Jahanian
a similar pointer. Fixes radar 7552179. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93803 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16Fix a use of uninitialized memory in overload diagnostics.John McCall
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93629 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15Candidates with arity mismatches are extra-special non-viable and need toJohn McCall
stand at the back of the line. Thanks to Oliver Hunt for reminding me to do this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93583 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-14Improve overload diagnostics some more by calling out qualifier mismatchesJohn McCall
for special diagnostics. Unfortunately, the non-overload diagnostics are not this good. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93420 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-14Improve the diagnostic for bad conversions in overload resolution to talkJohn McCall
about 'object argument' vs. 'nth argument'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93395 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13Don't report ambiguities in the user-defined conversion if we weren't supposedJohn McCall
to be considering user-defined conversions in the first place. Doug, please review; I'm not sure what we should be doing if we see a real ambiguity in selecting a copy constructor when otherwise suppressing user-defined conversions. Fixes PR6014. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93365 91177308-0d34-0410-b5e6-96231b3b80d8