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"


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 982 of file Overload.h.

Member Typedef Documentation

◆ iterator

Definition at line 1159 of file Overload.h.

Member Enumeration Documentation

◆ CandidateSetKind


Normal lookup.


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.


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


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.


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

Definition at line 984 of file Overload.h.

Constructor & Destructor Documentation

◆ OverloadCandidateSet() [1/2]

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

Definition at line 1127 of file Overload.h.

◆ OverloadCandidateSet() [2/2]

clang::OverloadCandidateSet::OverloadCandidateSet ( const OverloadCandidateSet )

◆ ~OverloadCandidateSet()

clang::OverloadCandidateSet::~OverloadCandidateSet ( )

Definition at line 1132 of file Overload.h.

Member Function Documentation

◆ addCandidate()

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

◆ allocateConversionSequences()

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

Allocate storage for conversion sequences for NumConversions conversions.

Definition at line 1170 of file Overload.h.

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

◆ begin()

iterator clang::OverloadCandidateSet::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.

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.
The result of overload resolution.

Definition at line 10872 of file SemaOverload.cpp.

References begin(), clang::OverloadCandidate::Best, clang::SemaCUDA::CFP_SameSide, clang::SemaCUDA::CFP_WrongSide, CSK_AddressOfOverloadSet, clang::Sema::CUDA(), clang::Sema::diagnoseEquivalentInternalLinkageDeclarations(), end(), clang::OverloadCandidate::Function, clang::Sema::getCurFunctionDecl(), clang::Sema::getLangOpts(), clang::SemaCUDA::IdentifyPreference(), clang::isBetterOverloadCandidate(), clang::Sema::isEquivalentInternalLinkageDeclaration(), Loc, 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

◆ end()

iterator clang::OverloadCandidateSet::end ( )

◆ exclude()

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

Exclude a function from being considered by overload resolution.

Definition at line 1151 of file Overload.h.

References isNewCandidate(), clang::Normal, and clang::Reversed.

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

◆ getDestAS()

LangAS clang::OverloadCandidateSet::getDestAS ( )

Definition at line 1219 of file Overload.h.

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

◆ getKind()

CandidateSetKind clang::OverloadCandidateSet::getKind ( ) const

◆ getLocation()

SourceLocation clang::OverloadCandidateSet::getLocation ( ) const

◆ getRewriteInfo()

OperatorRewriteInfo clang::OverloadCandidateSet::getRewriteInfo ( ) const

◆ isNewCandidate()

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

◆ 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 )

◆ setDestAS()

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

◆ shouldDeferDiags()

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

Whether diagnostics should be deferred.

Definition at line 12649 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

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