clang  14.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. More...
 
bool isNewCandidate (Decl *F, OverloadCandidateParamOrder PO=OverloadCandidateParamOrder::Normal)
 Determine when this overload candidate will be new to the overload set. More...
 
void exclude (Decl *F)
 Exclude a function from being considered by overload resolution. More...
 
void clear (CandidateSetKind CSK)
 Clear out all of the candidates. More...
 
iterator begin ()
 
iterator end ()
 
size_t size () const
 
bool empty () const
 
ConversionSequenceList allocateConversionSequences (unsigned NumConversions)
 Allocate storage for conversion sequences for NumConversions conversions. More...
 
OverloadCandidateaddCandidate (unsigned NumConversions=0, ConversionSequenceList Conversions=None)
 Add a new candidate with NumConversions conversion sequence slots to the overload set. More...
 
OverloadingResult BestViableFunction (Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best)
 Find the best viable function on this overload set, if it exists. More...
 
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. More...
 
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 936 of file Overload.h.

Member Typedef Documentation

◆ iterator

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

Constructor & Destructor Documentation

◆ OverloadCandidateSet() [1/2]

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

Definition at line 1072 of file Overload.h.

◆ OverloadCandidateSet() [2/2]

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

◆ ~OverloadCandidateSet()

clang::OverloadCandidateSet::~OverloadCandidateSet ( )
inline

Definition at line 1077 of file Overload.h.

Member Function Documentation

◆ addCandidate()

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

Add a new candidate with NumConversions conversion sequence slots to the overload set.

Definition at line 1128 of file Overload.h.

References allocateConversionSequences().

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

◆ allocateConversionSequences()

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

Allocate storage for conversion sequences for NumConversions conversions.

Definition at line 1115 of file Overload.h.

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

◆ begin()

iterator clang::OverloadCandidateSet::begin ( )
inline

Definition at line 1106 of file Overload.h.

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

Referenced by clang::Sema::BuildLiteralOperatorCall(), clang::Sema::CreateOverloadedBinOp(), clang::Sema::CreateOverloadedUnaryOp(), clang::Sema::DeduceTemplateSpecializationFromInitializer(), DiagnoseTwoPhaseLookup(), and FindConditionalOverload().

◆ clear()

void OverloadCandidateSet::clear ( CandidateSetKind  CSK)

Clear out all of the candidates.

Definition at line 916 of file SemaOverload.cpp.

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

◆ 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

Definition at line 1110 of file Overload.h.

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

◆ end()

iterator clang::OverloadCandidateSet::end ( )
inline

Definition at line 1107 of file Overload.h.

Referenced by chooseRecoveryType(), and clang::Sema::PerformCopyInitialization().

◆ exclude()

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

Exclude a function from being considered by overload resolution.

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

◆ getKind()

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

Definition at line 1080 of file Overload.h.

◆ 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

Determine when this overload candidate will be new to the overload set.

Definition at line 1088 of file Overload.h.

References clang::Decl::getCanonicalDecl().

Referenced by exclude().

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

Definition at line 11736 of file SemaOverload.cpp.

◆ operator=()

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

◆ setDestAS()

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

Definition at line 1165 of file Overload.h.

References CSK_InitByConstructor, and CSK_InitByUserDefinedConversion.

◆ shouldDeferDiags()

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

Whether diagnostics should be deferred.

Definition at line 11700 of file SemaOverload.cpp.

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

◆ size()

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

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