зеркало из https://github.com/microsoft/clang-1.git
Move some of SemaOverload's API to various places in Overload.h, and kill
some of it off completely. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111957 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
1fbb447e9d
Коммит
120d63cd44
|
@ -13,7 +13,7 @@
|
|||
#ifndef LLVM_CLANG_SEMA_INITIALIZATION_H
|
||||
#define LLVM_CLANG_SEMA_INITIALIZATION_H
|
||||
|
||||
#include "clang/Sema/Action.h"
|
||||
#include "clang/Sema/Ownership.h"
|
||||
#include "clang/Sema/Overload.h"
|
||||
#include "clang/AST/Type.h"
|
||||
#include "clang/AST/UnresolvedSet.h"
|
||||
|
@ -628,7 +628,7 @@ public:
|
|||
ExprResult Perform(Sema &S,
|
||||
const InitializedEntity &Entity,
|
||||
const InitializationKind &Kind,
|
||||
Action::MultiExprArg Args,
|
||||
MultiExprArg Args,
|
||||
QualType *ResultType = 0);
|
||||
|
||||
/// \brief Diagnose an potentially-invalid initialization sequence.
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace clang {
|
|||
class CXXConstructorDecl;
|
||||
class CXXConversionDecl;
|
||||
class FunctionDecl;
|
||||
class Sema;
|
||||
|
||||
/// OverloadingResult - Capture the result of performing overload
|
||||
/// resolution.
|
||||
|
@ -38,7 +39,16 @@ namespace clang {
|
|||
OR_Ambiguous, ///< Ambiguous candidates found.
|
||||
OR_Deleted ///< Succeeded, but refers to a deleted function.
|
||||
};
|
||||
|
||||
|
||||
enum OverloadCandidateDisplayKind {
|
||||
/// Requests that all candidates be shown. Viable candidates will
|
||||
/// be printed first.
|
||||
OCD_AllCandidates,
|
||||
|
||||
/// Requests that only viable candidates be shown.
|
||||
OCD_ViableCandidates
|
||||
};
|
||||
|
||||
/// ImplicitConversionKind - The kind of implicit conversion used to
|
||||
/// convert an argument to a parameter's type. The enumerator values
|
||||
/// match with Table 9 of (C++ 13.3.3.1.1) and are listed such that
|
||||
|
@ -461,6 +471,10 @@ namespace clang {
|
|||
Worse = 1
|
||||
};
|
||||
|
||||
void DiagnoseAmbiguousConversion(Sema &S,
|
||||
SourceLocation CaretLoc,
|
||||
const PartialDiagnostic &PDiag) const;
|
||||
|
||||
void DebugPrint() const;
|
||||
};
|
||||
|
||||
|
@ -611,7 +625,22 @@ namespace clang {
|
|||
void clear();
|
||||
|
||||
~OverloadCandidateSet() { clear(); }
|
||||
|
||||
/// Find the best viable function on this overload set, if it exists.
|
||||
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc,
|
||||
OverloadCandidateSet::iterator& Best);
|
||||
|
||||
void NoteCandidates(Sema &S,
|
||||
OverloadCandidateDisplayKind OCD,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
const char *Opc = 0,
|
||||
SourceLocation Loc = SourceLocation());
|
||||
};
|
||||
|
||||
bool isBetterOverloadCandidate(Sema &S,
|
||||
const OverloadCandidate& Cand1,
|
||||
const OverloadCandidate& Cand2,
|
||||
SourceLocation Loc);
|
||||
} // end namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_SEMA_OVERLOAD_H
|
||||
|
|
|
@ -1135,14 +1135,6 @@ public:
|
|||
bool AllowExplicit,
|
||||
bool InOverloadResolution);
|
||||
|
||||
ImplicitConversionSequence
|
||||
TryImplicitConversion(Expr* From, QualType ToType,
|
||||
bool SuppressUserConversions,
|
||||
bool AllowExplicit,
|
||||
bool InOverloadResolution);
|
||||
bool IsStandardConversion(Expr *From, QualType ToType,
|
||||
bool InOverloadResolution,
|
||||
StandardConversionSequence& SCS);
|
||||
bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
|
||||
bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
|
||||
bool IsComplexPromotion(QualType FromType, QualType ToType);
|
||||
|
@ -1166,44 +1158,18 @@ public:
|
|||
CXXCastPath &BasePath,
|
||||
bool IgnoreBaseAccess);
|
||||
bool IsQualificationConversion(QualType FromType, QualType ToType);
|
||||
OverloadingResult IsUserDefinedConversion(Expr *From, QualType ToType,
|
||||
UserDefinedConversionSequence& User,
|
||||
OverloadCandidateSet& Conversions,
|
||||
bool AllowExplicit);
|
||||
bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
|
||||
|
||||
|
||||
ImplicitConversionSequence::CompareKind
|
||||
CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
|
||||
const ImplicitConversionSequence& ICS2);
|
||||
|
||||
ImplicitConversionSequence::CompareKind
|
||||
CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
|
||||
const StandardConversionSequence& SCS2);
|
||||
|
||||
ImplicitConversionSequence::CompareKind
|
||||
CompareQualificationConversions(const StandardConversionSequence& SCS1,
|
||||
const StandardConversionSequence& SCS2);
|
||||
|
||||
ImplicitConversionSequence::CompareKind
|
||||
CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1,
|
||||
const StandardConversionSequence& SCS2);
|
||||
|
||||
ExprResult PerformCopyInitialization(const InitializedEntity &Entity,
|
||||
SourceLocation EqualLoc,
|
||||
ExprResult Init);
|
||||
ImplicitConversionSequence
|
||||
TryObjectArgumentInitialization(QualType FromType, CXXMethodDecl *Method,
|
||||
CXXRecordDecl *ActingContext);
|
||||
SourceLocation EqualLoc,
|
||||
ExprResult Init);
|
||||
bool PerformObjectArgumentInitialization(Expr *&From,
|
||||
NestedNameSpecifier *Qualifier,
|
||||
NamedDecl *FoundDecl,
|
||||
CXXMethodDecl *Method);
|
||||
|
||||
ImplicitConversionSequence TryContextuallyConvertToBool(Expr *From);
|
||||
bool PerformContextuallyConvertToBool(Expr *&From);
|
||||
|
||||
ImplicitConversionSequence TryContextuallyConvertToObjCId(Expr *From);
|
||||
bool PerformContextuallyConvertToObjCId(Expr *&From);
|
||||
|
||||
ExprResult
|
||||
|
@ -1302,31 +1268,8 @@ public:
|
|||
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
||||
OverloadCandidateSet& CandidateSet,
|
||||
bool PartialOverloading = false);
|
||||
bool isBetterOverloadCandidate(const OverloadCandidate& Cand1,
|
||||
const OverloadCandidate& Cand2,
|
||||
SourceLocation Loc);
|
||||
OverloadingResult BestViableFunction(OverloadCandidateSet& CandidateSet,
|
||||
SourceLocation Loc,
|
||||
OverloadCandidateSet::iterator& Best);
|
||||
|
||||
enum OverloadCandidateDisplayKind {
|
||||
/// Requests that all candidates be shown. Viable candidates will
|
||||
/// be printed first.
|
||||
OCD_AllCandidates,
|
||||
|
||||
/// Requests that only viable candidates be shown.
|
||||
OCD_ViableCandidates
|
||||
};
|
||||
void PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
|
||||
OverloadCandidateDisplayKind OCD,
|
||||
Expr **Args, unsigned NumArgs,
|
||||
const char *Opc = 0,
|
||||
SourceLocation Loc = SourceLocation());
|
||||
|
||||
void NoteOverloadCandidate(FunctionDecl *Fn);
|
||||
void DiagnoseAmbiguousConversion(const ImplicitConversionSequence &ICS,
|
||||
SourceLocation CaretLoc,
|
||||
const PartialDiagnostic &PDiag);
|
||||
|
||||
FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
|
||||
bool Complain,
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
#include "clang/Sema/Sema.h"
|
||||
#include "clang/Sema/Lookup.h"
|
||||
#include "clang/Sema/Overload.h"
|
||||
#include "clang/Sema/CodeCompleteConsumer.h"
|
||||
#include "clang/Sema/ExternalSemaSource.h"
|
||||
#include "clang/Sema/Scope.h"
|
||||
|
@ -2837,7 +2838,7 @@ namespace {
|
|||
|
||||
bool
|
||||
operator()(const OverloadCandidate &X, const OverloadCandidate &Y) const {
|
||||
return S.isBetterOverloadCandidate(X, Y, Loc);
|
||||
return isBetterOverloadCandidate(S, X, Y, Loc);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1124,7 +1124,7 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
|
|||
|
||||
// Do the resolution.
|
||||
OverloadCandidateSet::iterator Best;
|
||||
switch(BestViableFunction(Candidates, StartLoc, Best)) {
|
||||
switch (Candidates.BestViableFunction(*this, StartLoc, Best)) {
|
||||
case OR_Success: {
|
||||
// Got one!
|
||||
FunctionDecl *FnDecl = Best->Function;
|
||||
|
@ -1152,20 +1152,20 @@ bool Sema::FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
|
|||
case OR_No_Viable_Function:
|
||||
Diag(StartLoc, diag::err_ovl_no_viable_function_in_call)
|
||||
<< Name << Range;
|
||||
PrintOverloadCandidates(Candidates, OCD_AllCandidates, Args, NumArgs);
|
||||
Candidates.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
|
||||
return true;
|
||||
|
||||
case OR_Ambiguous:
|
||||
Diag(StartLoc, diag::err_ovl_ambiguous_call)
|
||||
<< Name << Range;
|
||||
PrintOverloadCandidates(Candidates, OCD_ViableCandidates, Args, NumArgs);
|
||||
Candidates.NoteCandidates(*this, OCD_ViableCandidates, Args, NumArgs);
|
||||
return true;
|
||||
|
||||
case OR_Deleted:
|
||||
Diag(StartLoc, diag::err_ovl_deleted_call)
|
||||
<< Best->Function->isDeleted()
|
||||
<< Name << Range;
|
||||
PrintOverloadCandidates(Candidates, OCD_AllCandidates, Args, NumArgs);
|
||||
Candidates.NoteCandidates(*this, OCD_AllCandidates, Args, NumArgs);
|
||||
return true;
|
||||
}
|
||||
assert(false && "Unreachable, bad result from BestViableFunction");
|
||||
|
@ -1674,7 +1674,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
|
|||
}
|
||||
|
||||
case ImplicitConversionSequence::AmbiguousConversion:
|
||||
DiagnoseAmbiguousConversion(ICS, From->getExprLoc(),
|
||||
ICS.DiagnoseAmbiguousConversion(*this, From->getExprLoc(),
|
||||
PDiag(diag::err_typecheck_ambiguous_condition)
|
||||
<< From->getSourceRange());
|
||||
return true;
|
||||
|
@ -2140,7 +2140,7 @@ static bool FindConditionalOverload(Sema &Self, Expr *&LHS, Expr *&RHS,
|
|||
Self.AddBuiltinOperatorCandidates(OO_Conditional, Loc, Args, 2, CandidateSet);
|
||||
|
||||
OverloadCandidateSet::iterator Best;
|
||||
switch (Self.BestViableFunction(CandidateSet, Loc, Best)) {
|
||||
switch (CandidateSet.BestViableFunction(Self, Loc, Best)) {
|
||||
case OR_Success:
|
||||
// We found a match. Perform the conversions on the arguments and move on.
|
||||
if (Self.PerformImplicitConversion(LHS, Best->BuiltinTypes.ParamTypes[0],
|
||||
|
|
|
@ -2392,7 +2392,7 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S,
|
|||
// Perform overload resolution. If it fails, return the failed result.
|
||||
OverloadCandidateSet::iterator Best;
|
||||
if (OverloadingResult Result
|
||||
= S.BestViableFunction(CandidateSet, DeclLoc, Best))
|
||||
= CandidateSet.BestViableFunction(S, DeclLoc, Best))
|
||||
return Result;
|
||||
|
||||
FunctionDecl *Function = Best->Function;
|
||||
|
@ -2777,7 +2777,7 @@ static void TryConstructorInitialization(Sema &S,
|
|||
// Perform overload resolution. If it fails, return the failed result.
|
||||
OverloadCandidateSet::iterator Best;
|
||||
if (OverloadingResult Result
|
||||
= S.BestViableFunction(CandidateSet, DeclLoc, Best)) {
|
||||
= CandidateSet.BestViableFunction(S, DeclLoc, Best)) {
|
||||
Sequence.SetOverloadFailure(
|
||||
InitializationSequence::FK_ConstructorOverloadFailed,
|
||||
Result);
|
||||
|
@ -2987,7 +2987,7 @@ static void TryUserDefinedConversion(Sema &S,
|
|||
// Perform overload resolution. If it fails, return the failed result.
|
||||
OverloadCandidateSet::iterator Best;
|
||||
if (OverloadingResult Result
|
||||
= S.BestViableFunction(CandidateSet, DeclLoc, Best)) {
|
||||
= CandidateSet.BestViableFunction(S, DeclLoc, Best)) {
|
||||
Sequence.SetOverloadFailure(
|
||||
InitializationSequence::FK_UserConversionOverloadFailed,
|
||||
Result);
|
||||
|
@ -3029,24 +3029,6 @@ static void TryUserDefinedConversion(Sema &S,
|
|||
}
|
||||
}
|
||||
|
||||
bool Sema::TryImplicitConversion(InitializationSequence &Sequence,
|
||||
const InitializedEntity &Entity,
|
||||
Expr *Initializer,
|
||||
bool SuppressUserConversions,
|
||||
bool AllowExplicitConversions,
|
||||
bool InOverloadResolution) {
|
||||
ImplicitConversionSequence ICS
|
||||
= TryImplicitConversion(Initializer, Entity.getType(),
|
||||
SuppressUserConversions,
|
||||
AllowExplicitConversions,
|
||||
InOverloadResolution);
|
||||
if (ICS.isBad()) return true;
|
||||
|
||||
// Perform the actual conversion.
|
||||
Sequence.AddConversionSequenceStep(ICS, Entity.getType());
|
||||
return false;
|
||||
}
|
||||
|
||||
InitializationSequence::InitializationSequence(Sema &S,
|
||||
const InitializedEntity &Entity,
|
||||
const InitializationKind &Kind,
|
||||
|
@ -3378,7 +3360,7 @@ static ExprResult CopyObject(Sema &S,
|
|||
}
|
||||
|
||||
OverloadCandidateSet::iterator Best;
|
||||
switch (S.BestViableFunction(CandidateSet, Loc, Best)) {
|
||||
switch (CandidateSet.BestViableFunction(S, Loc, Best)) {
|
||||
case OR_Success:
|
||||
break;
|
||||
|
||||
|
@ -3388,8 +3370,7 @@ static ExprResult CopyObject(Sema &S,
|
|||
: diag::err_temp_copy_no_viable)
|
||||
<< (int)Entity.getKind() << CurInitExpr->getType()
|
||||
<< CurInitExpr->getSourceRange();
|
||||
S.PrintOverloadCandidates(CandidateSet, Sema::OCD_AllCandidates,
|
||||
&CurInitExpr, 1);
|
||||
CandidateSet.NoteCandidates(S, OCD_AllCandidates, &CurInitExpr, 1);
|
||||
if (!IsExtraneousCopy || S.isSFINAEContext())
|
||||
return S.ExprError();
|
||||
return move(CurInit);
|
||||
|
@ -3398,8 +3379,7 @@ static ExprResult CopyObject(Sema &S,
|
|||
S.Diag(Loc, diag::err_temp_copy_ambiguous)
|
||||
<< (int)Entity.getKind() << CurInitExpr->getType()
|
||||
<< CurInitExpr->getSourceRange();
|
||||
S.PrintOverloadCandidates(CandidateSet, Sema::OCD_ViableCandidates,
|
||||
&CurInitExpr, 1);
|
||||
CandidateSet.NoteCandidates(S, OCD_ViableCandidates, &CurInitExpr, 1);
|
||||
return S.ExprError();
|
||||
|
||||
case OR_Deleted:
|
||||
|
@ -4034,16 +4014,14 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
<< DestType << Args[0]->getType()
|
||||
<< Args[0]->getSourceRange();
|
||||
|
||||
S.PrintOverloadCandidates(FailedCandidateSet, Sema::OCD_ViableCandidates,
|
||||
Args, NumArgs);
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates, Args, NumArgs);
|
||||
break;
|
||||
|
||||
case OR_No_Viable_Function:
|
||||
S.Diag(Kind.getLocation(), diag::err_typecheck_nonviable_condition)
|
||||
<< Args[0]->getType() << DestType.getNonReferenceType()
|
||||
<< Args[0]->getSourceRange();
|
||||
S.PrintOverloadCandidates(FailedCandidateSet, Sema::OCD_AllCandidates,
|
||||
Args, NumArgs);
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates, Args, NumArgs);
|
||||
break;
|
||||
|
||||
case OR_Deleted: {
|
||||
|
@ -4051,9 +4029,8 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
<< Args[0]->getType() << DestType.getNonReferenceType()
|
||||
<< Args[0]->getSourceRange();
|
||||
OverloadCandidateSet::iterator Best;
|
||||
OverloadingResult Ovl = S.BestViableFunction(FailedCandidateSet,
|
||||
Kind.getLocation(),
|
||||
Best);
|
||||
OverloadingResult Ovl
|
||||
= FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
|
||||
if (Ovl == OR_Deleted) {
|
||||
S.Diag(Best->Function->getLocation(), diag::note_unavailable_here)
|
||||
<< Best->Function->isDeleted();
|
||||
|
@ -4146,8 +4123,8 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
case OR_Ambiguous:
|
||||
S.Diag(Kind.getLocation(), diag::err_ovl_ambiguous_init)
|
||||
<< DestType << ArgsRange;
|
||||
S.PrintOverloadCandidates(FailedCandidateSet,
|
||||
Sema::OCD_ViableCandidates, Args, NumArgs);
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_ViableCandidates,
|
||||
Args, NumArgs);
|
||||
break;
|
||||
|
||||
case OR_No_Viable_Function:
|
||||
|
@ -4192,17 +4169,15 @@ bool InitializationSequence::Diagnose(Sema &S,
|
|||
|
||||
S.Diag(Kind.getLocation(), diag::err_ovl_no_viable_function_in_init)
|
||||
<< DestType << ArgsRange;
|
||||
S.PrintOverloadCandidates(FailedCandidateSet, Sema::OCD_AllCandidates,
|
||||
Args, NumArgs);
|
||||
FailedCandidateSet.NoteCandidates(S, OCD_AllCandidates, Args, NumArgs);
|
||||
break;
|
||||
|
||||
case OR_Deleted: {
|
||||
S.Diag(Kind.getLocation(), diag::err_ovl_deleted_init)
|
||||
<< true << DestType << ArgsRange;
|
||||
OverloadCandidateSet::iterator Best;
|
||||
OverloadingResult Ovl = S.BestViableFunction(FailedCandidateSet,
|
||||
Kind.getLocation(),
|
||||
Best);
|
||||
OverloadingResult Ovl
|
||||
= FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best);
|
||||
if (Ovl == OR_Deleted) {
|
||||
S.Diag(Best->Function->getLocation(), diag::note_unavailable_here)
|
||||
<< Best->Function->isDeleted();
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче