clang 10.0.0git

Classes | Namespaces | Macros | Enumerations | Functions
SemaTemplateDeduction.cpp File Reference
`#include "clang/Sema/TemplateDeduction.h"`
`#include "TreeTransform.h"`
`#include "TypeLocBuilder.h"`
`#include "clang/AST/ASTContext.h"`
`#include "clang/AST/ASTLambda.h"`
`#include "clang/AST/Decl.h"`
`#include "clang/AST/DeclAccessPair.h"`
`#include "clang/AST/DeclBase.h"`
`#include "clang/AST/DeclCXX.h"`
`#include "clang/AST/DeclTemplate.h"`
`#include "clang/AST/DeclarationName.h"`
`#include "clang/AST/Expr.h"`
`#include "clang/AST/ExprCXX.h"`
`#include "clang/AST/NestedNameSpecifier.h"`
`#include "clang/AST/RecursiveASTVisitor.h"`
`#include "clang/AST/TemplateBase.h"`
`#include "clang/AST/TemplateName.h"`
`#include "clang/AST/Type.h"`
`#include "clang/AST/TypeLoc.h"`
`#include "clang/AST/UnresolvedSet.h"`
`#include "clang/Basic/AddressSpaces.h"`
`#include "clang/Basic/ExceptionSpecificationType.h"`
`#include "clang/Basic/LLVM.h"`
`#include "clang/Basic/LangOptions.h"`
`#include "clang/Basic/PartialDiagnostic.h"`
`#include "clang/Basic/SourceLocation.h"`
`#include "clang/Basic/Specifiers.h"`
`#include "clang/Sema/Ownership.h"`
`#include "clang/Sema/Sema.h"`
`#include "clang/Sema/Template.h"`
`#include "llvm/ADT/APInt.h"`
`#include "llvm/ADT/APSInt.h"`
`#include "llvm/ADT/ArrayRef.h"`
`#include "llvm/ADT/DenseMap.h"`
`#include "llvm/ADT/FoldingSet.h"`
`#include "llvm/ADT/Optional.h"`
`#include "llvm/ADT/SmallBitVector.h"`
`#include "llvm/ADT/SmallPtrSet.h"`
`#include "llvm/ADT/SmallVector.h"`
`#include "llvm/Support/Casting.h"`
`#include "llvm/Support/Compiler.h"`
`#include "llvm/Support/ErrorHandling.h"`
`#include <algorithm>`
`#include <cassert>`
`#include <tuple>`
`#include <utility>`
`#include "clang/AST/TypeNodes.inc"`
Include dependency graph for SemaTemplateDeduction.cpp:

Go to the source code of this file.

## Classes
struct | clang::DeducedPack
| A pack that we're currently deducing. More...
struct | IsPartialSpecialization< T >
struct | IsPartialSpecialization< ClassTemplatePartialSpecializationDecl >
struct | IsPartialSpecialization< VarTemplatePartialSpecializationDecl >

## Namespaces
| clang
| Dataflow Directional Tag Classes.

## Macros
#define | NON_CANONICAL_TYPE(Class, Base) case Type::Class: llvm_unreachable("deducing non-canonical type: " #Class);
#define | TYPE(Class, Base)
#define | ABSTRACT_TYPE(Class, Base)
#define | DEPENDENT_TYPE(Class, Base)
#define | NON_CANONICAL_TYPE(Class, Base) case Type::Class:

## Enumerations
enum | clang::TemplateDeductionFlags { clang::TDF_None = 0, clang::TDF_ParamWithReferenceType = 0x1, clang::TDF_IgnoreQualifiers = 0x02, clang::TDF_DerivedClass = 0x04, clang::TDF_SkipNonDependent = 0x08, clang::TDF_TopLevelParameterTypeList = 0x10, clang::TDF_AllowCompatibleFunctionType = 0x20, clang::TDF_ArgWithReferenceType = 0x40 }
| Various flags that control template argument deduction. More...

## Functions
static bool | hasSameExtendedValue (llvm::APSInt X, llvm::APSInt Y)
| Compare two APSInts, extending and switching the sign as necessary to compare their values regardless of underlying type. More...
static Sema::TemplateDeductionResult | DeduceTemplateArguments (Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &Param, TemplateArgument Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
static Sema::TemplateDeductionResult | DeduceTemplateArgumentsByTypeMatch (Sema &S, TemplateParameterList *TemplateParams, QualType ParamIn, QualType ArgIn, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned TDF, bool PartialOrdering, bool DeducedFromArrayBound)
| Deduce the template arguments by comparing the parameter type and the argument type (C++ [temp.deduct.type]). More...
static Sema::TemplateDeductionResult | DeduceTemplateArguments (Sema &S, TemplateParameterList *TemplateParams, ArrayRef< TemplateArgument > Params, ArrayRef< TemplateArgument > Args, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, bool NumberOfArgumentsMustMatch)
static void | MarkUsedTemplateParameters (ASTContext &Ctx, const TemplateArgument &TemplateArg, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
| Mark the template parameters that are used by this template argument. More...
static void | MarkUsedTemplateParameters (ASTContext &Ctx, QualType T, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
| Mark the template parameters that are used by the given type. More...
static NonTypeTemplateParmDecl * | getDeducedParameterFromExpr (TemplateDeductionInfo &Info, Expr *E)
| If the given expression is of a form that permits the deduction of a non-type template parameter, return the declaration of that non-type template parameter. More...
static bool | isSameDeclaration (Decl *X, Decl *Y)
| Determine whether two declaration pointers refer to the same declaration. More...
static DeducedTemplateArgument | checkDeducedTemplateArguments (ASTContext &Context, const DeducedTemplateArgument &X, const DeducedTemplateArgument &Y)
| Verify that the given, deduced template arguments are compatible. More...
static Sema::TemplateDeductionResult | DeduceNonTypeTemplateArgument (Sema &S, TemplateParameterList *TemplateParams, NonTypeTemplateParmDecl *NTTP, const DeducedTemplateArgument &NewDeduced, QualType ValueType, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
| Deduce the value of the given non-type template parameter as the given deduced template argument. More...
static Sema::TemplateDeductionResult | DeduceNonTypeTemplateArgument (Sema &S, TemplateParameterList *TemplateParams, NonTypeTemplateParmDecl *NTTP, const llvm::APSInt &Value, QualType ValueType, bool DeducedFromArrayBound, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
| Deduce the value of the given non-type template parameter from the given integral constant. More...
static Sema::TemplateDeductionResult | DeduceNullPtrTemplateArgument (Sema &S, TemplateParameterList *TemplateParams, NonTypeTemplateParmDecl *NTTP, QualType NullPtrType, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
| Deduce the value of the given non-type template parameter from the given null pointer template argument type. More...
static Sema::TemplateDeductionResult | DeduceNonTypeTemplateArgument (Sema &S, TemplateParameterList *TemplateParams, NonTypeTemplateParmDecl *NTTP, Expr *Value, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
| Deduce the value of the given non-type template parameter from the given type- or value-dependent expression. More...
static Sema::TemplateDeductionResult | DeduceNonTypeTemplateArgument (Sema &S, TemplateParameterList *TemplateParams, NonTypeTemplateParmDecl *NTTP, ValueDecl *D, QualType T, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
| Deduce the value of the given non-type template parameter from the given declaration. More...
static Sema::TemplateDeductionResult | DeduceTemplateArguments (Sema &S, TemplateParameterList *TemplateParams, TemplateName Param, TemplateName Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
static Sema::TemplateDeductionResult | DeduceTemplateArguments (Sema &S, TemplateParameterList *TemplateParams, const TemplateSpecializationType *Param, QualType Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
| Deduce the template arguments by comparing the template parameter type (which is a template-id) with the template argument type. More...
static bool | IsPossiblyOpaquelyQualifiedType (QualType T)
| Determines whether the given type is an opaque type that might be more qualified when instantiated. More...
static TemplateParameter | makeTemplateParameter (Decl *D)
| Helper function to build a TemplateParameter when we don't know its type statically. More...
static Optional< unsigned > | getExpandedPackSize (NamedDecl *Param)
| If `Param` is an expanded parameter pack, get the number of expansions. More...
static Sema::TemplateDeductionResult | DeduceTemplateArguments (Sema &S, TemplateParameterList *TemplateParams, const QualType *Params, unsigned NumParams, const QualType *Args, unsigned NumArgs, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, unsigned TDF, bool PartialOrdering=false)
| Deduce the template arguments by comparing the list of parameter types to the list of argument types, as in the parameter-type-lists of function types (C++ [temp.deduct.type]p10). More...
static bool | hasInconsistentOrSupersetQualifiersOf (QualType ParamType, QualType ArgType)
| Determine whether the parameter has qualifiers that the argument lacks. More...
static unsigned | getFirstInnerIndex (FunctionTemplateDecl *FTD)
| Get the index of the first template parameter that was originally from the innermost template-parameter-list. More...
static bool | isForwardingReference (QualType Param, unsigned FirstInnerIndex)
| Determine whether a type denotes a forwarding reference. More...
static bool | hasTemplateArgumentForDeduction (ArrayRef< TemplateArgument > &Args, unsigned &ArgIdx)
| Determine whether there is a template argument to be used for deduction. More...
static bool | hasPackExpansionBeforeEnd (ArrayRef< TemplateArgument > Args)
| Determine whether the given set of template arguments has a pack expansion that is not the last template argument. More...
static Sema::TemplateDeductionResult | DeduceTemplateArguments (Sema &S, TemplateParameterList *TemplateParams, const TemplateArgumentList &ParamList, const TemplateArgumentList &ArgList, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
static bool | isSameTemplateArg (ASTContext &Context, TemplateArgument X, const TemplateArgument &Y, bool PackExpansionMatchesPack=false)
| Determine whether two template arguments are the same. More...
static bool | ConvertDeducedTemplateArgument (Sema &S, NamedDecl *Param, DeducedTemplateArgument Arg, NamedDecl *Template, TemplateDeductionInfo &Info, bool IsDeduced, SmallVectorImpl< TemplateArgument > &Output)
| Convert the given deduced template argument and add it to the set of fully-converted template arguments. More...
template<typename TemplateDeclT >
static Sema::TemplateDeductionResult | ConvertDeducedTemplateArguments (Sema &S, TemplateDeclT *Template, bool IsDeduced, SmallVectorImpl< DeducedTemplateArgument > &Deduced, TemplateDeductionInfo &Info, SmallVectorImpl< TemplateArgument > &Builder, LocalInstantiationScope *CurrentInstantiationScope=nullptr, unsigned NumAlreadyConverted=0, bool PartialOverloading=false)
static DeclContext * | getAsDeclContextOrEnclosing (Decl *D)
template<typename TemplateDeclT >
static Sema::TemplateDeductionResult | CheckDeducedArgumentConstraints (Sema &S, TemplateDeclT *Template, ArrayRef< TemplateArgument > DeducedArgs, TemplateDeductionInfo &Info)
template<typename T >
static std::enable_if< IsPartialSpecialization< T >::value, Sema::TemplateDeductionResult >::type | FinishTemplateArgumentDeduction (Sema &S, T *Partial, bool IsPartialOrdering, const TemplateArgumentList &TemplateArgs, SmallVectorImpl< DeducedTemplateArgument > &Deduced, TemplateDeductionInfo &Info)
| Complete template argument deduction for a partial specialization. More...
static Sema::TemplateDeductionResult | FinishTemplateArgumentDeduction (Sema &S, TemplateDecl *Template, bool PartialOrdering, const TemplateArgumentList &TemplateArgs, SmallVectorImpl< DeducedTemplateArgument > &Deduced, TemplateDeductionInfo &Info)
| Complete template argument deduction for a class or variable template, when partial ordering against a partial specialization. More...
static bool | isSimpleTemplateIdType (QualType T)
| Determine whether the given type T is a simple-template-id type. More...
static Sema::TemplateDeductionResult | CheckOriginalCallArgDeduction (Sema &S, TemplateDeductionInfo &Info, Sema::OriginalCallArg OriginalArg, QualType DeducedA)
| Check whether the deduced argument type for a call to a function template matches the actual argument type per C++ [temp.deduct.call]p4. More...
static unsigned | getPackIndexForParam (Sema &S, FunctionTemplateDecl *FunctionTemplate, const MultiLevelTemplateArgumentList &Args, unsigned ParamIdx)
| Find the pack index for a particular parameter index in an instantiation of a function template with specific arguments. More...
static QualType | GetTypeOfFunction (Sema &S, const OverloadExpr::FindResult &R, FunctionDecl *Fn)
| Gets the type of a function for template-argument-deducton purposes when it's considered as part of an overload set. More...
static QualType | ResolveOverloadForDeduction (Sema &S, TemplateParameterList *TemplateParams, Expr *Arg, QualType ParamType, bool ParamWasReference)
| Apply the deduction rules for overload sets. More...
static bool | AdjustFunctionParmAndArgTypesForDeduction (Sema &S, TemplateParameterList *TemplateParams, unsigned FirstInnerIndex, QualType &ParamType, QualType &ArgType, Expr *Arg, unsigned &TDF)
| Perform the adjustments to the parameter and argument types described in C++ [temp.deduct.call]. More...
static bool | hasDeducibleTemplateParameters (Sema &S, FunctionTemplateDecl *FunctionTemplate, QualType T)
static Sema::TemplateDeductionResult | DeduceTemplateArgumentsFromCallArgument (Sema &S, TemplateParameterList *TemplateParams, unsigned FirstInnerIndex, QualType ParamType, Expr *Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, SmallVectorImpl< Sema::OriginalCallArg > &OriginalCallArgs, bool DecomposedParam, unsigned ArgIdx, unsigned TDF)
| Perform template argument deduction per [temp.deduct.call] for a single parameter / argument pair. More...
static Sema::TemplateDeductionResult | DeduceFromInitializerList (Sema &S, TemplateParameterList *TemplateParams, QualType AdjustedParamType, InitListExpr *ILE, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, SmallVectorImpl< Sema::OriginalCallArg > &OriginalCallArgs, unsigned ArgIdx, unsigned TDF)
| Attempt template argument deduction from an initializer list deemed to be an argument in a function call. More...
static bool | diagnoseAutoDeductionFailure (Sema &S, Sema::TemplateDeductionResult TDK, TemplateDeductionInfo &Info, ArrayRef< SourceRange > Ranges)
| Attempt to produce an informative diagostic explaining why auto deduction failed. More...
static Sema::DeduceAutoResult | CheckDeducedPlaceholderConstraints (Sema &S, const AutoType &Type, AutoTypeLoc TypeLoc, QualType Deduced)
static void | AddImplicitObjectParameterType (ASTContext &Context, CXXMethodDecl *Method, SmallVectorImpl< QualType > &ArgTypes)
| If this is a non-static member function,. More...
static bool | isAtLeastAsSpecializedAs (Sema &S, SourceLocation Loc, FunctionTemplateDecl *FT1, FunctionTemplateDecl *FT2, TemplatePartialOrderingContext TPOC, unsigned NumCallArguments1)
| Determine whether the function template `FT1` is at least as specialized as `FT2`. More...
static bool | isVariadicFunctionTemplate (FunctionTemplateDecl *FunTmpl)
| Determine whether this a function template whose parameter-type-list ends with a function parameter pack. More...
static bool | isSameTemplate (TemplateDecl *T1, TemplateDecl *T2)
| Determine if the two templates are equivalent. More...
template<typename TemplateLikeDecl >
static bool | isAtLeastAsSpecializedAs (Sema &S, QualType T1, QualType T2, TemplateLikeDecl *P2, TemplateDeductionInfo &Info)
| Determine whether one partial specialization, P1, is at least as specialized than another, P2. More...
static void | MarkUsedTemplateParameters (ASTContext &Ctx, const Expr *E, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
| Mark the template parameters that are used by the given expression. More...
static void | MarkUsedTemplateParameters (ASTContext &Ctx, NestedNameSpecifier *NNS, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
| Mark the template parameters that are used by the given nested name specifier. More...
static void | MarkUsedTemplateParameters (ASTContext &Ctx, TemplateName Name, bool OnlyDeduced, unsigned Depth, llvm::SmallBitVector &Used)
| Mark the template parameters that are used by the given template name. More...

## Macro Definition Documentation

## ◆ ABSTRACT_TYPE

#define ABSTRACT_TYPE | ( |  | Class,
|  |  | Base
| ) |  |

## ◆ DEPENDENT_TYPE

#define DEPENDENT_TYPE | ( |  | Class,
|  |  | Base
| ) |  |

## ◆ NON_CANONICAL_TYPE [1/2]

#define NON_CANONICAL_TYPE | ( |  | Class,
|  |  | Base
| ) |  | case Type::Class: llvm_unreachable("deducing non-canonical type: " #Class);

## ◆ NON_CANONICAL_TYPE [2/2]

#define NON_CANONICAL_TYPE | ( |  | Class,
|  |  | Base
| ) |  | case Type::Class:

## ◆ TYPE [1/2]

#define TYPE | ( |  | Class,
|  |  | Base
| ) |  |

## ◆ TYPE [2/2]

#define TYPE | ( |  | Class,
|  |  | Base
| ) |  |

## Function Documentation

## ◆ AddImplicitObjectParameterType()

static void AddImplicitObjectParameterType | ( | ASTContext & | Context,
|  | CXXMethodDecl * | Method,
|  | SmallVectorImpl< QualType > & | ArgTypes
| ) |  |
| static

If this is a non-static member function,.

Definition at line 4841 of file SemaTemplateDeduction.cpp.

Referenced by isAtLeastAsSpecializedAs().

## ◆ AdjustFunctionParmAndArgTypesForDeduction()

static bool AdjustFunctionParmAndArgTypesForDeduction | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | unsigned | FirstInnerIndex,
|  | QualType & | ParamType,
|  | QualType & | ArgType,
|  | Expr * | Arg,
|  | unsigned & | TDF
| ) |  |
| static

Perform the adjustments to the parameter and argument types described in C++ [temp.deduct.call].

Returns
  true if the caller should not attempt to perform any template argument deduction based on this P/A pair because the argument is an overloaded function set that could not be resolved.

Definition at line 3662 of file SemaTemplateDeduction.cpp.

References clang::Sema::completeExprArrayBound(), clang::Sema::Context, DeduceTemplateArgumentsFromCallArgument(), clang::ASTContext::getArrayDecayedType(), clang::Type::getAs(), clang::ASTContext::getLValueReferenceType(), clang::PointerType::getPointeeType(), clang::ReferenceType::getPointeeType(), clang::ASTContext::getPointerType(), clang::Expr::getType(), clang::QualType::getUnqualifiedType(), hasDeducibleTemplateParameters(), clang::QualType::hasQualifiers(), clang::Type::isArrayType(), isForwardingReference(), clang::Type::isFunctionType(), clang::Type::isIncompleteArrayType(), clang::Expr::isLValue(), clang::Type::isMemberPointerType(), clang::QualType::isNull(), clang::Type::isObjCObjectPointerType(), clang::Type::isPointerType(), isSimpleTemplateIdType(), clang::ASTContext::OverloadTy, ResolveOverloadForDeduction(), clang::TDF_DerivedClass, clang::TDF_IgnoreQualifiers, clang::TDF_ParamWithReferenceType, and clang::TDF_SkipNonDependent.

Referenced by DeduceTemplateArgumentsFromCallArgument().

## ◆ CheckDeducedArgumentConstraints()

template<typename TemplateDeclT >

static Sema::TemplateDeductionResult CheckDeducedArgumentConstraints | ( | Sema & | S,
|  | TemplateDeclT * | Template,
|  | ArrayRef< TemplateArgument > | DeducedArgs,
|  | TemplateDeductionInfo & | Info
| ) |  |
| static

Definition at line 2750 of file SemaTemplateDeduction.cpp.

References clang::sema::TemplateDeductionInfo::AssociatedConstraintsSatisfaction, clang::Sema::CheckConstraintSatisfaction(), clang::Sema::Context, clang::TemplateArgumentList::CreateCopy(), clang::sema::TemplateDeductionInfo::getLocation(), clang::ConstraintSatisfaction::IsSatisfied, clang::sema::TemplateDeductionInfo::reset(), clang::Sema::TDK_ConstraintsNotSatisfied, and clang::Sema::TDK_Success.

## ◆ CheckDeducedPlaceholderConstraints()

static Sema::DeduceAutoResult CheckDeducedPlaceholderConstraints | ( | Sema & | S,
|  | const AutoType & | Type,
|  | AutoTypeLoc | TypeLoc,
|  | QualType | Deduced
| ) |  |
| static

Definition at line 4487 of file SemaTemplateDeduction.cpp.

References clang::TemplateArgumentListInfo::addArgument(), clang::Sema::CheckConstraintSatisfaction(), clang::Sema::CheckTemplateArgumentList(), clang::Sema::Context, clang::Sema::DAR_FailedAlreadyDiagnosed, clang::Sema::DAR_Succeeded, clang::Sema::Diag(), clang::Sema::DiagnoseUnsatisfiedConstraint(), clang::AutoTypeLoc::getArgLoc(), clang::AutoTypeLoc::getConceptNameLoc(), clang::AutoTypeLoc::getLAngleLoc(), clang::AutoTypeLoc::getLocalSourceRange(), clang::NamedDecl::getName(), clang::TypeSpecTypeLoc::getNameLoc(), clang::AutoTypeLoc::getNumArgs(), clang::Sema::getPrintingPolicy(), clang::AutoTypeLoc::getRAngleLoc(), clang::ASTContext::getTrivialTypeSourceInfo(), clang::AutoType::getTypeConstraintArguments(), clang::AutoType::getTypeConstraintConcept(), clang::AutoTypeLoc::hasExplicitTemplateArgs(), and clang::ConstraintSatisfaction::IsSatisfied.

## ◆ checkDeducedTemplateArguments()

static DeducedTemplateArgument checkDeducedTemplateArguments | ( | ASTContext & | Context,
|  | const DeducedTemplateArgument & | X,
|  | const DeducedTemplateArgument & | Y
| ) |  |
| static

Verify that the given, deduced template arguments are compatible.

Returns
  The deduced template argument, or a NULL template argument if the deduced template arguments were incompatible.

Definition at line 214 of file SemaTemplateDeduction.cpp.

Referenced by DeduceNonTypeTemplateArgument(), and DeduceTemplateArguments().

## ◆ CheckOriginalCallArgDeduction()

static Sema::TemplateDeductionResult CheckOriginalCallArgDeduction | ( | Sema & | S,
|  | TemplateDeductionInfo & | Info,
|  | Sema::OriginalCallArg | OriginalArg,
|  | QualType | DeducedA
| ) |  |
| static

Check whether the deduced argument type for a call to a function template matches the actual argument type per C++ [temp.deduct.call]p4.

Definition at line 3224 of file SemaTemplateDeduction.cpp.

## ◆ ConvertDeducedTemplateArgument()

static bool ConvertDeducedTemplateArgument | ( | Sema & | S,
|  | NamedDecl * | Param,
|  | DeducedTemplateArgument | Arg,
|  | NamedDecl * | Template,
|  | TemplateDeductionInfo & | Info,
|  | bool | IsDeduced,
|  | SmallVectorImpl< TemplateArgument > & | Output
| ) |  |
| static

Convert the given deduced template argument and add it to the set of fully-converted template arguments.

Definition at line 2543 of file SemaTemplateDeduction.cpp.

References clang::Sema::CheckTemplateArgument(), clang::Sema::Context, clang::TemplateArgument::CreatePackCopy(), clang::Sema::CTAK_Deduced, clang::Sema::CTAK_DeducedFromArrayBound, clang::Sema::CTAK_Specified, clang::Sema::CurContext, clang::Sema::Diag(), clang::SourceRange::getEnd(), clang::TemplateArgument::getKind(), clang::sema::TemplateDeductionInfo::getLocation(), clang::Decl::getLocation(), clang::Decl::getSourceRange(), clang::Sema::getTrivialTemplateArgumentLoc(), clang::TemplateArgumentList::OnStack, P, clang::TemplateArgument::Pack, clang::TemplateArgument::pack_elements(), clang::DeducedTemplateArgument::setDeducedFromArrayBound(), clang::Sema::SubstDecl(), clang::Sema::SubstType(), and clang::DeducedTemplateArgument::wasDeducedFromArrayBound().

## ◆ ConvertDeducedTemplateArguments()

template<typename TemplateDeclT >

static Sema::TemplateDeductionResult ConvertDeducedTemplateArguments | ( | Sema & | S,
|  | TemplateDeclT * | Template,
|  | bool | IsDeduced,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< TemplateArgument > & | Builder,
|  | LocalInstantiationScope * | CurrentInstantiationScope = `nullptr`,
|  | unsigned | NumAlreadyConverted = `0`,
|  | bool | PartialOverloading = `false`
| ) |  |
| static

Definition at line 2634 of file SemaTemplateDeduction.cpp.

## ◆ DeduceFromInitializerList()

static Sema::TemplateDeductionResult DeduceFromInitializerList | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | QualType | AdjustedParamType,
|  | InitListExpr * | ILE,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced,
|  | SmallVectorImpl< Sema::OriginalCallArg > & | OriginalCallArgs,
|  | unsigned | ArgIdx,
|  | unsigned | TDF
| ) |  |
| static

Attempt template argument deduction from an initializer list deemed to be an argument in a function call.

Definition at line 3765 of file SemaTemplateDeduction.cpp.

References clang::Sema::Context, DeduceNonTypeTemplateArgument(), DeduceTemplateArgumentsFromCallArgument(), clang::ASTContext::getAsArrayType(), getDeducedParameterFromExpr(), clang::ASTContext::getIntWidth(), clang::InitListExpr::getNumInits(), clang::ASTContext::getSizeType(), clang::InitListExpr::inits(), clang::Type::isDependentType(), clang::Sema::isStdInitializerList(), and clang::Sema::TDK_Success.

Referenced by DeduceTemplateArgumentsFromCallArgument().

## ◆ DeduceNonTypeTemplateArgument() [1/4]

static Sema::TemplateDeductionResult DeduceNonTypeTemplateArgument | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | NonTypeTemplateParmDecl * | NTTP,
|  | const DeducedTemplateArgument & | NewDeduced,
|  | QualType | ValueType,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced
| ) |  |
| static

Deduce the value of the given non-type template parameter as the given deduced template argument.

All non-type template parameter deduction is funneled through here.

Definition at line 375 of file SemaTemplateDeduction.cpp.

References checkDeducedTemplateArguments(), clang::Sema::Context, DeduceTemplateArgumentsByTypeMatch(), clang::sema::TemplateDeductionInfo::FirstArg, clang::ASTContext::getAdjustedParameterType(), clang::sema::TemplateDeductionInfo::getDeducedDepth(), clang::TemplateParmPosition::getDepth(), clang::TemplateParmPosition::getIndex(), clang::Sema::getLangOpts(), clang::QualType::getNonReferenceType(), clang::ValueDecl::getType(), clang::NonTypeTemplateParmDecl::isExpandedParameterPack(), clang::sema::TemplateDeductionInfo::Param, clang::sema::TemplateDeductionInfo::SecondArg, clang::TDF_SkipNonDependent, clang::Sema::TDK_Inconsistent, clang::Sema::TDK_Success, and clang::DeducedTemplateArgument::wasDeducedFromArrayBound().

Referenced by DeduceFromInitializerList(), DeduceNonTypeTemplateArgument(), DeduceNullPtrTemplateArgument(), and DeduceTemplateArguments().

## ◆ DeduceNonTypeTemplateArgument() [2/4]

static Sema::TemplateDeductionResult DeduceNonTypeTemplateArgument | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | NonTypeTemplateParmDecl * | NTTP,
|  | const llvm::APSInt & | Value,
|  | QualType | ValueType,
|  | bool | DeducedFromArrayBound,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced
| ) |  |
| static

Deduce the value of the given non-type template parameter from the given integral constant.

Definition at line 422 of file SemaTemplateDeduction.cpp.

References clang::Sema::Context, and DeduceNonTypeTemplateArgument().

## ◆ DeduceNonTypeTemplateArgument() [3/4]

static Sema::TemplateDeductionResult DeduceNonTypeTemplateArgument | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | NonTypeTemplateParmDecl * | NTTP,
|  | Expr * | Value,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced
| ) |  |
| static

Deduce the value of the given non-type template parameter from the given type- or value-dependent expression.

Returns
  true if deduction succeeded, false otherwise.

Definition at line 455 of file SemaTemplateDeduction.cpp.

References DeduceNonTypeTemplateArgument(), and clang::Expr::getType().

## ◆ DeduceNonTypeTemplateArgument() [4/4]

static Sema::TemplateDeductionResult DeduceNonTypeTemplateArgument | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | NonTypeTemplateParmDecl * | NTTP,
|  | ValueDecl * | D,
|  | QualType | T,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced
| ) |  |
| static

Deduce the value of the given non-type template parameter from the given declaration.

Returns
  true if deduction succeeded, false otherwise.

Definition at line 468 of file SemaTemplateDeduction.cpp.

References DeduceNonTypeTemplateArgument(), and clang::Decl::getCanonicalDecl().

## ◆ DeduceNullPtrTemplateArgument()

static Sema::TemplateDeductionResult DeduceNullPtrTemplateArgument | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | NonTypeTemplateParmDecl * | NTTP,
|  | QualType | NullPtrType,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced
| ) |  |
| static

Deduce the value of the given non-type template parameter from the given null pointer template argument type.

Definition at line 436 of file SemaTemplateDeduction.cpp.

References clang::Sema::Context, DeduceNonTypeTemplateArgument(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::Decl::getLocation(), clang::Expr::getType(), clang::Sema::ImpCastExprToType(), and clang::ASTContext::NullPtrTy.

Referenced by DeduceTemplateArguments().

## ◆ DeduceTemplateArguments() [1/6]

static Sema::TemplateDeductionResult DeduceTemplateArguments | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | const TemplateArgument & | Param,
|  | TemplateArgument | Arg,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced
| ) |  |
| static

Definition at line 2129 of file SemaTemplateDeduction.cpp.

References clang::Sema::Context, clang::TemplateArgument::Declaration, DeduceNonTypeTemplateArgument(), DeduceNullPtrTemplateArgument(), DeduceTemplateArgumentsByTypeMatch(), clang::TemplateArgument::Expression, clang::sema::TemplateDeductionInfo::FirstArg, clang::TemplateArgument::getAsDecl(), clang::TemplateArgument::getAsExpr(), clang::TemplateArgument::getAsIntegral(), clang::TemplateArgument::getAsTemplate(), clang::TemplateArgument::getAsType(), getDeducedParameterFromExpr(), clang::TemplateArgument::getIntegralType(), clang::TemplateArgument::getKind(), clang::TemplateArgument::getNullPtrType(), clang::TemplateArgument::getPackExpansionPattern(), clang::TemplateArgument::getParamTypeForDecl(), hasSameExtendedValue(), clang::ASTContext::hasSameType(), clang::TemplateArgument::Integral, clang::TemplateArgument::isPackExpansion(), isSameDeclaration(), clang::TemplateArgument::Null, clang::TemplateArgument::NullPtr, clang::TemplateArgument::Pack, clang::sema::TemplateDeductionInfo::SecondArg, clang::Sema::TDK_NonDeducedMismatch, clang::Sema::TDK_Success, clang::TemplateArgument::Template, clang::TemplateArgument::TemplateExpansion, and clang::TemplateArgument::Type.

Referenced by DeduceTemplateArguments(), clang::Sema::DeduceTemplateArguments(), hasSameExtendedValue(), isAtLeastAsSpecializedAs(), and clang::Sema::ResolveSingleFunctionTemplateSpecialization().

## ◆ DeduceTemplateArguments() [2/6]

static Sema::TemplateDeductionResult DeduceTemplateArguments | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | ArrayRef< TemplateArgument > | Params,
|  | ArrayRef< TemplateArgument > | Args,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced,
|  | bool | NumberOfArgumentsMustMatch
| ) |  |
| static

Definition at line 2286 of file SemaTemplateDeduction.cpp.

References DeduceTemplateArguments(), clang::TemplateArgument::getPackExpansionPattern(), hasPackExpansionBeforeEnd(), hasTemplateArgumentForDeduction(), clang::Sema::TDK_MiscellaneousDeductionFailure, and clang::Sema::TDK_Success.

## ◆ DeduceTemplateArguments() [3/6]

static Sema::TemplateDeductionResult DeduceTemplateArguments | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | TemplateName | Param,
|  | TemplateName | Arg,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced
| ) |  |
| static

Definition at line 480 of file SemaTemplateDeduction.cpp.

References checkDeducedTemplateArguments(), clang::Sema::Context, clang::sema::TemplateDeductionInfo::FirstArg, clang::TemplateName::getAsTemplateDecl(), clang::ASTContext::getCanonicalTemplateName(), clang::sema::TemplateDeductionInfo::getDeducedDepth(), clang::ASTContext::hasSameTemplateName(), clang::sema::TemplateDeductionInfo::Param, clang::sema::TemplateDeductionInfo::SecondArg, clang::Sema::TDK_Inconsistent, clang::Sema::TDK_NonDeducedMismatch, and clang::Sema::TDK_Success.

## ◆ DeduceTemplateArguments() [4/6]

static Sema::TemplateDeductionResult DeduceTemplateArguments | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | const TemplateSpecializationType * | Param,
|  | QualType | Arg,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced
| ) |  |
| static

Deduce the template arguments by comparing the template parameter type (which is a template-id) with the template argument type.

Parameters

  S | the Sema
  TemplateParams | the template parameters that we are deducing
  Param | the parameter type
  Arg | the argument type
  Info | information about the template argument deduction itself
  Deduced | the deduced template arguments

Returns
  the result of template argument deduction so far. Note that a "success" result means that template argument deduction has not yet failed, but it may still fail, later, for other reasons.

Definition at line 543 of file SemaTemplateDeduction.cpp.

References clang::TemplateArgumentList::asArray(), DeduceTemplateArguments(), clang::sema::TemplateDeductionInfo::FirstArg, clang::ClassTemplateSpecializationDecl::getSpecializedTemplate(), clang::ClassTemplateSpecializationDecl::getTemplateArgs(), clang::TemplateSpecializationType::getTemplateName(), clang::QualType::isCanonical(), clang::sema::TemplateDeductionInfo::SecondArg, clang::Sema::TDK_NonDeducedMismatch, and clang::TemplateSpecializationType::template_arguments().

## ◆ DeduceTemplateArguments() [5/6]

static Sema::TemplateDeductionResult DeduceTemplateArguments | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | const QualType * | Params,
|  | unsigned | NumParams,
|  | const QualType * | Args,
|  | unsigned | NumArgs,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced,
|  | unsigned | TDF,
|  | bool | PartialOrdering = `false`
| ) |  |
| static

Deduce the template arguments by comparing the list of parameter types to the list of argument types, as in the parameter-type-lists of function types (C++ [temp.deduct.type]p10).

Parameters

  S | The semantic analysis object within which we are deducing
  TemplateParams | The template parameters that we are deducing
  Params | The list of parameter types
  NumParams | The number of types in `Params`
  Args | The list of argument types
  NumArgs | The number of types in `Args`
  Info | information about the template argument deduction itself
  Deduced | the deduced template arguments
  TDF | bitwise OR of the TemplateDeductionFlags bits that describe how template argument deduction is performed.
  PartialOrdering | If true, we are performing template argument deduction for during partial ordering for a call (C++0x [temp.deduct.partial]).

Returns
  the result of template argument deduction so far. Note that a "success" result means that template argument deduction has not yet failed, but it may still fail, later, for other reasons.

Definition at line 1014 of file SemaTemplateDeduction.cpp.

References DeduceTemplateArgumentsByTypeMatch(), clang::PackExpansionType::getNumExpansions(), clang::PackExpansionType::getPattern(), clang::PartialOrdering, clang::Sema::TDK_MiscellaneousDeductionFailure, and clang::Sema::TDK_Success.

## ◆ DeduceTemplateArguments() [6/6]

static Sema::TemplateDeductionResult DeduceTemplateArguments | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | const TemplateArgumentList & | ParamList,
|  | const TemplateArgumentList & | ArgList,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced
| ) |  |
| static

Definition at line 2369 of file SemaTemplateDeduction.cpp.

References clang::TemplateArgumentList::asArray(), and DeduceTemplateArguments().

## ◆ DeduceTemplateArgumentsByTypeMatch()

static Sema::TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | QualType | ParamIn,
|  | QualType | ArgIn,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced,
|  | unsigned | TDF,
|  | bool | PartialOrdering,
|  | bool | DeducedFromArrayBound
| ) |  |
| static

Deduce the template arguments by comparing the parameter type and the argument type (C++ [temp.deduct.type]).

Parameters

  S | the semantic analysis object within which we are deducing
  TemplateParams | the template parameters that we are deducing
  ParamIn | the parameter type
  ArgIn | the argument type
  Info | information about the template argument deduction itself
  Deduced | the deduced template arguments
  TDF | bitwise OR of the TemplateDeductionFlags bits that describe how template argument deduction is performed.
  PartialOrdering | Whether we're performing template argument deduction in the context of partial ordering (C++0x [temp.deduct.partial]).

Returns
  the result of template argument deduction so far. Note that a "success" result means that template argument deduction has not yet failed, but it may still fail, later, for other reasons.

Definition at line 1228 of file SemaTemplateDeduction.cpp.

References clang::Sema::Context, clang::sema::TemplateDeductionInfo::FirstArg, clang::Type::getAs(), clang::ASTContext::getCanonicalType(), clang::Qualifiers::getCVRQualifiers(), clang::QualType::getCVRQualifiers(), clang::sema::TemplateDeductionInfo::getDeducedDepth(), clang::Qualifiers::getObjCLifetime(), clang::Type::getPointeeType(), clang::ReferenceType::getPointeeType(), clang::ASTContext::getQualifiedType(), clang::QualType::getQualifiers(), clang::ASTContext::getUnqualifiedArrayType(), clang::QualType::getUnqualifiedType(), clang::Qualifiers::hasNonTrivialObjCLifetime(), clang::ASTContext::hasSameUnqualifiedType(), isForwardingReference(), clang::Type::isFunctionType(), clang::Type::isLValueReferenceType(), clang::Type::isPlaceholderType(), clang::Qualifiers::isStrictSupersetOf(), clang::Qualifiers::OCL_ExplicitNone, clang::sema::TemplateDeductionInfo::SecondArg, clang::Qualifiers::setCVRQualifiers(), clang::TDF_ParamWithReferenceType, clang::TDF_TopLevelParameterTypeList, clang::Sema::TDK_NonDeducedMismatch, clang::Sema::TDK_Success, and clang::Qualifiers::withoutObjCLifetime().

Referenced by DeduceNonTypeTemplateArgument(), DeduceTemplateArguments(), DeduceTemplateArgumentsFromCallArgument(), isAtLeastAsSpecializedAs(), and ResolveOverloadForDeduction().

## ◆ DeduceTemplateArgumentsFromCallArgument()

static Sema::TemplateDeductionResult DeduceTemplateArgumentsFromCallArgument | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | unsigned | FirstInnerIndex,
|  | QualType | ParamType,
|  | Expr * | Arg,
|  | TemplateDeductionInfo & | Info,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced,
|  | SmallVectorImpl< Sema::OriginalCallArg > & | OriginalCallArgs,
|  | bool | DecomposedParam,
|  | unsigned | ArgIdx,
|  | unsigned | TDF
| ) |  |
| static

Perform template argument deduction per [temp.deduct.call] for a single parameter / argument pair.

Definition at line 3832 of file SemaTemplateDeduction.cpp.

References AdjustFunctionParmAndArgTypesForDeduction(), DeduceFromInitializerList(), DeduceTemplateArgumentsByTypeMatch(), clang::Expr::getType(), and clang::Sema::TDK_Success.

Referenced by AdjustFunctionParmAndArgTypesForDeduction(), DeduceFromInitializerList(), and clang::Sema::DeduceTemplateArguments().

## ◆ diagnoseAutoDeductionFailure()

static bool diagnoseAutoDeductionFailure | ( | Sema & | S,
|  | Sema::TemplateDeductionResult | TDK,
|  | TemplateDeductionInfo & | Info,
|  | ArrayRef< SourceRange > | Ranges
| ) |  |
| static

Attempt to produce an informative diagostic explaining why auto deduction failed.

Returns
  `true` if diagnosed, `false` if not.

Definition at line 4464 of file SemaTemplateDeduction.cpp.

References clang::Sema::Diag(), clang::sema::TemplateDeductionInfo::FirstArg, clang::sema::TemplateDeductionInfo::getLocation(), clang::sema::TemplateDeductionInfo::SecondArg, and clang::Sema::TDK_Inconsistent.

## ◆ FinishTemplateArgumentDeduction() [1/2]

template<typename T >

static std::enable_if<IsPartialSpecialization<T>::value, Sema::TemplateDeductionResult>::type FinishTemplateArgumentDeduction | ( | Sema & | S,
|  | T * | Partial,
|  | bool | IsPartialOrdering,
|  | const TemplateArgumentList & | TemplateArgs,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced,
|  | TemplateDeductionInfo & | Info
| ) |  |
| static

Complete template argument deduction for a partial specialization.

Definition at line 2769 of file SemaTemplateDeduction.cpp.

References getAsDeclContextOrEnclosing(), and clang::Sema::Unevaluated.

Referenced by clang::Sema::DeduceTemplateArguments(), and isAtLeastAsSpecializedAs().

## ◆ FinishTemplateArgumentDeduction() [2/2]

static Sema::TemplateDeductionResult FinishTemplateArgumentDeduction | ( | Sema & | S,
|  | TemplateDecl * | Template,
|  | bool | PartialOrdering,
|  | const TemplateArgumentList & | TemplateArgs,
|  | SmallVectorImpl< DeducedTemplateArgument > & | Deduced,
|  | TemplateDeductionInfo & | Info
| ) |  |
| static

Complete template argument deduction for a class or variable template, when partial ordering against a partial specialization.

Definition at line 2855 of file SemaTemplateDeduction.cpp.

References getAsDeclContextOrEnclosing(), and clang::Sema::Unevaluated.

## ◆ getAsDeclContextOrEnclosing()

static DeclContext* getAsDeclContextOrEnclosing | ( | Decl * | D | ) |
| static

Definition at line 2730 of file SemaTemplateDeduction.cpp.

References clang::Decl::getDeclContext().

Referenced by FinishTemplateArgumentDeduction().

## ◆ getDeducedParameterFromExpr()

static NonTypeTemplateParmDecl* getDeducedParameterFromExpr | ( | TemplateDeductionInfo & | Info,
|  | Expr * | E
| ) |  |
| static

If the given expression is of a form that permits the deduction of a non-type template parameter, return the declaration of that non-type template parameter.

Definition at line 175 of file SemaTemplateDeduction.cpp.

References clang::sema::TemplateDeductionInfo::getDeducedDepth().

Referenced by DeduceFromInitializerList(), and DeduceTemplateArguments().

## ◆ getExpandedPackSize()

static Optional<unsigned> getExpandedPackSize | ( | NamedDecl * | Param | ) |
| static

If `Param` is an expanded parameter pack, get the number of expansions.

Definition at line 645 of file SemaTemplateDeduction.cpp.

## ◆ getFirstInnerIndex()

static unsigned getFirstInnerIndex | ( | FunctionTemplateDecl * | FTD | ) |
| static

Get the index of the first template parameter that was originally from the innermost template-parameter-list.

This is 0 except when we concatenate the template parameter lists of a class template and a constructor template when forming an implicit deduction guide.

Definition at line 1181 of file SemaTemplateDeduction.cpp.

References clang::CXXDeductionGuideDecl::getDeducedTemplate(), clang::FunctionTemplateDecl::getTemplatedDecl(), clang::TemplateDecl::getTemplateParameters(), and clang::TemplateParameterList::size().

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

## ◆ getPackIndexForParam()

static unsigned getPackIndexForParam | ( | Sema & | S,
|  | FunctionTemplateDecl * | FunctionTemplate,
|  | const MultiLevelTemplateArgumentList & | Args,
|  | unsigned | ParamIdx
| ) |  |
| static

Find the pack index for a particular parameter index in an instantiation of a function template with specific arguments.

Returns
  The pack index for whichever pack produced this parameter, or -1 if this was not produced by a parameter. Intended to be used as the ArgumentPackSubstitutionIndex for further substitutions.

Definition at line 3345 of file SemaTemplateDeduction.cpp.

References clang::Sema::getNumArgumentsInExpansion(), clang::FunctionTemplateDecl::getTemplatedDecl(), and clang::FunctionDecl::parameters().

## ◆ GetTypeOfFunction()

static QualType GetTypeOfFunction | ( | Sema & | S,
|  | const OverloadExpr::FindResult & | R,
|  | FunctionDecl * | Fn
| ) |  |
| static

Gets the type of a function for template-argument-deducton purposes when it's considered as part of an overload set.

Definition at line 3530 of file SemaTemplateDeduction.cpp.

References clang::Sema::Context, clang::Sema::DeduceReturnType(), clang::OverloadExpr::FindResult::Expression, clang::Expr::getExprLoc(), clang::Sema::getLangOpts(), clang::ASTContext::getMemberPointerType(), clang::ASTContext::getPointerType(), clang::FunctionDecl::getReturnType(), clang::ValueDecl::getType(), clang::ASTContext::getTypeDeclType(), clang::OverloadExpr::FindResult::HasFormOfMemberPointer, clang::OverloadExpr::FindResult::IsAddressOfOperand, and clang::Type::isUndeducedType().

Referenced by ResolveOverloadForDeduction().

## ◆ hasDeducibleTemplateParameters()

bool hasDeducibleTemplateParameters | ( | Sema & | S,
|  | FunctionTemplateDecl * | FunctionTemplate,
|  | QualType | T
| ) |  |
| static

Definition at line 5971 of file SemaTemplateDeduction.cpp.

References clang::Sema::Context, clang::TemplateParameterList::getDepth(), clang::TemplateDecl::getTemplateParameters(), clang::Type::isDependentType(), MarkUsedTemplateParameters(), and clang::TemplateParameterList::size().

Referenced by AdjustFunctionParmAndArgTypesForDeduction(), and clang::Sema::DeduceTemplateArguments().

## ◆ hasInconsistentOrSupersetQualifiersOf()

static bool hasInconsistentOrSupersetQualifiersOf | ( | QualType | ParamType,
|  | QualType | ArgType
| ) |  |
| static

Determine whether the parameter has qualifiers that the argument lacks.

Put another way, determine whether there is no way to add a deduced set of qualifiers to the ParamType that would result in its qualifiers matching those of the ArgType.

Definition at line 1124 of file SemaTemplateDeduction.cpp.

References clang::Qualifiers::getAddressSpace(), clang::Qualifiers::getCVRQualifiers(), clang::Qualifiers::getObjCGCAttr(), clang::Qualifiers::getObjCLifetime(), clang::QualType::getQualifiers(), clang::Qualifiers::hasAddressSpace(), clang::Qualifiers::hasObjCGCAttr(), and clang::Qualifiers::hasObjCLifetime().

## ◆ hasPackExpansionBeforeEnd()

static bool hasPackExpansionBeforeEnd | ( | ArrayRef< TemplateArgument > | Args | ) |
| static

Determine whether the given set of template arguments has a pack expansion that is not the last template argument.

Definition at line 2267 of file SemaTemplateDeduction.cpp.

References clang::TemplateArgument::Pack.

Referenced by DeduceTemplateArguments(), MarkUsedTemplateParameters(), and clang::Sema::MarkUsedTemplateParameters().

## ◆ hasSameExtendedValue()

static bool hasSameExtendedValue | ( | llvm::APSInt | X,
|  | llvm::APSInt | Y
| ) |  |
| static

Compare two APSInts, extending and switching the sign as necessary to compare their values regardless of underlying type.

Definition at line 115 of file SemaTemplateDeduction.cpp.

References DeduceTemplateArguments().

Referenced by DeduceTemplateArguments().

## ◆ hasTemplateArgumentForDeduction()

static bool hasTemplateArgumentForDeduction | ( | ArrayRef< TemplateArgument > & | Args,
|  | unsigned & | ArgIdx
| ) |  |
| static

Determine whether there is a template argument to be used for deduction.

This routine "expands" argument packs in-place, overriding its input parameters so that `Args`[ArgIdx] will be the available template argument.

Returns
  true if there is another template argument (which will be at `Args`[ArgIdx]), false otherwise.

Definition at line 2250 of file SemaTemplateDeduction.cpp.

References clang::TemplateArgument::getKind(), clang::TemplateArgument::Pack, and clang::TemplateArgument::pack_elements().

Referenced by DeduceTemplateArguments().

## ◆ isAtLeastAsSpecializedAs() [1/2]

static bool isAtLeastAsSpecializedAs | ( | Sema & | S,
|  | SourceLocation | Loc,
|  | FunctionTemplateDecl * | FT1,
|  | FunctionTemplateDecl * | FT2,
|  | TemplatePartialOrderingContext | TPOC,
|  | unsigned | NumCallArguments1
| ) |  |
| static

Determine whether the function template `FT1` is at least as specialized as `FT2`.

Definition at line 4862 of file SemaTemplateDeduction.cpp.

References AddImplicitObjectParameterType(), clang::Sema::Context, DeduceTemplateArguments(), DeduceTemplateArgumentsByTypeMatch(), clang::Type::getAs(), clang::TemplateParameterList::getDepth(), clang::FunctionType::getReturnType(), clang::FunctionTemplateDecl::getTemplatedDecl(), clang::TemplateDecl::getTemplateParameters(), clang::ValueDecl::getType(), clang::CXXMethodDecl::isStatic(), MarkUsedTemplateParameters(), clang::FunctionProtoType::param_type_begin(), clang::FunctionProtoType::param_type_end(), clang::TemplateParameterList::size(), clang::TDF_None, clang::TPOC_Call, clang::TPOC_Conversion, and clang::TPOC_Other.

Referenced by clang::Sema::getMoreSpecializedPartialSpecialization(), clang::Sema::getMoreSpecializedTemplate(), and clang::Sema::isMoreSpecializedThanPrimary().

## ◆ isAtLeastAsSpecializedAs() [2/2]

template<typename TemplateLikeDecl >

static bool isAtLeastAsSpecializedAs | ( | Sema & | S,
|  | QualType | T1,
|  | QualType | T2,
|  | TemplateLikeDecl * | P2,
|  | TemplateDeductionInfo & | Info
| ) |  |
| static

Determine whether one partial specialization, P1, is at least as specialized than another, P2.

Template Parameters

  TemplateLikeDecl | The kind of P2, which must be a TemplateDecl or {Class,Var}TemplatePartialSpecializationDecl.

Parameters

  T1 | The injected-class-name of P1 (faked for a variable template).
  T2 | The injected-class-name of P2 (faked for a variable template).

Definition at line 5213 of file SemaTemplateDeduction.cpp.

References DeduceTemplateArgumentsByTypeMatch(), FinishTemplateArgumentDeduction(), clang::TemplateArgumentList::OnStack, and clang::TDF_None.

## ◆ isForwardingReference()

static bool isForwardingReference | ( | QualType | Param,
|  | unsigned | FirstInnerIndex
| ) |  |
| static

Determine whether a type denotes a forwarding reference.

Definition at line 1189 of file SemaTemplateDeduction.cpp.

References clang::Type::getAs(), and clang::TemplateTypeParmType::getIndex().

Referenced by AdjustFunctionParmAndArgTypesForDeduction(), and DeduceTemplateArgumentsByTypeMatch().

## ◆ IsPossiblyOpaquelyQualifiedType()

static bool IsPossiblyOpaquelyQualifiedType | ( | QualType | T | ) |
| static

Determines whether the given type is an opaque type that might be more qualified when instantiated.

Definition at line 611 of file SemaTemplateDeduction.cpp.

References clang::Type::getTypeClass().

## ◆ isSameDeclaration()

static bool isSameDeclaration | ( | Decl * | X,
|  | Decl * | Y
| ) |  |
| static

Determine whether two declaration pointers refer to the same declaration.

Definition at line 200 of file SemaTemplateDeduction.cpp.

References clang::Decl::getCanonicalDecl().

Referenced by DeduceTemplateArguments().

## ◆ isSameTemplate()

static bool isSameTemplate | ( | TemplateDecl * | T1,
|  | TemplateDecl * | T2
| ) |  |
| static

Determine if the two templates are equivalent.

Definition at line 5095 of file SemaTemplateDeduction.cpp.

References clang::Decl::getCanonicalDecl().

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

## ◆ isSameTemplateArg()

static bool isSameTemplateArg | ( | ASTContext & | Context,
|  | TemplateArgument | X,
|  | const TemplateArgument & | Y,
|  | bool | PackExpansionMatchesPack = `false`
| ) |  |
| static

Determine whether two template arguments are the same.

Definition at line 2381 of file SemaTemplateDeduction.cpp.

## ◆ isSimpleTemplateIdType()

static bool isSimpleTemplateIdType | ( | QualType | T | ) |
| static

Determine whether the given type T is a simple-template-id type.

Definition at line 2983 of file SemaTemplateDeduction.cpp.

References clang::Type::getAs().

Referenced by AdjustFunctionParmAndArgTypesForDeduction().

## ◆ isVariadicFunctionTemplate()

static bool isVariadicFunctionTemplate | ( | FunctionTemplateDecl * | FunTmpl | ) |
| static

Determine whether this a function template whose parameter-type-list ends with a function parameter pack.

Definition at line 5013 of file SemaTemplateDeduction.cpp.

References clang::FunctionDecl::getNumParams(), clang::FunctionDecl::getParamDecl(), clang::FunctionTemplateDecl::getTemplatedDecl(), clang::VarDecl::isParameterPack(), and clang::Last.

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

## ◆ makeTemplateParameter()

static TemplateParameter makeTemplateParameter | ( | Decl * | D | ) |
| static

Helper function to build a TemplateParameter when we don't know its type statically.

Definition at line 635 of file SemaTemplateDeduction.cpp.

## ◆ MarkUsedTemplateParameters() [1/5]

static void MarkUsedTemplateParameters | ( | ASTContext & | Ctx,
|  | const TemplateArgument & | TemplateArg,
|  | bool | OnlyDeduced,
|  | unsigned | Depth,
|  | llvm::SmallBitVector & | Used
| ) |  |
| static

Mark the template parameters that are used by this template argument.

Definition at line 5875 of file SemaTemplateDeduction.cpp.

References clang::TemplateArgument::Declaration, Depth, clang::TemplateArgument::Expression, clang::TemplateArgument::getAsExpr(), clang::TemplateArgument::getAsTemplateOrTemplatePattern(), clang::TemplateArgument::getAsType(), clang::TemplateArgument::getKind(), clang::TemplateArgument::getNullPtrType(), clang::TemplateArgument::Integral, clang::TemplateArgument::Null, clang::TemplateArgument::NullPtr, P, clang::TemplateArgument::Pack, clang::TemplateArgument::pack_elements(), clang::TemplateArgument::Template, clang::TemplateArgument::TemplateExpansion, clang::TemplateArgument::Type, and Used.

Referenced by hasDeducibleTemplateParameters(), isAtLeastAsSpecializedAs(), clang::Sema::MarkDeducedTemplateParameters(), MarkUsedTemplateParameters(), and clang::Sema::MarkUsedTemplateParameters().

## ◆ MarkUsedTemplateParameters() [2/5]

static void MarkUsedTemplateParameters | ( | ASTContext & | Ctx,
|  | QualType | T,
|  | bool | OnlyDeduced,
|  | unsigned | Depth,
|  | llvm::SmallBitVector & | Used
| ) |  |
| static

Mark the template parameters that are used by the given type.

Definition at line 5599 of file SemaTemplateDeduction.cpp.

References clang::Auto, Depth, clang::DependentAddressSpaceType::getAddrSpaceExpr(), clang::TemplateSpecializationType::getArg(), clang::DependentTemplateSpecializationType::getArg(), clang::SubstTemplateTypeParmPackType::getArgumentPack(), clang::Type::getAs(), clang::ASTContext::getCanonicalType(), clang::MemberPointerType::getClass(), clang::TemplateTypeParmType::getDepth(), clang::DependentSizedExtVectorType::getElementType(), clang::TemplateTypeParmType::getIndex(), clang::FunctionProtoType::getNoexceptExpr(), clang::TemplateSpecializationType::getNumArgs(), clang::DependentTemplateSpecializationType::getNumArgs(), clang::FunctionProtoType::getNumParams(), clang::FunctionProtoType::getParamType(), clang::MemberPointerType::getPointeeType(), clang::DependentAddressSpaceType::getPointeeType(), clang::DependentTemplateSpecializationType::getQualifier(), clang::SubstTemplateTypeParmPackType::getReplacedParameter(), clang::FunctionType::getReturnType(), clang::DependentSizedExtVectorType::getSizeExpr(), clang::TemplateSpecializationType::getTemplateName(), clang::Type::getTypeClass(), clang::QualType::getTypePtr(), getUnderlyingType(), hasPackExpansionBeforeEnd(), clang::Type::isDependentType(), clang::QualType::isNull(), MarkUsedTemplateParameters(), clang::TemplateSpecializationType::template_arguments(), and Used.

## ◆ MarkUsedTemplateParameters() [3/5]

static void MarkUsedTemplateParameters | ( | ASTContext & | Ctx,
|  | const Expr * | E,
|  | bool | OnlyDeduced,
|  | unsigned | Depth,
|  | llvm::SmallBitVector & | Used
| ) |  |
| static

Mark the template parameters that are used by the given expression.

Definition at line 5507 of file SemaTemplateDeduction.cpp.

References Depth, clang::DeclRefExpr::getDecl(), clang::TemplateParmPosition::getDepth(), clang::TemplateParmPosition::getIndex(), clang::ASTContext::getLangOpts(), clang::ValueDecl::getType(), MarkUsedTemplateParameters(), and Used.

## ◆ MarkUsedTemplateParameters() [4/5]

static void MarkUsedTemplateParameters | ( | ASTContext & | Ctx,
|  | NestedNameSpecifier * | NNS,
|  | bool | OnlyDeduced,
|  | unsigned | Depth,
|  | llvm::SmallBitVector & | Used
| ) |  |
| static

Mark the template parameters that are used by the given nested name specifier.

Definition at line 5557 of file SemaTemplateDeduction.cpp.

References Depth, clang::NestedNameSpecifier::getAsType(), clang::NestedNameSpecifier::getPrefix(), MarkUsedTemplateParameters(), and Used.

## ◆ MarkUsedTemplateParameters() [5/5]

static void MarkUsedTemplateParameters | ( | ASTContext & | Ctx,
|  | TemplateName | Name,
|  | bool | OnlyDeduced,
|  | unsigned | Depth,
|  | llvm::SmallBitVector & | Used
| ) |  |
| static

Mark the template parameters that are used by the given template name.

Definition at line 5574 of file SemaTemplateDeduction.cpp.

## ◆ ResolveOverloadForDeduction()

static QualType ResolveOverloadForDeduction | ( | Sema & | S,
|  | TemplateParameterList * | TemplateParams,
|  | Expr * | Arg,
|  | QualType | ParamType,
|  | bool | ParamWasReference
| ) |  |
| static

Apply the deduction rules for overload sets.

Returns
  the null type if this argument should be treated as an undeduced context

Definition at line 3557 of file SemaTemplateDeduction.cpp.

References clang::Sema::Context, clang::OverloadExpr::copyTemplateArgumentsInto(), clang::OverloadExpr::decls_begin(), clang::OverloadExpr::decls_end(), clang::Sema::DeduceTemplateArguments(), DeduceTemplateArgumentsByTypeMatch(), clang::OverloadExpr::FindResult::Expression, clang::OverloadExpr::find(), clang::OverloadExpr::getNameLoc(), clang::ASTContext::getPointerType(), GetTypeOfFunction(), clang::NamedDecl::getUnderlyingDecl(), clang::OverloadExpr::hasExplicitTemplateArgs(), clang::OverloadExpr::FindResult::IsAddressOfOperand, clang::Type::isFunctionPointerType(), clang::Type::isFunctionType(), clang::Type::isMemberFunctionPointerType(), clang::QualType::isNull(), clang::Type::isPointerType(), clang::Sema::resolveAddressOfSingleOverloadCandidate(), clang::Sema::ResolveSingleFunctionTemplateSpecialization(), clang::TemplateParameterList::size(), clang::TDF_IgnoreQualifiers, and clang::TDF_ParamWithReferenceType.

Referenced by AdjustFunctionParmAndArgTypesForDeduction().