diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-02-25 08:52:25 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-02-25 08:52:25 +0000 |
commit | 30028234f38945981ebf9c8a2cb915fc2f9a63a4 (patch) | |
tree | 093913b5dee2354c3a8a81ce59acd45459ec5a27 /lib/Sema/SemaOverload.cpp | |
parent | 79ac241f0b4b5a653adb7e07292d7b00c5cb92ff (diff) |
Rough fix for PR9323 that prevents Clang from marking copy constructor
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126480 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 60873cd969..c59bfec811 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -6248,7 +6248,8 @@ isBetterOverloadCandidate(Sema &S, OverloadingResult OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc, iterator &Best, - bool UserDefinedConversion) { + bool UserDefinedConversion, + bool IsExtraneousCopy) { // Find the best viable function. Best = end(); for (iterator Cand = begin(); Cand != end(); ++Cand) { @@ -6286,7 +6287,13 @@ OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc, // covers calls to named functions (5.2.2), operator overloading // (clause 13), user-defined conversions (12.3.2), allocation function for // placement new (5.3.4), as well as non-default initialization (8.5). - if (Best->Function) + // + // As a special exception, we don't mark functions selected for extraneous + // copy constructor calls as used; the nature of extraneous copy constructor + // calls is that they are never in fact called. + // FIXME: This doesn't seem like the right approach. Should we be doing + // overload resolution at all for extraneous copies? + if (Best->Function && !IsExtraneousCopy) S.MarkDeclarationReferenced(Loc, Best->Function); return OR_Success; |