clang 19.0.0git
Classes | Public Types | Public Member Functions | List of all members
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 }
 
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 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
 
bool empty () const
 
ConversionSequenceList allocateConversionSequences (unsigned NumConversions)
 Allocate storage for conversion sequences for NumConversions conversions.
 
OverloadCandidateaddCandidate (unsigned NumConversions=0, ConversionSequenceList Conversions=std::nullopt)
 Add a new candidate with NumConversions conversion sequence slots to the overload set.
 
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 980 of file Overload.h.

Member Typedef Documentation

◆ iterator

Definition at line 1153 of file Overload.h.

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.

Definition at line 982 of file Overload.h.

Constructor & Destructor Documentation

◆ OverloadCandidateSet() [1/2]

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

Definition at line 1121 of file Overload.h.

◆ OverloadCandidateSet() [2/2]

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

◆ ~OverloadCandidateSet()

clang::OverloadCandidateSet::~OverloadCandidateSet ( )
inline

Definition at line 1126 of file Overload.h.

Member Function Documentation

◆ addCandidate()

OverloadCandidate & clang::OverloadCandidateSet::addCandidate ( unsigned  NumConversions = 0,
ConversionSequenceList  Conversions = std::nullopt 
)
inline

◆ allocateConversionSequences()

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

Allocate storage for conversion sequences for NumConversions conversions.

Definition at line 1164 of file Overload.h.

Referenced by addCandidate(), and clang::Sema::CheckNonDependentConversions().

◆ begin()

iterator clang::OverloadCandidateSet::begin ( )
inline

◆ 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 10876 of file SemaOverload.cpp.

References begin(), clang::OverloadCandidate::Best, clang::SemaCUDA::CFP_SameSide, clang::SemaCUDA::CFP_WrongSide, clang::Sema::CUDA(), clang::Sema::diagnoseEquivalentInternalLinkageDeclarations(), end(), clang::OverloadCandidate::Function, clang::Sema::getCurFunctionDecl(), clang::Sema::getLangOpts(), clang::SemaCUDA::IdentifyPreference(), clang::isBetterOverloadCandidate(), clang::Sema::isEquivalentInternalLinkageDeclaration(), clang::OverloadCandidate::NotValidBecauseConstraintExprHasError(), clang::OR_Ambiguous, clang::OR_Deleted, clang::OR_No_Viable_Function, clang::OR_Success, and clang::OverloadCandidate::Viable.

Referenced by 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::InitializationSequence::Diagnose(), clang::Sema::DiagnoseEmptyLookup(), DiagnoseTwoPhaseLookup(), FindConditionalOverload(), FindConversionForRefInit(), clang::InitializationSequence::InitializeFrom(), IsInitializerListConstructorConversion(), IsUserDefinedConversion(), clang::Sema::LookupSpecialMember(), clang::Sema::PerformContextualImplicitConversion(), resolveAllocationOverload(), resolveBuiltinNewDeleteOverload(), ResolveConstructorOverload(), tryDiagnoseOverloadedCast(), TryRefInitWithConversionFunction(), TryTypoCorrectionForCall(), and TryUserDefinedConversion().

◆ clear()

void OverloadCandidateSet::clear ( CandidateSetKind  CSK)

◆ CompleteCandidates()

SmallVector< OverloadCandidate *, 32 > OverloadCandidateSet::CompleteCandidates ( Sema S,
OverloadCandidateDisplayKind  OCD,
ArrayRef< Expr * >  Args,
SourceLocation  OpLoc = SourceLocation(),
llvm::function_ref< bool(OverloadCandidate &)>  Filter = [](OverloadCandidate &) { return true; } 
)

◆ empty()

bool clang::OverloadCandidateSet::empty ( ) const
inline

◆ end()

iterator clang::OverloadCandidateSet::end ( )
inline

◆ exclude()

void clang::OverloadCandidateSet::exclude ( Decl F)
inline

Exclude a function from being considered by overload resolution.

Definition at line 1145 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 1213 of file Overload.h.

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

◆ getKind()

CandidateSetKind clang::OverloadCandidateSet::getKind ( ) const
inline

Definition at line 1129 of file Overload.h.

Referenced by clang::Sema::AddOverloadCandidate(), and mergeCandidatesWithResults().

◆ getLocation()

SourceLocation clang::OverloadCandidateSet::getLocation ( ) const
inline

◆ getRewriteInfo()

OperatorRewriteInfo clang::OverloadCandidateSet::getRewriteInfo ( ) const
inline

◆ isNewCandidate()

bool clang::OverloadCandidateSet::isNewCandidate ( Decl F,
OverloadCandidateParamOrder  PO = OverloadCandidateParamOrder::Normal 
)
inline

◆ NoteCandidates() [1/2]

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; } 
)

◆ NoteCandidates() [2/2]

void OverloadCandidateSet::NoteCandidates ( Sema S,
ArrayRef< Expr * >  Args,
ArrayRef< OverloadCandidate * >  Cands,
StringRef  Opc = "",
SourceLocation  OpLoc = SourceLocation() 
)

◆ operator=()

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

◆ setDestAS()

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

◆ shouldDeferDiags()

bool OverloadCandidateSet::shouldDeferDiags ( Sema S,
ArrayRef< Expr * >  Args,
SourceLocation  OpLoc 
)

Whether diagnostics should be deferred.

Definition at line 12624 of file SemaOverload.cpp.

References CompleteCandidates(), clang::Sema::getLangOpts(), clang::OCD_AllCandidates, and clang::ovl_fail_bad_target.

Referenced by clang::Sema::CreateOverloadedBinOp(), and NoteCandidates().

◆ size()

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

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