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;
202 assert(Idx < 3 &&
"To type index is out of range");
215 assert(Idx < 3 &&
"To type index is out of range");
392 unsigned ConversionKind : 30;
396 bool StdInitializerListElement : 1;
398 void setKind(
Kind K) {
427 : ConversionKind(Uninitialized), StdInitializerListElement(
false)
433 : ConversionKind(Other.ConversionKind),
434 StdInitializerListElement(Other.StdInitializerListElement)
436 switch (ConversionKind) {
437 case Uninitialized:
break;
454 assert(
isInitialized() &&
"querying uninitialized conversion");
455 return Kind(ConversionKind);
481 llvm_unreachable(
"Invalid ImplicitConversionSequence::Kind!");
500 Bad.
init(Failure, FromExpr, ToType);
507 Bad.
init(Failure, FromType, ToType);
522 return StdInitializerListElement;
526 StdInitializerListElement = V;
682 while (STy->isPointerType() || STy->isReferenceType())
708 llvm::SmallPtrSet<Decl *, 16> Functions;
712 llvm::BumpPtrAllocator ConversionSequenceAllocator;
717 unsigned NumInlineSequences;
718 llvm::AlignedCharArray<llvm::AlignOf<ImplicitConversionSequence>::Alignment,
724 void destroyCandidates();
728 : Loc(Loc),
Kind(CSK), NumInlineSequences(0) {}
747 size_t size()
const {
return Candidates.size(); }
748 bool empty()
const {
return Candidates.empty(); }
758 if (NumConversions + NumInlineSequences <= 16) {
762 NumInlineSequences += NumConversions;
770 for (
unsigned i = 0; i != NumConversions; ++i)
780 bool UserDefinedConversion =
false);
790 const OverloadCandidate& Cand1,
791 const OverloadCandidate& Cand2,
793 bool UserDefinedConversion =
false);
796 #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...
void setFromType(QualType T)
char Buffer[sizeof(ConversionSet)]
void setStdInitializerListElement(bool V=true)
QualType getToType() const
void setToType(QualType T)
void setFromType(QualType T)
QualType getConversionType() const
Returns the type that this conversion function is converting to.
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
ImplicitConversionSequence()
Defines the C++ template declaration subclasses.
Not a narrowing conversion.
unsigned IncompatibleObjC
Ambiguous candidates found.
Conversions between compatible types in C99.
bool IgnoreObjectArgument
ConversionSet::iterator iterator
Represents a C++ constructor within a class.
void * getAsOpaquePtr() const
SmallVector< FunctionDecl *, 4 > ConversionSet
bool HadMultipleCandidates
Removal of noreturn from a type (Clang)
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
unsigned BindsToFunctionLvalue
Whether we're binding to a function lvalue.
BadConversionSequence Bad
Identity conversion (no conversion)
ConversionSet & conversions()
QualType getToType() const
Floating point conversions (C++ 4.8)
const_iterator end() const
OverloadCandidateDisplayKind
Floating point promotions (C++ 4.6)
ImplicitConversionRank getRank() const
unsigned BindsToRvalue
Whether we're binding to an rvalue.
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...
ImplicitConversionKind Second
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).
Qualification conversions (C++ 4.4)
void setFromType(QualType T)
NarrowingKind getNarrowingKind(ASTContext &Context, const Expr *Converted, APValue &ConstantValue, QualType &ConstantType) const
The number of conversion kinds.
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion.
Complex <-> Real conversion.
bool Viable
Viable - True to indicate that this overload candidate is viable.
Integral promotions (C++ 4.5)
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
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)
Transparent Union Conversions.
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
QualType getPointeeType() const
ObjC ARC writeback conversion.
bool hasAmbiguousConversion() const
Represents an ambiguous user-defined conversion sequence.
StandardConversionSequence After
SmallVectorImpl< OverloadCandidate >::iterator iterator
void copyFrom(const AmbiguousConversionSequence &)
CXXConstructorDecl * CopyConstructor
void addConversion(FunctionDecl *D)
Overload resolution succeeded.
unsigned ReferenceBinding
QualType getFromType() const
Floating-integral conversions (C++ 4.9)
void init(FailureKind K, Expr *From, QualType To)
bool TryToFixBadConversion(unsigned Idx, Sema &S)
QualType getFromType() const
CXXConversionDecl * Surrogate
void NoteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation())
StandardConversionSequence Standard
Represents a C++ conversion function within a class.
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
QualType getFromType() const
Integral conversions (C++ 4.7)
Complex promotions (Clang extension)
bool isInitialized() const
OverloadCandidate - A single candidate in an overload set (C++ 13.3).
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
unsigned getNumParams() const
A vector splat from an arithmetic type.
Objective-C ARC writeback conversion.
void init(FailureKind K, QualType From, QualType To)
bool isStdInitializerListElement() const
Whether the target is really a std::initializer_list, and the sequence only represents the worst elem...
void setAsIdentityConversion()
Pointer conversions (C++ 4.10)
CandidateSetKind getKind() const
QualType getToType(unsigned Idx) const
Derived-to-base (C++ [over.best.ics])
Complex-real conversions (C99 6.3.1.7)
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)
ImplicitConversionRank GetConversionRank(ImplicitConversionKind Kind)
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
OverloadCandidateSet(SourceLocation Loc, CandidateSetKind CSK)
~ImplicitConversionSequence()
ConversionSet::const_iterator const_iterator
const ConversionSet & conversions() const
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.
unsigned getNumParams() const
bool isPointerConversionToBool() const
FunctionDecl * ConversionFunction
void setToType(QualType T)
void setAllToTypes(QualType T)
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
void setBad(BadConversionSequence::FailureKind Failure, QualType FromType, QualType ToType)
Sets this sequence as a bad conversion for an implicit argument.
Block Pointer conversions.
ConversionFixItGenerator Fix
The FixIt hints which can be used to fix the Bad candidate.
AmbiguousConversionSequence Ambiguous
const_iterator begin() const
Function-to-pointer (C++ 4.3)
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
Zero constant to event (OpenCL1.2 6.12.10)
void clear()
Clear out all of the candidates.
ImplicitConversionKind First
struct clang::OverloadCandidate::@202 BuiltinTypes
No viable function found.
DeductionFailureInfo DeductionFailure
Pointer-to-member conversions (C++ 4.11)
void setToType(unsigned Idx, QualType T)
bool isPointerConversionToVoidPointer(ASTContext &Context) const
SourceLocation getLocation() const