clang 22.0.0git
clang::OverloadCandidateSet Class Reference

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
OverloadCandidateSetoperator= (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)
OverloadCandidateaddCandidate (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)

Detailed Description

OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13.3).

Definition at line 1153 of file Overload.h.

Member Typedef Documentation

◆ iterator

Member Enumeration Documentation

◆ CandidateSetKind

Enumerator
CSK_Normal 

Normal lookup.

CSK_Operator 

C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.

Candidates that have no parameters of class type will be skipped unless there is a parameter of (reference to) enum type and the corresponding argument is of the same enum type.

CSK_InitByUserDefinedConversion 

C++ [over.match.copy]: Copy-initialization of an object of class type by user-defined conversion.

CSK_InitByConstructor 

C++ [over.match.ctor], [over.match.list] Initialization of an object of class type by constructor, using either a parenthesized or braced list of arguments.

CSK_AddressOfOverloadSet 

C++ [over.match.call.general] Resolve a call through the address of an overload set.

CSK_CodeCompletion 

When doing overload resolution during code completion, we want to show all viable candidates, including otherwise deferred template candidates.

Definition at line 1155 of file Overload.h.

Constructor & Destructor Documentation

◆ OverloadCandidateSet() [1/2]

clang::OverloadCandidateSet::OverloadCandidateSet ( SourceLocation Loc,
CandidateSetKind CSK,
OperatorRewriteInfo RewriteInfo = {} )
inline

Definition at line 1331 of file Overload.h.

Referenced by operator=(), and OverloadCandidateSet().

◆ OverloadCandidateSet() [2/2]

clang::OverloadCandidateSet::OverloadCandidateSet ( const OverloadCandidateSet & )
delete

◆ ~OverloadCandidateSet()

clang::OverloadCandidateSet::~OverloadCandidateSet ( )
inline

Definition at line 1339 of file Overload.h.

Member Function Documentation

◆ addCandidate()

◆ AddDeferredConversionTemplateCandidate()

void OverloadCandidateSet::AddDeferredConversionTemplateCandidate ( FunctionTemplateDecl * FunctionTemplate,
DeclAccessPair FoundDecl,
CXXRecordDecl * ActingContext,
Expr * From,
QualType ToType,
bool AllowObjCConversionOnExplicit,
bool AllowExplicit,
bool AllowResultConversion )

◆ AddDeferredMethodTemplateCandidate()

void OverloadCandidateSet::AddDeferredMethodTemplateCandidate ( FunctionTemplateDecl * MethodTmpl,
DeclAccessPair FoundDecl,
CXXRecordDecl * ActingContext,
QualType ObjectType,
Expr::Classification ObjectClassification,
ArrayRef< Expr * > Args,
bool SuppressUserConversions,
bool PartialOverloading,
OverloadCandidateParamOrder PO )

◆ AddDeferredTemplateCandidate()

void OverloadCandidateSet::AddDeferredTemplateCandidate ( FunctionTemplateDecl * FunctionTemplate,
DeclAccessPair FoundDecl,
ArrayRef< Expr * > Args,
bool SuppressUserConversions,
bool PartialOverloading,
bool AllowExplicit,
CallExpr::ADLCallKind IsADLCandidate,
OverloadCandidateParamOrder PO,
bool AggregateCandidateDeduction )

◆ allocateConversionSequences()

ConversionSequenceList clang::OverloadCandidateSet::allocateConversionSequences ( unsigned NumConversions)
inline

Allocate storage for conversion sequences for NumConversions conversions.

Definition at line 1385 of file Overload.h.

Referenced by clang::Sema::CheckNonDependentConversions().

◆ begin()

◆ BestViableFunction()

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.

Parameters
LocThe location of the function name (or operator symbol) for which overload resolution occurs.
BestIf overload resolution was successful or found a deleted function, Best points to the candidate function found.
Returns
The result of overload resolution.

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().

◆ clear()

◆ CompleteCandidates()

◆ DisableResolutionByPerfectCandidate()

void clang::OverloadCandidateSet::DisableResolutionByPerfectCandidate ( )
inline

◆ empty()

◆ end()

◆ exclude()

void clang::OverloadCandidateSet::exclude ( Decl * F)
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().

◆ getDestAS()

LangAS clang::OverloadCandidateSet::getDestAS ( )
inline

Definition at line 1477 of file Overload.h.

Referenced by clang::Sema::AddOverloadCandidate().

◆ getKind()

◆ getLocation()

◆ getPersistentArgsArray() [1/2]

template<typename... T>
llvm::MutableArrayRef< Expr * > clang::OverloadCandidateSet::getPersistentArgsArray ( T *... Exprs)
inline

Definition at line 1407 of file Overload.h.

References getPersistentArgsArray(), and clang::T.

◆ getPersistentArgsArray() [2/2]

llvm::MutableArrayRef< Expr * > clang::OverloadCandidateSet::getPersistentArgsArray ( unsigned N)
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().

◆ getRewriteInfo()

◆ InjectNonDeducedTemplateCandidates()

◆ isNewCandidate()

◆ nonDeferredCandidatesCount()

size_t clang::OverloadCandidateSet::nonDeferredCandidatesCount ( ) const
inline

Definition at line 1376 of file Overload.h.

Referenced by clang::Sema::BuildCallToObjectOfClassType().

◆ NoteCandidates() [1/2]

◆ NoteCandidates() [2/2]

◆ operator=()

OverloadCandidateSet & clang::OverloadCandidateSet::operator= ( const OverloadCandidateSet & )
delete

◆ setDestAS()

void clang::OverloadCandidateSet::setDestAS ( LangAS AS)
inline

◆ shouldDeferDiags()

◆ shouldDeferTemplateArgumentDeduction()

bool clang::OverloadCandidateSet::shouldDeferTemplateArgumentDeduction ( const LangOptions & Opts) const
inline

◆ size()


The documentation for this class was generated from the following files: