diff options
Diffstat (limited to 'contrib/llvm-project/clang/include/clang/Sema/Overload.h')
-rw-r--r-- | contrib/llvm-project/clang/include/clang/Sema/Overload.h | 118 |
1 files changed, 88 insertions, 30 deletions
diff --git a/contrib/llvm-project/clang/include/clang/Sema/Overload.h b/contrib/llvm-project/clang/include/clang/Sema/Overload.h index 82661cb3d12a..6ccabad3af54 100644 --- a/contrib/llvm-project/clang/include/clang/Sema/Overload.h +++ b/contrib/llvm-project/clang/include/clang/Sema/Overload.h @@ -26,7 +26,6 @@ #include "clang/Sema/SemaFixItUtils.h" #include "clang/Sema/TemplateDeduction.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/None.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" @@ -163,6 +162,9 @@ class Sema; /// Arm SVE Vector conversions ICK_SVE_Vector_Conversion, + /// RISC-V RVV Vector conversions + ICK_RVV_Vector_Conversion, + /// A vector splat from an arithmetic type ICK_Vector_Splat, @@ -190,6 +192,9 @@ class Sema; /// C-only conversion between pointers with incompatible types ICK_Incompatible_Pointer_Conversion, + /// Fixed point type conversions according to N1169. + ICK_Fixed_Point_Conversion, + /// The number of conversion kinds ICK_Num_Conversion_Kinds, }; @@ -252,10 +257,7 @@ class Sema; /// sequence (C++ 13.3.3.1.1). A standard conversion sequence /// contains between zero and three conversions. If a particular /// conversion is not needed, it will be set to the identity conversion - /// (ICK_Identity). Note that the three conversions are - /// specified as separate members (rather than in an array) so that - /// we can keep the size of a standard conversion sequence to a - /// single word. + /// (ICK_Identity). class StandardConversionSequence { public: /// First -- The first conversion can be an lvalue-to-rvalue @@ -469,7 +471,9 @@ class Sema; unrelated_class, bad_qualifiers, lvalue_ref_to_rvalue, - rvalue_ref_to_lvalue + rvalue_ref_to_lvalue, + too_few_initializers, + too_many_initializers, }; // This can be null, e.g. for implicit object arguments. @@ -519,8 +523,12 @@ class Sema; /// specifies that there is no conversion from the source type to /// the target type. AmbiguousConversion represents the unique /// ambiguous conversion (C++0x [over.best.ics]p10). + /// StaticObjectArgumentConversion represents the conversion rules for + /// the synthesized first argument of calls to static member functions + /// ([over.best.ics.general]p8). enum Kind { StandardConversion = 0, + StaticObjectArgumentConversion, UserDefinedConversion, AmbiguousConversion, EllipsisConversion, @@ -533,11 +541,17 @@ class Sema; }; /// ConversionKind - The kind of implicit conversion sequence. - unsigned ConversionKind : 30; + unsigned ConversionKind : 31; + + // Whether the initializer list was of an incomplete array. + unsigned InitializerListOfIncompleteArray : 1; - /// Whether the target is really a std::initializer_list, and the - /// sequence only represents the worst element conversion. - unsigned StdInitializerListElement : 1; + /// When initializing an array or std::initializer_list from an + /// initializer-list, this is the array or std::initializer_list type being + /// initialized. The remainder of the conversion sequence, including ToType, + /// describe the worst conversion of an initializer to an element of the + /// array or std::initializer_list. (Note, 'worst' is not well defined.) + QualType InitializerListContainerType; void setKind(Kind K) { destruct(); @@ -568,16 +582,21 @@ class Sema; }; ImplicitConversionSequence() - : ConversionKind(Uninitialized), StdInitializerListElement(false) { + : ConversionKind(Uninitialized), + InitializerListOfIncompleteArray(false) { Standard.setAsIdentityConversion(); } ImplicitConversionSequence(const ImplicitConversionSequence &Other) : ConversionKind(Other.ConversionKind), - StdInitializerListElement(Other.StdInitializerListElement) { + InitializerListOfIncompleteArray( + Other.InitializerListOfIncompleteArray), + InitializerListContainerType(Other.InitializerListContainerType) { switch (ConversionKind) { case Uninitialized: break; case StandardConversion: Standard = Other.Standard; break; + case StaticObjectArgumentConversion: + break; case UserDefinedConversion: UserDefined = Other.UserDefined; break; case AmbiguousConversion: Ambiguous.copyFrom(Other.Ambiguous); break; case EllipsisConversion: break; @@ -611,6 +630,7 @@ class Sema; unsigned getKindRank() const { switch (getKind()) { case StandardConversion: + case StaticObjectArgumentConversion: return 0; case UserDefinedConversion: @@ -629,6 +649,9 @@ class Sema; bool isBad() const { return getKind() == BadConversion; } bool isStandard() const { return getKind() == StandardConversion; } + bool isStaticObjectArgument() const { + return getKind() == StaticObjectArgumentConversion; + } bool isEllipsis() const { return getKind() == EllipsisConversion; } bool isAmbiguous() const { return getKind() == AmbiguousConversion; } bool isUserDefined() const { return getKind() == UserDefinedConversion; } @@ -654,6 +677,7 @@ class Sema; } void setStandard() { setKind(StandardConversion); } + void setStaticObjectArgument() { setKind(StaticObjectArgumentConversion); } void setEllipsis() { setKind(EllipsisConversion); } void setUserDefined() { setKind(UserDefinedConversion); } @@ -670,14 +694,22 @@ class Sema; Standard.setAllToTypes(T); } - /// Whether the target is really a std::initializer_list, and the - /// sequence only represents the worst element conversion. - bool isStdInitializerListElement() const { - return StdInitializerListElement; + // True iff this is a conversion sequence from an initializer list to an + // array or std::initializer. + bool hasInitializerListContainerType() const { + return !InitializerListContainerType.isNull(); } - - void setStdInitializerListElement(bool V = true) { - StdInitializerListElement = V; + void setInitializerListContainerType(QualType T, bool IA) { + InitializerListContainerType = T; + InitializerListOfIncompleteArray = IA; + } + bool isInitializerListOfIncompleteArray() const { + return InitializerListOfIncompleteArray; + } + QualType getInitializerListContainerType() const { + assert(hasInitializerListContainerType() && + "not initializer list container"); + return InitializerListContainerType; } /// Form an "implicit" conversion sequence from nullptr_t to bool, for a @@ -776,6 +808,10 @@ class Sema; /// This candidate was not viable because its associated constraints were /// not satisfied. ovl_fail_constraints_not_satisfied, + + /// This candidate was not viable because it has internal linkage and is + /// from a different module unit than the use. + ovl_fail_module_mismatched, }; /// A list of implicit conversion sequences for the arguments of an @@ -905,6 +941,8 @@ class Sema; return ExplicitCallArguments; } + bool NotValidBecauseConstraintExprHasError() const; + private: friend class OverloadCandidateSet; OverloadCandidate() @@ -941,12 +979,16 @@ class Sema; /// functions to a candidate set. struct OperatorRewriteInfo { OperatorRewriteInfo() - : OriginalOperator(OO_None), AllowRewrittenCandidates(false) {} - OperatorRewriteInfo(OverloadedOperatorKind Op, bool AllowRewritten) - : OriginalOperator(Op), AllowRewrittenCandidates(AllowRewritten) {} + : OriginalOperator(OO_None), OpLoc(), AllowRewrittenCandidates(false) {} + OperatorRewriteInfo(OverloadedOperatorKind Op, SourceLocation OpLoc, + bool AllowRewritten) + : OriginalOperator(Op), OpLoc(OpLoc), + AllowRewrittenCandidates(AllowRewritten) {} /// The original operator as written in the source. OverloadedOperatorKind OriginalOperator; + /// The source location of the operator. + SourceLocation OpLoc; /// Whether we should include rewritten candidates in the overload set. bool AllowRewrittenCandidates; @@ -982,22 +1024,23 @@ class Sema; CRK = OverloadCandidateRewriteKind(CRK | CRK_Reversed); return CRK; } - /// Determines whether this operator could be implemented by a function /// with reversed parameter order. bool isReversible() { return AllowRewrittenCandidates && OriginalOperator && (getRewrittenOverloadedOperator(OriginalOperator) != OO_None || - shouldAddReversed(OriginalOperator)); + allowsReversed(OriginalOperator)); } - /// Determine whether we should consider looking for and adding reversed - /// candidates for operator Op. - bool shouldAddReversed(OverloadedOperatorKind Op); + /// Determine whether reversing parameter order is allowed for operator + /// Op. + bool allowsReversed(OverloadedOperatorKind Op); /// Determine whether we should add a rewritten candidate for \p FD with /// reversed parameter order. - bool shouldAddReversed(ASTContext &Ctx, const FunctionDecl *FD); + /// \param OriginalArgs are the original non reversed arguments. + bool shouldAddReversed(Sema &S, ArrayRef<Expr *> OriginalArgs, + FunctionDecl *FD); }; private: @@ -1105,8 +1148,9 @@ class Sema; /// Add a new candidate with NumConversions conversion sequence slots /// to the overload set. - OverloadCandidate &addCandidate(unsigned NumConversions = 0, - ConversionSequenceList Conversions = None) { + OverloadCandidate & + addCandidate(unsigned NumConversions = 0, + ConversionSequenceList Conversions = std::nullopt) { assert((Conversions.empty() || Conversions.size() == NumConversions) && "preallocated conversion sequence has wrong length"); @@ -1184,6 +1228,20 @@ class Sema; return Info; } + // Returns false if signature help is relevant despite number of arguments + // exceeding parameters. Specifically, it returns false when + // PartialOverloading is true and one of the following: + // * Function is variadic + // * Function is template variadic + // * Function is an instantiation of template variadic function + // The last case may seem strange. The idea is that if we added one more + // argument, we'd end up with a function similar to Function. Since, in the + // context of signature help and/or code completion, we do not know what the + // type of the next argument (that the user is typing) will be, this is as + // good candidate as we can get, despite the fact that it takes one less + // parameter. + bool shouldEnforceArgLimit(bool PartialOverloading, FunctionDecl *Function); + } // namespace clang #endif // LLVM_CLANG_SEMA_OVERLOAD_H |