clang 22.0.0git
|
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13.3). More...
#include "clang/Sema/Overload.h"
Classes | |
struct | OperatorRewriteInfo |
Information about operator rewrites to consider when adding operator functions to a candidate set. More... |
Public Types | |
enum | CandidateSetKind { CSK_Normal , CSK_Operator , CSK_InitByUserDefinedConversion , CSK_InitByConstructor , CSK_AddressOfOverloadSet , CSK_CodeCompletion } |
using | iterator = SmallVectorImpl<OverloadCandidate>::iterator |
Public Member Functions | |
OverloadCandidateSet (SourceLocation Loc, CandidateSetKind CSK, OperatorRewriteInfo RewriteInfo={}) | |
OverloadCandidateSet (const OverloadCandidateSet &)=delete | |
OverloadCandidateSet & | operator= (const OverloadCandidateSet &)=delete |
~OverloadCandidateSet () | |
SourceLocation | getLocation () const |
CandidateSetKind | getKind () const |
OperatorRewriteInfo | getRewriteInfo () const |
bool | shouldDeferDiags (Sema &S, ArrayRef< Expr * > Args, SourceLocation OpLoc) |
Whether diagnostics should be deferred. | |
bool | shouldDeferTemplateArgumentDeduction (const LangOptions &Opts) const |
bool | isNewCandidate (Decl *F, OverloadCandidateParamOrder PO=OverloadCandidateParamOrder::Normal) |
Determine when this overload candidate will be new to the overload set. | |
void | exclude (Decl *F) |
Exclude a function from being considered by overload resolution. | |
void | clear (CandidateSetKind CSK) |
Clear out all of the candidates. | |
iterator | begin () |
iterator | end () |
size_t | size () const |
size_t | nonDeferredCandidatesCount () const |
bool | empty () const |
ConversionSequenceList | allocateConversionSequences (unsigned NumConversions) |
Allocate storage for conversion sequences for NumConversions conversions. | |
llvm::MutableArrayRef< Expr * > | getPersistentArgsArray (unsigned N) |
Provide storage for any Expr* arg that must be preserved until deferred template candidates are deduced. | |
template<typename... T> | |
llvm::MutableArrayRef< Expr * > | getPersistentArgsArray (T *...Exprs) |
OverloadCandidate & | addCandidate (unsigned NumConversions=0, ConversionSequenceList Conversions={}) |
Add a new candidate with NumConversions conversion sequence slots to the overload set. | |
void | AddDeferredTemplateCandidate (FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, bool AllowExplicit, CallExpr::ADLCallKind IsADLCandidate, OverloadCandidateParamOrder PO, bool AggregateCandidateDeduction) |
void | AddDeferredMethodTemplateCandidate (FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, bool SuppressUserConversions, bool PartialOverloading, OverloadCandidateParamOrder PO) |
void | AddDeferredConversionTemplateCandidate (FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, Expr *From, QualType ToType, bool AllowObjCConversionOnExplicit, bool AllowExplicit, bool AllowResultConversion) |
void | InjectNonDeducedTemplateCandidates (Sema &S) |
void | DisableResolutionByPerfectCandidate () |
OverloadingResult | BestViableFunction (Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best) |
Find the best viable function on this overload set, if it exists. | |
SmallVector< OverloadCandidate *, 32 > | CompleteCandidates (Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, SourceLocation OpLoc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;}) |
void | NoteCandidates (PartialDiagnosticAt PA, Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation(), llvm::function_ref< bool(OverloadCandidate &)> Filter=[](OverloadCandidate &) { return true;}) |
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate set. | |
void | NoteCandidates (Sema &S, ArrayRef< Expr * > Args, ArrayRef< OverloadCandidate * > Cands, StringRef Opc="", SourceLocation OpLoc=SourceLocation()) |
LangAS | getDestAS () |
void | setDestAS (LangAS AS) |
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13.3).
Definition at line 1153 of file Overload.h.
using clang::OverloadCandidateSet::iterator = SmallVectorImpl<OverloadCandidate>::iterator |
Definition at line 1369 of file Overload.h.
Definition at line 1155 of file Overload.h.
|
inline |
Definition at line 1331 of file Overload.h.
Referenced by operator=(), and OverloadCandidateSet().
|
delete |
References OverloadCandidateSet().
|
inline |
Definition at line 1339 of file Overload.h.
|
inline |
Add a new candidate with NumConversions conversion sequence slots to the overload set.
Definition at line 1416 of file Overload.h.
Referenced by clang::Sema::ActOnExplicitInstantiation(), clang::Sema::AddBuiltinCandidate(), clang::Sema::AddConversionCandidate(), clang::Sema::AddMethodCandidate(), AddMethodTemplateCandidateImmediately(), clang::Sema::AddOverloadCandidate(), clang::Sema::AddSurrogateCandidate(), AddTemplateConversionCandidateImmediately(), and AddTemplateOverloadCandidateImmediately().
void OverloadCandidateSet::AddDeferredConversionTemplateCandidate | ( | FunctionTemplateDecl * | FunctionTemplate, |
DeclAccessPair | FoundDecl, | ||
CXXRecordDecl * | ActingContext, | ||
Expr * | From, | ||
QualType | ToType, | ||
bool | AllowObjCConversionOnExplicit, | ||
bool | AllowExplicit, | ||
bool | AllowResultConversion ) |
Definition at line 11211 of file SemaOverload.cpp.
References clang::C, clang::DeferredTemplateOverloadCandidate::Conversion, and clang::FunctionTemplate.
Referenced by clang::Sema::AddTemplateConversionCandidate().
void OverloadCandidateSet::AddDeferredMethodTemplateCandidate | ( | FunctionTemplateDecl * | MethodTmpl, |
DeclAccessPair | FoundDecl, | ||
CXXRecordDecl * | ActingContext, | ||
QualType | ObjectType, | ||
Expr::Classification | ObjectClassification, | ||
ArrayRef< Expr * > | Args, | ||
bool | SuppressUserConversions, | ||
bool | PartialOverloading, | ||
OverloadCandidateParamOrder | PO ) |
Definition at line 11184 of file SemaOverload.cpp.
References clang::C, clang::FunctionTemplateDecl::getTemplatedDecl(), clang::isa(), and clang::DeferredTemplateOverloadCandidate::Method.
Referenced by clang::Sema::AddMethodTemplateCandidate().
void OverloadCandidateSet::AddDeferredTemplateCandidate | ( | FunctionTemplateDecl * | FunctionTemplate, |
DeclAccessPair | FoundDecl, | ||
ArrayRef< Expr * > | Args, | ||
bool | SuppressUserConversions, | ||
bool | PartialOverloading, | ||
bool | AllowExplicit, | ||
CallExpr::ADLCallKind | IsADLCandidate, | ||
OverloadCandidateParamOrder | PO, | ||
bool | AggregateCandidateDeduction ) |
Definition at line 11159 of file SemaOverload.cpp.
References clang::C, clang::DeferredTemplateOverloadCandidate::Function, clang::FunctionTemplate, and clang::isa().
Referenced by clang::Sema::AddTemplateOverloadCandidate().
|
inline |
Allocate storage for conversion sequences for NumConversions conversions.
Definition at line 1385 of file Overload.h.
Referenced by clang::Sema::CheckNonDependentConversions().
|
inline |
Definition at line 1371 of file Overload.h.
Referenced by clang::Sema::AddArgumentDependentLookupCandidates(), clang::Sema::BuildCallToObjectOfClassType(), ComputeSelectedDestructor(), FindConversionForRefInit(), markUnaddressableCandidatesUnviable(), clang::TemplateSpecCandidateSet::NoteCandidates(), and TryUserDefinedConversion().
OverloadingResult OverloadCandidateSet::BestViableFunction | ( | Sema & | S, |
SourceLocation | Loc, | ||
OverloadCandidateSet::iterator & | Best ) |
Find the best viable function on this overload set, if it exists.
Computes the best viable function (C++ 13.3.3) within an overload candidate set.
Loc | The location of the function name (or operator symbol) for which overload resolution occurs. |
Best | If overload resolution was successful or found a deleted function, Best points to the candidate function found. |
Definition at line 11345 of file SemaOverload.cpp.
References clang::Sema::Context, end(), clang::Sema::getLangOpts(), InjectNonDeducedTemplateCandidates(), and shouldDeferTemplateArgumentDeduction().
Referenced by clang::Sema::ActOnExplicitInstantiation(), clang::Sema::BuildCallToMemberFunction(), clang::Sema::BuildCallToObjectOfClassType(), clang::Sema::BuildForRangeBeginEndCall(), clang::Sema::BuildLiteralOperatorCall(), clang::Sema::BuildOverloadedArrowExpr(), clang::Sema::BuildOverloadedCallExpr(), clang::Sema::buildOverloadedCallSet(), ComputeSelectedDestructor(), clang::Sema::CreateOverloadedArraySubscriptExpr(), clang::Sema::CreateOverloadedBinOp(), clang::Sema::CreateOverloadedUnaryOp(), clang::Sema::DeduceTemplateSpecializationFromInitializer(), clang::Sema::DiagnoseEmptyLookup(), DiagnoseTwoPhaseLookup(), FindConditionalOverload(), FindConversionForRefInit(), IsInitializerListConstructorConversion(), IsUserDefinedConversion(), clang::Sema::LookupSpecialMember(), LookupSpecialMemberFromXValue(), clang::Sema::PerformContextualImplicitConversion(), resolveAllocationOverloadInterior(), resolveBuiltinNewDeleteOverload(), ResolveConstructorOverload(), tryDiagnoseOverloadedCast(), TryRefInitWithConversionFunction(), TryTypoCorrectionForCall(), and TryUserDefinedConversion().
void OverloadCandidateSet::clear | ( | CandidateSetKind | CSK | ) |
Clear out all of the candidates.
Definition at line 1123 of file SemaOverload.cpp.
Referenced by clang::Sema::BuildForRangeBeginEndCall(), clang::Sema::DeduceTemplateSpecializationFromInitializer(), IsInitializerListConstructorConversion(), IsUserDefinedConversion(), ResolveConstructorOverload(), TryRefInitWithConversionFunction(), and TryUserDefinedConversion().
SmallVector< OverloadCandidate *, 32 > OverloadCandidateSet::CompleteCandidates | ( | Sema & | S, |
OverloadCandidateDisplayKind | OCD, | ||
ArrayRef< Expr * > | Args, | ||
SourceLocation | OpLoc = SourceLocation(), | ||
llvm::function_ref< bool(OverloadCandidate &)> | Filter = [](OverloadCandidate &) { return true; } ) |
Definition at line 13140 of file SemaOverload.cpp.
References clang::OverloadCandidate::Best, CompleteNonViableCandidate(), clang::OverloadCandidate::Function, InjectNonDeducedTemplateCandidates(), clang::OverloadCandidate::IsSurrogate, clang::OCD_AllCandidates, clang::OCD_AmbiguousCandidates, clang::OCD_ViableCandidates, size(), and clang::OverloadCandidate::Viable.
Referenced by clang::Sema::BuildOverloadedArrowExpr(), clang::Sema::CreateOverloadedBinOp(), clang::Sema::DiagnoseMultipleUserDefinedConversion(), NoteCandidates(), resolveAllocationOverloadInterior(), and shouldDeferDiags().
|
inline |
Definition at line 1451 of file Overload.h.
Referenced by clang::Sema::AddTemplateConversionCandidate(), and clang::Sema::AddTemplateOverloadCandidate().
|
inline |
Definition at line 1378 of file Overload.h.
Referenced by clang::Sema::ActOnExplicitInstantiation(), clang::Sema::BuildCallToObjectOfClassType(), clang::Sema::BuildForRangeBeginEndCall(), clang::Sema::BuildOverloadedArrowExpr(), clang::Sema::buildOverloadedCallSet(), ComputeSelectedDestructor(), clang::Sema::CreateOverloadedArraySubscriptExpr(), clang::Sema::DiagnoseMultipleUserDefinedConversion(), FinishOverloadedCallExpr(), clang::SemaCodeCompletion::ProduceCallSignatureHelp(), tryDiagnoseOverloadedCast(), and TryReferenceInitializationCore().
|
inline |
Definition at line 1372 of file Overload.h.
Referenced by clang::Sema::AddArgumentDependentLookupCandidates(), BestViableFunction(), clang::Sema::BuildCallToObjectOfClassType(), clang::Sema::BuildOverloadedCallExpr(), chooseRecoveryType(), DiagnoseTwoPhaseLookup(), FindConversionForRefInit(), FinishOverloadedCallExpr(), markUnaddressableCandidatesUnviable(), clang::TemplateSpecCandidateSet::NoteCandidates(), and TryUserDefinedConversion().
|
inline |
Exclude a function from being considered by overload resolution.
Definition at line 1361 of file Overload.h.
References isNewCandidate(), clang::Normal, and clang::Reversed.
Referenced by clang::Sema::CreateOverloadedBinOp().
|
inline |
Definition at line 1477 of file Overload.h.
Referenced by clang::Sema::AddOverloadCandidate().
|
inline |
Definition at line 1342 of file Overload.h.
Referenced by clang::Sema::AddMethodCandidate(), AddMethodTemplateCandidateImmediately(), clang::Sema::AddOverloadCandidate(), clang::Sema::AddTemplateConversionCandidate(), AddTemplateOverloadCandidateImmediately(), clang::Sema::CheckNonDependentConversions(), FinishOverloadedCallExpr(), mergeCandidatesWithResults(), and TryConstructorInitialization().
|
inline |
Definition at line 1341 of file Overload.h.
Referenced by clang::Sema::AddConversionCandidate(), clang::Sema::AddMethodCandidate(), AddMethodTemplateCandidateImmediately(), clang::Sema::AddOverloadCandidate(), clang::Sema::AddSurrogateCandidate(), AddTemplateConversionCandidateImmediately(), AddTemplateOverloadCandidateImmediately(), clang::Sema::CheckNonDependentConversions(), and clang::Sema::LookupOverloadedBinOp().
|
inline |
Definition at line 1407 of file Overload.h.
References getPersistentArgsArray(), and clang::T.
|
inline |
Provide storage for any Expr* arg that must be preserved until deferred template candidates are deduced.
Typically this should be used for reversed operator arguments and any time the argument array is transformed while adding a template candidate.
Definition at line 1401 of file Overload.h.
Referenced by clang::Sema::AddArgumentDependentLookupCandidates(), clang::Sema::AddNonMemberOperatorCandidates(), clang::Sema::DeduceTemplateSpecializationFromInitializer(), getPersistentArgsArray(), and clang::Sema::LookupOverloadedBinOp().
|
inline |
Definition at line 1343 of file Overload.h.
Referenced by clang::Sema::AddArgumentDependentLookupCandidates(), clang::Sema::AddMemberOperatorCandidates(), clang::Sema::AddMethodCandidate(), AddMethodTemplateCandidateImmediately(), clang::Sema::AddNonMemberOperatorCandidates(), clang::Sema::AddOverloadCandidate(), clang::Sema::CreateOverloadedBinOp(), and clang::Sema::LookupOverloadedBinOp().
void OverloadCandidateSet::InjectNonDeducedTemplateCandidates | ( | Sema & | S | ) |
Definition at line 11263 of file SemaOverload.cpp.
References AddTemplateOverloadCandidate(), clang::DeferredTemplateOverloadCandidate::Conversion, clang::DeferredTemplateOverloadCandidate::Function, clang::DeferredTemplateOverloadCandidate::Method, and clang::DeferredTemplateOverloadCandidate::Next.
Referenced by BestViableFunction(), and CompleteCandidates().
|
inline |
Determine when this overload candidate will be new to the overload set.
Definition at line 1353 of file Overload.h.
References clang::Decl::getCanonicalDecl(), and clang::Normal.
Referenced by clang::Sema::AddConversionCandidate(), clang::Sema::AddMethodCandidate(), clang::Sema::AddMethodTemplateCandidate(), clang::Sema::AddOverloadCandidate(), clang::Sema::AddSurrogateCandidate(), clang::Sema::AddTemplateConversionCandidate(), clang::Sema::AddTemplateOverloadCandidate(), and exclude().
|
inline |
Definition at line 1376 of file Overload.h.
Referenced by clang::Sema::BuildCallToObjectOfClassType().
void OverloadCandidateSet::NoteCandidates | ( | PartialDiagnosticAt | PA, |
Sema & | S, | ||
OverloadCandidateDisplayKind | OCD, | ||
ArrayRef< Expr * > | Args, | ||
StringRef | Opc = "", | ||
SourceLocation | Loc = SourceLocation(), | ||
llvm::function_ref< bool(OverloadCandidate &)> | Filter = [](OverloadCandidate &) { return true; } ) |
When overload resolution fails, prints diagnostic messages containing the candidates in the candidate set.
Definition at line 13208 of file SemaOverload.cpp.
References CompleteCandidates(), clang::SemaBase::Diag(), MaybeDiagnoseAmbiguousConstraints(), NoteCandidates(), clang::OCD_AmbiguousCandidates, and shouldDeferDiags().
Referenced by clang::Sema::ActOnExplicitInstantiation(), clang::Sema::BuildCallToMemberFunction(), clang::Sema::BuildCallToObjectOfClassType(), clang::Sema::BuildCXXForRangeStmt(), clang::Sema::BuildLiteralOperatorCall(), BuildNonArrayForRange(), clang::Sema::BuildOverloadedArrowExpr(), CheckCXX98CompatAccessibleCopy(), ComputeSelectedDestructor(), CopyObject(), clang::Sema::CreateOverloadedArraySubscriptExpr(), clang::Sema::CreateOverloadedBinOp(), clang::Sema::CreateOverloadedUnaryOp(), clang::Sema::DeduceTemplateSpecializationFromInitializer(), clang::Sema::DiagnoseMultipleUserDefinedConversion(), clang::Sema::DiagnoseUseOfDeletedFunction(), FinishOverloadedCallExpr(), NoteCandidates(), resolveAllocationOverloadInterior(), resolveBuiltinNewDeleteOverload(), and tryDiagnoseOverloadedCast().
void OverloadCandidateSet::NoteCandidates | ( | Sema & | S, |
ArrayRef< Expr * > | Args, | ||
ArrayRef< OverloadCandidate * > | Cands, | ||
StringRef | Opc = "", | ||
SourceLocation | OpLoc = SourceLocation() ) |
Definition at line 13233 of file SemaOverload.cpp.
References CSK_AddressOfOverloadSet, clang::SemaBase::Diag(), clang::Sema::Diags, clang::OverloadCandidate::Function, clang::DiagnosticsEngine::getNumOverloadCandidatesToShow(), clang::DiagnosticsEngine::getShowOverloads(), int, clang::OverloadCandidate::IsSurrogate, NoteAmbiguousUserConversions(), NoteBuiltinOperatorCandidate(), NoteFunctionCandidate(), NoteSurrogateCandidate(), clang::DiagnosticsEngine::overloadCandidatesShown(), clang::Ovl_Best, shouldDeferDiags(), and clang::OverloadCandidate::Viable.
|
delete |
References OverloadCandidateSet().
|
inline |
Definition at line 1479 of file Overload.h.
References CSK_InitByConstructor, and CSK_InitByUserDefinedConversion.
Referenced by ResolveConstructorOverload(), and TryUserDefinedConversion().
bool OverloadCandidateSet::shouldDeferDiags | ( | Sema & | S, |
ArrayRef< Expr * > | Args, | ||
SourceLocation | OpLoc ) |
Whether diagnostics should be deferred.
Definition at line 13187 of file SemaOverload.cpp.
References CompleteCandidates(), clang::OverloadCandidate::FailureKind, clang::OverloadCandidate::Function, clang::Sema::getLangOpts(), hasAttr(), clang::OCD_AllCandidates, clang::ovl_fail_bad_target, and clang::OverloadCandidate::Viable.
Referenced by clang::Sema::CreateOverloadedBinOp(), NoteCandidates(), and NoteCandidates().
|
inline |
Definition at line 1542 of file Overload.h.
References CSK_CodeCompletion, and CSK_InitByUserDefinedConversion.
Referenced by clang::Sema::AddMethodTemplateCandidate(), clang::Sema::AddTemplateConversionCandidate(), clang::Sema::AddTemplateOverloadCandidate(), and BestViableFunction().
|
inline |
Definition at line 1374 of file Overload.h.
Referenced by clang::Sema::BuildCallToMemberFunction(), clang::Sema::BuildCallToObjectOfClassType(), clang::Sema::BuildLiteralOperatorCall(), clang::Sema::BuildOverloadedArrowExpr(), CompleteCandidates(), CopyObject(), clang::Sema::CreateOverloadedArraySubscriptExpr(), clang::Sema::CreateOverloadedBinOp(), clang::Sema::CreateOverloadedUnaryOp(), FindConversionForRefInit(), IsInitializerListConstructorConversion(), IsUserDefinedConversion(), clang::TemplateSpecCandidateSet::NoteCandidates(), TryConstructorInitialization(), TryRefInitWithConversionFunction(), and TryUserDefinedConversion().