summaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-02-25 19:41:05 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-02-25 19:41:05 +0000
commit25ca421a6049350a2748c8fd0c19a052eba6ae99 (patch)
tree1c5b4801544f09fb0d45b059b1ca1b2c1f07a537 /lib/Sema/SemaOverload.cpp
parent8435bf93757b5fe1b11ac8a3149d18649a6f4086 (diff)
downloadclang-25ca421a6049350a2748c8fd0c19a052eba6ae99.tar.gz
clang-25ca421a6049350a2748c8fd0c19a052eba6ae99.tar.bz2
clang-25ca421a6049350a2748c8fd0c19a052eba6ae99.tar.xz
Remove the FIXME I introduced last night, and pull the logic for
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126503 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r--lib/Sema/SemaOverload.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 1da95b6a35..56322d9583 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -2261,6 +2261,8 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
// Record the standard conversion we used and the conversion function.
if (CXXConstructorDecl *Constructor
= dyn_cast<CXXConstructorDecl>(Best->Function)) {
+ S.MarkDeclarationReferenced(From->getLocStart(), Constructor);
+
// C++ [over.ics.user]p1:
// If the user-defined conversion is specified by a
// constructor (12.3.1), the initial standard conversion
@@ -2282,6 +2284,8 @@ IsUserDefinedConversion(Sema &S, Expr *From, QualType ToType,
return OR_Success;
} else if (CXXConversionDecl *Conversion
= dyn_cast<CXXConversionDecl>(Best->Function)) {
+ S.MarkDeclarationReferenced(From->getLocStart(), Conversion);
+
// C++ [over.ics.user]p1:
//
// [...] If the user-defined conversion is specified by a
@@ -3068,6 +3072,8 @@ FindConversionForRefInit(Sema &S, ImplicitConversionSequence &ICS,
if (!Best->FinalConversion.DirectBinding)
return false;
+ if (Best->Function)
+ S.MarkDeclarationReferenced(DeclLoc, Best->Function);
ICS.setUserDefined();
ICS.UserDefined.Before = Best->Conversions[0].Standard;
ICS.UserDefined.After = Best->FinalConversion;
@@ -6248,8 +6254,7 @@ isBetterOverloadCandidate(Sema &S,
OverloadingResult
OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc,
iterator &Best,
- bool UserDefinedConversion,
- bool IsExtraneousCopy) {
+ bool UserDefinedConversion) {
// Find the best viable function.
Best = end();
for (iterator Cand = begin(); Cand != end(); ++Cand) {
@@ -6281,21 +6286,6 @@ OverloadCandidateSet::BestViableFunction(Sema &S, SourceLocation Loc,
Best->Function->getAttr<UnavailableAttr>()))
return OR_Deleted;
- // C++ [basic.def.odr]p2:
- // An overloaded function is used if it is selected by overload resolution
- // when referred to from a potentially-evaluated expression. [Note: this
- // 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).
- //
- // 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;
}
@@ -7687,6 +7677,7 @@ Sema::BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE,
switch (CandidateSet.BestViableFunction(*this, Fn->getLocStart(), Best)) {
case OR_Success: {
FunctionDecl *FDecl = Best->Function;
+ MarkDeclarationReferenced(Fn->getExprLoc(), FDecl);
CheckUnresolvedLookupAccess(ULE, Best->FoundDecl);
DiagnoseUseOfDecl(FDecl? FDecl : Best->FoundDecl.getDecl(),
ULE->getNameLoc());
@@ -7833,6 +7824,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, unsigned OpcIn,
// We matched an overloaded operator. Build a call to that
// operator.
+ MarkDeclarationReferenced(OpLoc, FnDecl);
+
// Convert the arguments.
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
CheckMemberOperatorAccess(OpLoc, Args[0], 0, Best->FoundDecl);
@@ -8056,6 +8049,8 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
// We matched an overloaded operator. Build a call to that
// operator.
+ MarkDeclarationReferenced(OpLoc, FnDecl);
+
// Convert the arguments.
if (CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(FnDecl)) {
// Best->Access is only meaningful for class members.
@@ -8237,6 +8232,8 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
// We matched an overloaded operator. Build a call to that
// operator.
+ MarkDeclarationReferenced(LLoc, FnDecl);
+
CheckMemberOperatorAccess(LLoc, Args[0], Args[1], Best->FoundDecl);
DiagnoseUseOfDecl(Best->FoundDecl, LLoc);
@@ -8408,6 +8405,7 @@ Sema::BuildCallToMemberFunction(Scope *S, Expr *MemExprE,
Best)) {
case OR_Success:
Method = cast<CXXMethodDecl>(Best->Function);
+ MarkDeclarationReferenced(UnresExpr->getMemberLoc(), Method);
FoundDecl = Best->FoundDecl;
CheckUnresolvedMemberAccess(UnresExpr, Best->FoundDecl);
DiagnoseUseOfDecl(Best->FoundDecl, UnresExpr->getNameLoc());
@@ -8635,6 +8633,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object,
RParenLoc);
}
+ MarkDeclarationReferenced(LParenLoc, Best->Function);
CheckMemberOperatorAccess(LParenLoc, Object, 0, Best->FoundDecl);
DiagnoseUseOfDecl(Best->FoundDecl, LParenLoc);
@@ -8813,6 +8812,7 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc) {
return ExprError();
}
+ MarkDeclarationReferenced(OpLoc, Best->Function);
CheckMemberOperatorAccess(OpLoc, Base, 0, Best->FoundDecl);
DiagnoseUseOfDecl(Best->FoundDecl, OpLoc);