15 #ifndef LLVM_CLANG_SEMA_OVERLOAD_H
16 #define LLVM_CLANG_SEMA_OVERLOAD_H
26 #include "llvm/ADT/SmallPtrSet.h"
27 #include "llvm/ADT/SmallVector.h"
28 #include "llvm/Support/AlignOf.h"
29 #include "llvm/Support/Allocator.h"
33 class CXXConstructorDecl;
34 class CXXConversionDecl;
206 assert(Idx < 3 &&
"To type index is out of range");
219 assert(Idx < 3 &&
"To type index is out of range");
396 unsigned ConversionKind : 30;
400 unsigned StdInitializerListElement : 1;
402 void setKind(
Kind K) {
431 : ConversionKind(Uninitialized), StdInitializerListElement(
false)
437 : ConversionKind(Other.ConversionKind),
438 StdInitializerListElement(Other.StdInitializerListElement)
440 switch (ConversionKind) {
441 case Uninitialized:
break;
458 assert(
isInitialized() &&
"querying uninitialized conversion");
459 return Kind(ConversionKind);
485 llvm_unreachable(
"Invalid ImplicitConversionSequence::Kind!");
504 Bad.
init(Failure, FromExpr, ToType);
511 Bad.
init(Failure, FromType, ToType);
526 return StdInitializerListElement;
530 StdInitializerListElement = V;
689 while (STy->isPointerType() || STy->isReferenceType())
715 llvm::SmallPtrSet<Decl *, 16> Functions;
719 llvm::BumpPtrAllocator ConversionSequenceAllocator;
724 unsigned NumInlineSequences;
725 llvm::AlignedCharArray<llvm::AlignOf<ImplicitConversionSequence>::Alignment,
731 void destroyCandidates();
735 : Loc(Loc),
Kind(CSK), NumInlineSequences(0) {}
744 return Functions.insert(F->getCanonicalDecl()).second;
754 size_t size()
const {
return Candidates.size(); }
755 bool empty()
const {
return Candidates.empty(); }
765 if (NumConversions + NumInlineSequences <= 16) {
769 NumInlineSequences += NumConversions;
777 for (
unsigned i = 0; i != NumConversions; ++i)
787 bool UserDefinedConversion =
false);
797 const OverloadCandidate& Cand1,
798 const OverloadCandidate& Cand2,
800 bool UserDefinedConversion =
false);
811 if (isa<UsingDecl>(ND))
827 #endif // LLVM_CLANG_SEMA_OVERLOAD_H
unsigned ExplicitCallArguments
The number of call arguments that were explicitly provided, to be used while performing partial order...
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
unsigned DeprecatedStringLiteralToCharPtr
Whether this is the deprecated conversion of a string literal to a pointer to non-const character dat...
(CUDA) This candidate was not viable because the callee was not accessible from the caller's target (...
void setFromType(QualType T)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
char Buffer[sizeof(ConversionSet)]
void setStdInitializerListElement(bool V=true)
bool EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ...
QualType getToType() const
A (possibly-)qualified type.
void setToType(QualType T)
ImplicitConversionKind
ImplicitConversionKind - The kind of implicit conversion used to convert an argument to a parameter's...
void setFromType(QualType T)
QualType getConversionType() const
Returns the type that this conversion function is converting to.
A structure used to record information about a failed template argument deduction, for diagnosis.
void dump() const
dump - Print this standard conversion sequence to standard error.
C Language Family Type Representation.
bool tryToFixConversion(const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S)
If possible, generates and stores a fix for the given conversion.
Complex conversions (C99 6.3.1.6)
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
ImplicitConversionSequence()
ConstructorInfo getConstructorInfo(NamedDecl *ND)
Defines the C++ template declaration subclasses.
Not a narrowing conversion.
ImplicitConversionRank
ImplicitConversionRank - The rank of an implicit conversion kind.
unsigned IncompatibleObjC
IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actuall...
Ambiguous candidates found.
Conversions between compatible types in C99.
bool IgnoreObjectArgument
IgnoreObjectArgument - True to indicate that the first argument's conversion, which for this function...
ConversionSet::iterator iterator
unsigned DirectBinding
DirectBinding - True when this is a reference binding that is a direct binding (C++ [dcl...
Represents a C++ constructor within a class.
void * getAsOpaquePtr() const
bool IsSurrogate
IsSurrogate - True to indicate that this candidate is a surrogate for a conversion to a function poin...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
Removal of noreturn from a type (Clang)
void * ToTypePtrs[3]
ToType - The types that this conversion is converting to in each step.
ImplicitConversionSequence(const ImplicitConversionSequence &Other)
Boolean conversions (C++ 4.12)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
OverloadCandidate & addCandidate(unsigned NumConversions=0)
Add a new candidate with NumConversions conversion sequence slots to the overload set...
ImplicitConversionSequence * Conversions
Conversions - The conversion sequences used to convert the function arguments to the function paramet...
unsigned BindsToFunctionLvalue
Whether we're binding to a function lvalue.
BadConversionSequence Bad
When ConversionKind == BadConversion, provides the details of the bad conversion. ...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Identity conversion (no conversion)
Kind
Kind - The kind of implicit conversion sequence.
ConversionSet & conversions()
BadConversionSequence - Records information about an invalid conversion sequence. ...
QualType getToType() const
Floating point conversions (C++ 4.8)
const_iterator end() const
OverloadCandidateDisplayKind
Floating point promotions (C++ 4.6)
ImplicitConversionRank getRank() const
getRank - Retrieve the rank of this standard conversion sequence (C++ 13.3.3.1.1p3).
unsigned BindsToRvalue
Whether we're binding to an rvalue.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
Succeeded, but refers to a deleted function.
ImplicitConversionSequence & operator=(const ImplicitConversionSequence &Other)
unsigned QualificationIncludesObjCLifetime
Whether the qualification conversion involves a change in the Objective-C lifetime (for automatic ref...
This candidate function was not viable because an enable_if attribute disabled it.
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
A narrowing conversion, because a constant expression got narrowed.
unsigned IsLvalueReference
Whether this is an lvalue reference binding (otherwise, it's an rvalue reference binding).
NarrowingKind
NarrowingKind - The kind of narrowing conversion being performed by a standard conversion sequence ac...
Qualification conversions (C++ 4.4)
void setFromType(QualType T)
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType) const
Check if this standard conversion sequence represents a narrowing conversion, according to C++11 [dcl...
The number of conversion kinds.
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion.
detail::InMemoryDirectory::const_iterator I
Complex <-> Real conversion.
bool Viable
Viable - True to indicate that this overload candidate is viable.
Integral promotions (C++ 4.5)
This conversion function template specialization candidate is not viable because the final conversion...
Sema - This implements semantic analysis and AST building for C.
bool isBetterOverloadCandidate(Sema &S, const OverloadCandidate &Cand1, const OverloadCandidate &Cand2, SourceLocation Loc, bool UserDefinedConversion=false)
isBetterOverloadCandidate - Determines whether the first overload candidate is a better candidate tha...
Represents a prototype with parameter type info, e.g.
Transparent Union Conversions.
This conversion candidate was not considered because it duplicates the work of a trivial or derived-t...
bool isNewCandidate(Decl *F)
Determine when this overload candidate will be new to the overload set.
A narrowing conversion by virtue of the source and destination types.
StandardConversionSequence FinalConversion
FinalConversion - For a conversion function (where Function is a CXXConversionDecl), the standard conversion that occurs after the call to the overload candidate to convert the result of calling the conversion function to the required type.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
ObjC ARC writeback conversion.
bool hasAmbiguousConversion() const
hasAmbiguousConversion - Returns whether this overload candidate requires an ambiguous conversion or ...
void dump() const
dump - Print this user-defined conversion sequence to standard error.
Expr - This represents one expression.
Represents an ambiguous user-defined conversion sequence.
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion...
SmallVectorImpl< OverloadCandidate >::iterator iterator
void copyFrom(const AmbiguousConversionSequence &)
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
Overload resolution succeeded.
unsigned ReferenceBinding
ReferenceBinding - True when this is a reference binding (C++ [over.ics.ref]).
QualType getFromType() const
Floating-integral conversions (C++ 4.9)
void init(FailureKind K, Expr *From, QualType To)
This conversion candidate was not considered because it is an illegal instantiation of a constructor ...
bool TryToFixBadConversion(unsigned Idx, Sema &S)
QualType getFromType() const
CXXConversionDecl * Surrogate
Surrogate - The conversion function for which this candidate is a surrogate, but only if IsSurrogate ...
UserDefinedConversionSequence - Represents a user-defined conversion sequence (C++ 13...
This candidate was not viable because its address could not be taken.
void NoteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation())
PrintOverloadCandidates - When overload resolution fails, prints diagnostic messages containing the c...
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence...
Represents a C++ conversion function within a class.
A narrowing conversion, because a non-constant-expression variable might have got narrowed...
Lvalue-to-rvalue conversion (C++ 4.1)
unsigned ObjCLifetimeConversionBinding
Whether this binds a reference to an object with a different Objective-C lifetime qualifier...
unsigned NumConversions
NumConversions - The number of elements in the Conversions array.
bool isIdentityConversion() const
CXXConstructorDecl * Constructor
QualType getFromType() const
Integral conversions (C++ 4.7)
Complex promotions (Clang extension)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
bool isInitialized() const
Determines whether this conversion sequence has been initialized.
SmallVector< std::pair< NamedDecl *, FunctionDecl * >, 4 > ConversionSet
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
Encodes a location in the source.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
const TemplateArgument * iterator
A vector splat from an arithmetic type.
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
Objective-C ARC writeback conversion.
void init(FailureKind K, QualType From, QualType To)
void dump() const
dump - Print this implicit conversion sequence to standard error.
bool isStdInitializerListElement() const
Whether the target is really a std::initializer_list, and the sequence only represents the worst elem...
void setAsIdentityConversion()
StandardConversionSequence - Set the standard conversion sequence to the identity conversion...
Pointer conversions (C++ 4.10)
Lookup for candidates for a call using operator syntax.
CandidateSetKind getKind() const
QualType getToType(unsigned Idx) const
Requests that all candidates be shown.
Derived-to-base (C++ [over.best.ics])
Complex-real conversions (C99 6.3.1.7)
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
void setBad(BadConversionSequence::FailureKind Failure, Expr *FromExpr, QualType ToType)
Sets this sequence as a bad conversion for an explicit argument.
static QualType getFromOpaquePtr(const void *Ptr)
void setFromExpr(Expr *E)
A POD class for pairing a NamedDecl* with an access specifier.
ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind)
GetConversionRank - Retrieve the implicit conversion rank corresponding to the given implicit convers...
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
DeclAccessPair FoundCopyConstructor
OverloadCandidateSet(SourceLocation Loc, CandidateSetKind CSK)
~ImplicitConversionSequence()
ConversionSet::const_iterator const_iterator
const ConversionSet & conversions() const
Conversions allowed in C, but not C++.
Array-to-pointer conversion (C++ 4.2)
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
Requests that only viable candidates be shown.
detail::InMemoryDirectory::const_iterator E
FunctionDecl * Function
Function - The actual function that this candidate represents.
unsigned getNumParams() const
bool isPointerConversionToBool() const
isPointerConversionToBool - Determines whether this conversion is a conversion of a pointer or pointe...
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
Conversion only allowed in the C standard.
void setToType(QualType T)
void setAllToTypes(QualType T)
const T * getAs() const
Member-template getAs<specific type>'.
unsigned getKindRank() const
Return a ranking of the implicit conversion sequence kind, where smaller ranks represent better conve...
unsigned BindsImplicitObjectArgumentWithoutRefQualifier
Whether this binds an implicit object argument to a non-static member function without a ref-qualifie...
unsigned char FailureKind
FailureKind - The reason why this candidate is not viable.
void setBad(BadConversionSequence::FailureKind Failure, QualType FromType, QualType ToType)
Sets this sequence as a bad conversion for an implicit argument.
DeclAccessPair FoundDecl
FoundDecl - The original declaration that was looked up / invented / otherwise found, together with its access.
Block Pointer conversions.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
ConversionFixItGenerator Fix
The FixIt hints which can be used to fix the Bad candidate.
AmbiguousConversionSequence Ambiguous
When ConversionKind == AmbiguousConversion, provides the details of the ambiguous conversion...
void addConversion(NamedDecl *Found, FunctionDecl *D)
const_iterator begin() const
Function-to-pointer (C++ 4.3)
FunctionTemplateDecl * ConstructorTmpl
void * FromTypePtr
FromType - The type that this conversion is converting from.
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best, bool UserDefinedConversion=false)
Find the best viable function on this overload set, if it exists.
bool isUserDefined() const
The class facilities generation and storage of conversion FixIts.
Zero constant to event (OpenCL1.2 6.12.10)
void clear()
Clear out all of the candidates.
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion...
struct clang::OverloadCandidate::@202 BuiltinTypes
No viable function found.
DeductionFailureInfo DeductionFailure
NamedDecl - This represents a decl with a name.
Pointer-to-member conversions (C++ 4.11)
void setToType(unsigned Idx, QualType T)
bool isPointerConversionToVoidPointer(ASTContext &Context) const
isPointerConversionToVoidPointer - Determines whether this conversion is a conversion of a pointer to...
This conversion candidate is not viable because its result type is not implicitly convertible to the ...
Declaration of a template function.
SourceLocation getLocation() const
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).