clang 20.0.0git
Classes | Namespaces | Macros | Enumerations | Functions
SemaTemplateDeduction.cpp File Reference
#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/TypeOrdering.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/EnterExpressionEvaluationContext.h"
#include "clang/Sema/Ownership.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/Template.h"
#include "clang/Sema/TemplateDeduction.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/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 <optional>
#include <tuple>
#include <type_traits>
#include <utility>
#include "clang/AST/TypeNodes.inc"

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

namespace  clang
 The JSON file list parser is used to communicate input to InstallAPI.
 

Macros

#define NON_CANONICAL_TYPE(Class, Base)    case Type::Class: llvm_unreachable("deducing non-canonical type: " #Class);
 
#define TYPE(Class, Base)
 
#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...
 
enum class  PackFold { ParameterToArgument , ArgumentToParameter }
 

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.
 
static TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch (Sema &S, TemplateParameterList *TemplateParams, QualType P, QualType A, 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]).
 
static TemplateDeductionResult DeduceTemplateArguments (Sema &S, TemplateParameterList *TemplateParams, ArrayRef< TemplateArgument > Ps, ArrayRef< TemplateArgument > As, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, bool NumberOfArgumentsMustMatch, PackFold PackFold=PackFold::ParameterToArgument)
 
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.
 
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.
 
static const NonTypeTemplateParmDeclgetDeducedParameterFromExpr (const Expr *E, unsigned Depth)
 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.
 
static const NonTypeTemplateParmDeclgetDeducedParameterFromExpr (TemplateDeductionInfo &Info, Expr *E)
 
static bool isSameDeclaration (Decl *X, Decl *Y)
 Determine whether two declaration pointers refer to the same declaration.
 
static DeducedTemplateArgument checkDeducedTemplateArguments (ASTContext &Context, const DeducedTemplateArgument &X, const DeducedTemplateArgument &Y, bool AggregateCandidateDeduction=false)
 Verify that the given, deduced template arguments are compatible.
 
static TemplateDeductionResult DeduceNonTypeTemplateArgument (Sema &S, TemplateParameterList *TemplateParams, const 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.
 
static TemplateDeductionResult DeduceNonTypeTemplateArgument (Sema &S, TemplateParameterList *TemplateParams, const 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.
 
static TemplateDeductionResult DeduceNullPtrTemplateArgument (Sema &S, TemplateParameterList *TemplateParams, const 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.
 
static TemplateDeductionResult DeduceNonTypeTemplateArgument (Sema &S, TemplateParameterList *TemplateParams, const 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.
 
static TemplateDeductionResult DeduceNonTypeTemplateArgument (Sema &S, TemplateParameterList *TemplateParams, const 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.
 
static NamedDeclgetTemplateParameterWithDefault (Sema &S, NamedDecl *A, TemplateArgument Default)
 Create a shallow copy of a given template parameter declaration, with empty source locations and using the given TemplateArgument as it's default argument.
 
static TemplateDeductionResult DeduceTemplateArguments (Sema &S, TemplateParameterList *TemplateParams, TemplateName Param, TemplateName Arg, TemplateDeductionInfo &Info, ArrayRef< TemplateArgument > DefaultArguments, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
 
static const TemplateSpecializationTypegetLastTemplateSpecType (QualType QT)
 Deduce the template arguments by comparing the template parameter type (which is a template-id) with the template argument type.
 
static TemplateDeductionResult DeduceTemplateSpecArguments (Sema &S, TemplateParameterList *TemplateParams, const QualType P, QualType A, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
 
static bool IsPossiblyOpaquelyQualifiedTypeInternal (const Type *T)
 
static bool IsPossiblyOpaquelyQualifiedType (QualType T)
 Determines whether the given type is an opaque type that might be more qualified when instantiated.
 
static TemplateParameter makeTemplateParameter (Decl *D)
 Helper function to build a TemplateParameter when we don't know its type statically.
 
static 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).
 
static bool hasInconsistentOrSupersetQualifiersOf (QualType ParamType, QualType ArgType)
 Determine whether the parameter has qualifiers that the argument lacks.
 
static unsigned getFirstInnerIndex (FunctionTemplateDecl *FTD)
 Get the index of the first template parameter that was originally from the innermost template-parameter-list.
 
static bool isForwardingReference (QualType Param, unsigned FirstInnerIndex)
 Determine whether a type denotes a forwarding reference.
 
static TemplateDeductionResult DeduceTemplateBases (Sema &S, const CXXRecordDecl *RD, TemplateParameterList *TemplateParams, QualType P, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
 Attempt to deduce the template arguments by checking the base types according to (C++20 [temp.deduct.call] p4b3.
 
static TemplateDeductionResult DeduceTemplateArguments (Sema &S, TemplateParameterList *TemplateParams, const TemplateArgument &P, TemplateArgument A, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced)
 
static bool hasTemplateArgumentForDeduction (ArrayRef< TemplateArgument > &Args, unsigned &ArgIdx)
 Determine whether there is a template argument to be used for deduction.
 
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.
 
static bool isSameTemplateArg (ASTContext &Context, TemplateArgument X, const TemplateArgument &Y, bool PartialOrdering, bool PackExpansionMatchesPack=false)
 Determine whether two template arguments are the same.
 
static bool ConvertDeducedTemplateArgument (Sema &S, NamedDecl *Param, DeducedTemplateArgument Arg, NamedDecl *Template, TemplateDeductionInfo &Info, bool IsDeduced, SmallVectorImpl< TemplateArgument > &SugaredOutput, SmallVectorImpl< TemplateArgument > &CanonicalOutput)
 Convert the given deduced template argument and add it to the set of fully-converted template arguments.
 
template<typename TemplateDeclT >
static TemplateDeductionResult ConvertDeducedTemplateArguments (Sema &S, TemplateDeclT *Template, bool IsDeduced, SmallVectorImpl< DeducedTemplateArgument > &Deduced, TemplateDeductionInfo &Info, SmallVectorImpl< TemplateArgument > &SugaredBuilder, SmallVectorImpl< TemplateArgument > &CanonicalBuilder, LocalInstantiationScope *CurrentInstantiationScope=nullptr, unsigned NumAlreadyConverted=0, bool PartialOverloading=false)
 
static DeclContextgetAsDeclContextOrEnclosing (Decl *D)
 
template<typename TemplateDeclT >
static bool DeducedArgsNeedReplacement (TemplateDeclT *Template)
 
template<>
bool DeducedArgsNeedReplacement< VarTemplatePartialSpecializationDecl > (VarTemplatePartialSpecializationDecl *Spec)
 
template<>
bool DeducedArgsNeedReplacement< ClassTemplatePartialSpecializationDecl > (ClassTemplatePartialSpecializationDecl *Spec)
 
template<typename TemplateDeclT >
static TemplateDeductionResult CheckDeducedArgumentConstraints (Sema &S, TemplateDeclT *Template, ArrayRef< TemplateArgument > SugaredDeducedArgs, ArrayRef< TemplateArgument > CanonicalDeducedArgs, TemplateDeductionInfo &Info)
 
template<typename T >
static std::enable_if_t< IsPartialSpecialization< T >::value, TemplateDeductionResultFinishTemplateArgumentDeduction (Sema &S, T *Partial, bool IsPartialOrdering, ArrayRef< TemplateArgument > TemplateArgs, SmallVectorImpl< DeducedTemplateArgument > &Deduced, TemplateDeductionInfo &Info)
 Complete template argument deduction for a partial specialization.
 
static TemplateDeductionResult FinishTemplateArgumentDeduction (Sema &S, TemplateDecl *Template, bool PartialOrdering, ArrayRef< TemplateArgument > TemplateArgs, SmallVectorImpl< DeducedTemplateArgument > &Deduced, TemplateDeductionInfo &Info)
 Complete template argument deduction for a class or variable template, when partial ordering against a partial specialization.
 
static TemplateDeductionResult FinishTemplateArgumentDeduction (Sema &S, TemplateDecl *TD, SmallVectorImpl< DeducedTemplateArgument > &Deduced, TemplateDeductionInfo &Info)
 Complete template argument deduction for DeduceTemplateArgumentsFromType.
 
template<typename T >
static std::enable_if_t< IsPartialSpecialization< T >::value, TemplateDeductionResultDeduceTemplateArguments (Sema &S, T *Partial, ArrayRef< TemplateArgument > TemplateArgs, TemplateDeductionInfo &Info)
 Perform template argument deduction to determine whether the given template arguments match the given class or variable template partial specialization per C++ [temp.class.spec.match].
 
static bool isSimpleTemplateIdType (QualType T)
 Determine whether the given type T is a simple-template-id type.
 
static 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.
 
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.
 
static TemplateDeductionResult instantiateExplicitSpecifierDeferred (Sema &S, FunctionDecl *Specialization, const MultiLevelTemplateArgumentList &SubstArgs, TemplateDeductionInfo &Info, FunctionTemplateDecl *FunctionTemplate, ArrayRef< TemplateArgument > DeducedArgs)
 
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.
 
static QualType ResolveOverloadForDeduction (Sema &S, TemplateParameterList *TemplateParams, Expr *Arg, QualType ParamType, bool ParamWasReference, TemplateSpecCandidateSet *FailedTSC=nullptr)
 Apply the deduction rules for overload sets.
 
static bool AdjustFunctionParmAndArgTypesForDeduction (Sema &S, TemplateParameterList *TemplateParams, unsigned FirstInnerIndex, QualType &ParamType, QualType &ArgType, Expr::Classification ArgClassification, Expr *Arg, unsigned &TDF, TemplateSpecCandidateSet *FailedTSC=nullptr)
 Perform the adjustments to the parameter and argument types described in C++ [temp.deduct.call].
 
static bool hasDeducibleTemplateParameters (Sema &S, FunctionTemplateDecl *FunctionTemplate, QualType T)
 
static TemplateDeductionResult DeduceTemplateArgumentsFromCallArgument (Sema &S, TemplateParameterList *TemplateParams, unsigned FirstInnerIndex, QualType ParamType, QualType ArgType, Expr::Classification ArgClassification, Expr *Arg, TemplateDeductionInfo &Info, SmallVectorImpl< DeducedTemplateArgument > &Deduced, SmallVectorImpl< Sema::OriginalCallArg > &OriginalCallArgs, bool DecomposedParam, unsigned ArgIdx, unsigned TDF, TemplateSpecCandidateSet *FailedTSC)
 Perform template argument deduction per [temp.deduct.call] for a single parameter / argument pair.
 
static 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.
 
static bool CheckDeducedPlaceholderConstraints (Sema &S, const AutoType &Type, AutoTypeLoc TypeLoc, QualType Deduced)
 
static QualType GetImplicitObjectParameterType (ASTContext &Context, const CXXMethodDecl *Method, QualType RawType, bool IsOtherRvr)
 
static bool isAtLeastAsSpecializedAs (Sema &S, SourceLocation Loc, const FunctionTemplateDecl *FT1, const FunctionTemplateDecl *FT2, TemplatePartialOrderingContext TPOC, bool Reversed, const SmallVector< QualType > &Args1, const SmallVector< QualType > &Args2)
 Determine whether the function template FT1 is at least as specialized as FT2.
 
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.
 
template<typename TemplateLikeDecl , typename PrimaryDel >
static TemplateLikeDecl * getMoreSpecialized (Sema &S, QualType T1, QualType T2, TemplateLikeDecl *P1, PrimaryDel *P2, TemplateDeductionInfo &Info)
 Returns the more specialized template specialization between T1/P1 and T2/P2.
 
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.
 
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.
 
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.
 

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 
)

Enumeration Type Documentation

◆ PackFold

enum class PackFold
strong
Enumerator
ParameterToArgument 
ArgumentToParameter 

Definition at line 143 of file SemaTemplateDeduction.cpp.

Function Documentation

◆ AdjustFunctionParmAndArgTypesForDeduction()

static bool AdjustFunctionParmAndArgTypesForDeduction ( Sema S,
TemplateParameterList TemplateParams,
unsigned  FirstInnerIndex,
QualType ParamType,
QualType ArgType,
Expr::Classification  ArgClassification,
Expr Arg,
unsigned TDF,
TemplateSpecCandidateSet FailedTSC = nullptr 
)
static

◆ CheckDeducedArgumentConstraints()

template<typename TemplateDeclT >
static TemplateDeductionResult CheckDeducedArgumentConstraints ( Sema S,
TemplateDeclT *  Template,
ArrayRef< TemplateArgument SugaredDeducedArgs,
ArrayRef< TemplateArgument CanonicalDeducedArgs,
TemplateDeductionInfo Info 
)
static

◆ CheckDeducedPlaceholderConstraints()

static bool CheckDeducedPlaceholderConstraints ( Sema S,
const AutoType Type,
AutoTypeLoc  TypeLoc,
QualType  Deduced 
)
static

◆ checkDeducedTemplateArguments()

static DeducedTemplateArgument checkDeducedTemplateArguments ( ASTContext Context,
const DeducedTemplateArgument X,
const DeducedTemplateArgument Y,
bool  AggregateCandidateDeduction = false 
)
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 216 of file SemaTemplateDeduction.cpp.

References checkDeducedTemplateArguments(), clang::TemplateArgument::CreatePackCopy(), clang::TemplateArgument::Declaration, clang::TemplateArgument::Expression, clang::TemplateArgument::getAsDecl(), clang::TemplateArgument::getAsExpr(), clang::TemplateArgument::getAsIntegral(), clang::TemplateArgument::getAsTemplate(), clang::TemplateArgument::getAsTemplateOrTemplatePattern(), clang::TemplateArgument::getAsType(), clang::ASTContext::getCommonSugaredType(), clang::TemplateArgument::getKind(), clang::TemplateArgument::getNonTypeTemplateArgumentType(), clang::TemplateArgument::getNullPtrType(), clang::Expr::getType(), hasSameExtendedValue(), clang::ASTContext::hasSameTemplateName(), clang::ASTContext::hasSameType(), clang::TemplateArgument::Integral, clang::TemplateArgument::isNull(), clang::QualType::isNull(), isSameDeclaration(), clang::TemplateArgument::Null, clang::TemplateArgument::NullPtr, clang::TemplateArgument::Pack, clang::TemplateArgument::pack_begin(), clang::TemplateArgument::pack_end(), clang::TemplateArgument::pack_size(), clang::Stmt::Profile(), clang::TemplateArgument::StructuralValue, clang::TemplateArgument::Template, clang::TemplateArgument::TemplateExpansion, clang::TemplateArgument::Type, clang::DeducedTemplateArgument::wasDeducedFromArrayBound(), and X.

Referenced by checkDeducedTemplateArguments(), DeduceNonTypeTemplateArgument(), DeduceTemplateArguments(), and DeduceTemplateArgumentsByTypeMatch().

◆ CheckOriginalCallArgDeduction()

static 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 3618 of file SemaTemplateDeduction.cpp.

References clang::Sema::OriginalCallArg::ArgIdx, clang::sema::TemplateDeductionInfo::CallArgIndex, clang::Qualifiers::compatiblyIncludes(), clang::Sema::Context, clang::Sema::OriginalCallArg::DecomposedParam, clang::DeducedMismatch, clang::DeducedMismatchNested, clang::sema::TemplateDeductionInfo::FirstArg, clang::Type::getAs(), clang::Sema::getLangOpts(), clang::sema::TemplateDeductionInfo::getLocation(), clang::Qualifiers::getObjCLifetime(), clang::Type::getPointeeType(), clang::ASTContext::getQualifiedType(), clang::QualType::getQualifiers(), clang::QualType::getUnqualifiedType(), clang::Qualifiers::hasConst(), clang::ASTContext::hasSameUnqualifiedType(), clang::Type::isAnyPointerType(), clang::Sema::IsDerivedFrom(), clang::Sema::IsFunctionConversion(), clang::Type::isFunctionType(), clang::Type::isMemberPointerType(), clang::Sema::IsQualificationConversion(), clang::Type::isRecordType(), isSimpleTemplateIdType(), clang::Qualifiers::OCL_ExplicitNone, clang::Qualifiers::OCL_None, clang::Qualifiers::OCL_Strong, clang::Sema::OriginalCallArg::OriginalArgType, clang::Sema::OriginalCallArg::OriginalParamType, clang::sema::TemplateDeductionInfo::SecondArg, clang::Qualifiers::setObjCLifetime(), and clang::Success.

Referenced by clang::Sema::DeduceAutoType(), and clang::Sema::FinishTemplateArgumentDeduction().

◆ ConvertDeducedTemplateArgument()

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

◆ ConvertDeducedTemplateArguments()

template<typename TemplateDeclT >
static TemplateDeductionResult ConvertDeducedTemplateArguments ( Sema S,
TemplateDeclT *  Template,
bool  IsDeduced,
SmallVectorImpl< DeducedTemplateArgument > &  Deduced,
TemplateDeductionInfo Info,
SmallVectorImpl< TemplateArgument > &  SugaredBuilder,
SmallVectorImpl< TemplateArgument > &  CanonicalBuilder,
LocalInstantiationScope CurrentInstantiationScope = nullptr,
unsigned  NumAlreadyConverted = 0,
bool  PartialOverloading = false 
)
static

◆ DeducedArgsNeedReplacement()

template<typename TemplateDeclT >
static bool DeducedArgsNeedReplacement ( TemplateDeclT *  Template)
static

Definition at line 3055 of file SemaTemplateDeduction.cpp.

Referenced by CheckDeducedArgumentConstraints().

◆ DeducedArgsNeedReplacement< ClassTemplatePartialSpecializationDecl >()

◆ DeducedArgsNeedReplacement< VarTemplatePartialSpecializationDecl >()

◆ DeduceFromInitializerList()

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

◆ DeduceNonTypeTemplateArgument() [1/4]

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

◆ DeduceNonTypeTemplateArgument() [2/4]

static TemplateDeductionResult DeduceNonTypeTemplateArgument ( Sema S,
TemplateParameterList TemplateParams,
const 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 453 of file SemaTemplateDeduction.cpp.

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

◆ DeduceNonTypeTemplateArgument() [3/4]

static TemplateDeductionResult DeduceNonTypeTemplateArgument ( Sema S,
TemplateParameterList TemplateParams,
const 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 488 of file SemaTemplateDeduction.cpp.

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

◆ DeduceNonTypeTemplateArgument() [4/4]

static TemplateDeductionResult DeduceNonTypeTemplateArgument ( Sema S,
TemplateParameterList TemplateParams,
const 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 502 of file SemaTemplateDeduction.cpp.

References D, DeduceNonTypeTemplateArgument(), and clang::T.

◆ DeduceNullPtrTemplateArgument()

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

◆ DeduceTemplateArguments() [1/5]

template<typename T >
static std::enable_if_t< IsPartialSpecialization< T >::value, TemplateDeductionResult > DeduceTemplateArguments ( Sema S,
T *  Partial,
ArrayRef< TemplateArgument TemplateArgs,
TemplateDeductionInfo Info 
)
static

Perform template argument deduction to determine whether the given template arguments match the given class or variable template partial specialization per C++ [temp.class.spec.match].

Definition at line 3296 of file SemaTemplateDeduction.cpp.

References DeduceTemplateArguments(), clang::sema::TemplateDeductionInfo::getLocation(), clang::Sema::SFINAETrap::hasErrorOccurred(), clang::InstantiationDepth, clang::Invalid, clang::Sema::InstantiatingTemplate::isInvalid(), clang::Result, clang::Sema::runWithSufficientStackSpace(), clang::SubstitutionFailure, clang::Success, clang::Unevaluated, and clang::Sema::Unevaluated.

◆ DeduceTemplateArguments() [2/5]

static TemplateDeductionResult DeduceTemplateArguments ( Sema S,
TemplateParameterList TemplateParams,
ArrayRef< TemplateArgument Ps,
ArrayRef< TemplateArgument As,
TemplateDeductionInfo Info,
SmallVectorImpl< DeducedTemplateArgument > &  Deduced,
bool  NumberOfArgumentsMustMatch,
PackFold  PackFold = PackFold::ParameterToArgument 
)
static

◆ DeduceTemplateArguments() [3/5]

static 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
SThe semantic analysis object within which we are deducing
TemplateParamsThe template parameters that we are deducing
ParamsThe list of parameter types
NumParamsThe number of types in Params
ArgsThe list of argument types
NumArgsThe number of types in Args
Infoinformation about the template argument deduction itself
Deducedthe deduced template arguments
TDFbitwise OR of the TemplateDeductionFlags bits that describe how template argument deduction is performed.
PartialOrderingIf 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 1193 of file SemaTemplateDeduction.cpp.

References DeduceTemplateArgumentsByTypeMatch(), clang::PackExpansionType::getNumExpansions(), clang::PackExpansionType::getPattern(), clang::QualType::getUnqualifiedType(), and clang::PartialOrdering.

◆ DeduceTemplateArguments() [4/5]

static TemplateDeductionResult DeduceTemplateArguments ( Sema S,
TemplateParameterList TemplateParams,
const TemplateArgument P,
TemplateArgument  A,
TemplateDeductionInfo Info,
SmallVectorImpl< DeducedTemplateArgument > &  Deduced 
)
static

◆ DeduceTemplateArguments() [5/5]

static TemplateDeductionResult DeduceTemplateArguments ( Sema S,
TemplateParameterList TemplateParams,
TemplateName  Param,
TemplateName  Arg,
TemplateDeductionInfo Info,
ArrayRef< TemplateArgument DefaultArguments,
SmallVectorImpl< DeducedTemplateArgument > &  Deduced 
)
static

◆ DeduceTemplateArgumentsByTypeMatch()

static TemplateDeductionResult DeduceTemplateArgumentsByTypeMatch ( Sema S,
TemplateParameterList TemplateParams,
QualType  P,
QualType  A,
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
Sthe semantic analysis object within which we are deducing
TemplateParamsthe template parameters that we are deducing
Pthe parameter type
Athe argument type
Infoinformation about the template argument deduction itself
Deducedthe deduced template arguments
TDFbitwise OR of the TemplateDeductionFlags bits that describe how template argument deduction is performed.
PartialOrderingWhether 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 1521 of file SemaTemplateDeduction.cpp.

References clang::Sema::adjustMemberFunctionCC(), clang::ASTContext::BoolTy, checkDeducedTemplateArguments(), clang::Qualifiers::compatiblyIncludes(), clang::Sema::Context, clang::CT_Can, clang::CT_Cannot, clang::CT_Dependent, DeduceNonTypeTemplateArgument(), DeduceTemplateArguments(), DeduceTemplateArgumentsByTypeMatch(), DeduceTemplateBases(), DeduceTemplateSpecArguments(), clang::sema::TemplateDeductionInfo::FirstArg, clang::QualType::getAddressSpace(), clang::Type::getAs(), clang::ASTContext::getAsArrayType(), clang::ASTContext::getAsConstantArrayType(), clang::Type::getAsCXXRecordDecl(), clang::ASTContext::getAsDependentSizedArrayType(), clang::ASTContext::getAsIncompleteArrayType(), clang::QualType::getCanonicalType(), clang::Type::getCanonicalTypeInternal(), clang::DependentSizedMatrixType::getColumnExpr(), clang::Qualifiers::getCVRQualifiers(), clang::QualType::getCVRQualifiers(), clang::sema::TemplateDeductionInfo::getDeducedDepth(), getDeducedParameterFromExpr(), clang::NonTypeTemplateParmDecl::getDepth(), clang::MatrixType::getElementType(), clang::Expr::getIntegerConstantExpr(), clang::Sema::getLangOpts(), clang::sema::TemplateDeductionInfo::getLocation(), clang::ConstantMatrixType::getNumColumns(), clang::ConstantMatrixType::getNumRows(), clang::TemplateParameterList::getParam(), clang::Type::getPointeeType(), clang::PointerType::getPointeeType(), clang::ReferenceType::getPointeeType(), clang::ASTContext::getQualifiedType(), clang::QualType::getQualifiers(), clang::DependentSizedMatrixType::getRowExpr(), clang::PackIndexingType::getSelectedType(), clang::ASTContext::getSizeType(), clang::ASTContext::getTypeSize(), clang::ASTContext::getUnqualifiedArrayType(), clang::Qualifiers::hasAddressSpace(), hasInconsistentOrSupersetQualifiersOf(), clang::Qualifiers::hasNonTrivialObjCLifetime(), clang::Qualifiers::hasObjCGCAttr(), clang::Qualifiers::hasObjCLifetime(), clang::ASTContext::hasSameType(), clang::ASTContext::hasSameUnqualifiedType(), clang::PackIndexingType::hasSelectedType(), clang::IncompletePack, clang::Inconsistent, clang::ASTContext::IntTy, clang::Invalid, clang::Type::isArrayType(), clang::Sema::isCompleteType(), clang::Type::isDependentType(), isForwardingReference(), clang::Type::isFunctionType(), clang::Decl::isInvalidDecl(), clang::Type::isLValueReferenceType(), clang::Type::isObjCLifetimeType(), clang::Type::isPlaceholderType(), IsPossiblyOpaquelyQualifiedType(), clang::Type::isRecordType(), clang::Sema::isSameOrCompatibleFunctionType(), clang::Qualifiers::isStrictSupersetOf(), clang::isTargetAddressSpace(), clang::NonDeducedMismatch, clang::Qualifiers::OCL_ExplicitNone, clang::Qualifiers::OCL_Strong, clang::ASTContext::OverloadTy, P, clang::sema::TemplateDeductionInfo::Param, clang::PartialOrdering, clang::Qualifiers::removeAddressSpace(), clang::ASTContext::removeAddrSpaceQualType(), clang::Qualifiers::removeCVRQualifiers(), clang::Qualifiers::removeObjCGCAttr(), clang::Qualifiers::removeObjCLifetime(), clang::Result, clang::sema::TemplateDeductionInfo::SecondArg, clang::Qualifiers::setCVRQualifiers(), clang::Qualifiers::setObjCLifetime(), clang::Success, clang::TDF_AllowCompatibleFunctionType, clang::TDF_ArgWithReferenceType, clang::TDF_DerivedClass, clang::TDF_IgnoreQualifiers, clang::TDF_ParamWithReferenceType, clang::TDF_SkipNonDependent, clang::TDF_TopLevelParameterTypeList, clang::toTargetAddressSpace(), clang::Underqualified, clang::ASTContext::UnsignedIntTy, and clang::Qualifiers::withoutObjCLifetime().

Referenced by DeduceNonTypeTemplateArgument(), clang::Sema::DeduceTemplateArguments(), DeduceTemplateArguments(), DeduceTemplateArgumentsByTypeMatch(), DeduceTemplateArgumentsFromCallArgument(), isAtLeastAsSpecializedAs(), and ResolveOverloadForDeduction().

◆ DeduceTemplateArgumentsFromCallArgument()

static TemplateDeductionResult DeduceTemplateArgumentsFromCallArgument ( Sema S,
TemplateParameterList TemplateParams,
unsigned  FirstInnerIndex,
QualType  ParamType,
QualType  ArgType,
Expr::Classification  ArgClassification,
Expr Arg,
TemplateDeductionInfo Info,
SmallVectorImpl< DeducedTemplateArgument > &  Deduced,
SmallVectorImpl< Sema::OriginalCallArg > &  OriginalCallArgs,
bool  DecomposedParam,
unsigned  ArgIdx,
unsigned  TDF,
TemplateSpecCandidateSet FailedTSC = nullptr 
)
static

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

Definition at line 4322 of file SemaTemplateDeduction.cpp.

References AdjustFunctionParmAndArgTypesForDeduction(), DeduceFromInitializerList(), DeduceTemplateArgumentsByTypeMatch(), and clang::Success.

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

◆ DeduceTemplateBases()

static TemplateDeductionResult DeduceTemplateBases ( Sema S,
const CXXRecordDecl RD,
TemplateParameterList TemplateParams,
QualType  P,
TemplateDeductionInfo Info,
SmallVectorImpl< DeducedTemplateArgument > &  Deduced 
)
static

Attempt to deduce the template arguments by checking the base types according to (C++20 [temp.deduct.call] p4b3.

Parameters
Sthe semantic analysis object within which we are deducing.
RDthe top level record object we are deducing against.
TemplateParamsthe template parameters that we are deducing.
Pthe template specialization parameter type.
Infoinformation about the template argument deduction itself.
Deducedthe deduced template arguments.
Returns
the result of template argument deduction with the bases. "invalid" means no matches, "success" found a single item, and the "MiscellaneousDeductionFailure" result happens when the match is ambiguous.

Definition at line 1402 of file SemaTemplateDeduction.cpp.

References clang::CXXRecordDecl::bases(), DeduceTemplateSpecArguments(), clang::sema::TemplateDeductionInfo::ForBase, clang::Type::getAsCXXRecordDecl(), clang::Invalid, clang::Type::isRecordType(), clang::MiscellaneousDeductionFailure, P, clang::Success, clang::T, and Visited.

Referenced by DeduceTemplateArgumentsByTypeMatch().

◆ DeduceTemplateSpecArguments()

static TemplateDeductionResult DeduceTemplateSpecArguments ( Sema S,
TemplateParameterList TemplateParams,
const QualType  P,
QualType  A,
TemplateDeductionInfo Info,
SmallVectorImpl< DeducedTemplateArgument > &  Deduced 
)
static

◆ FinishTemplateArgumentDeduction() [1/3]

template<typename T >
static std::enable_if_t< IsPartialSpecialization< T >::value, TemplateDeductionResult > FinishTemplateArgumentDeduction ( Sema S,
T *  Partial,
bool  IsPartialOrdering,
ArrayRef< TemplateArgument TemplateArgs,
SmallVectorImpl< DeducedTemplateArgument > &  Deduced,
TemplateDeductionInfo Info 
)
static

◆ FinishTemplateArgumentDeduction() [2/3]

static TemplateDeductionResult FinishTemplateArgumentDeduction ( Sema S,
TemplateDecl TD,
SmallVectorImpl< DeducedTemplateArgument > &  Deduced,
TemplateDeductionInfo Info 
)
static

Complete template argument deduction for DeduceTemplateArgumentsFromType.

FIXME: this is mostly duplicated with the above two versions. Deduplicate the three implementations.

Definition at line 3258 of file SemaTemplateDeduction.cpp.

References CheckDeducedArgumentConstraints(), ConvertDeducedTemplateArguments(), getAsDeclContextOrEnclosing(), clang::Sema::SFINAETrap::hasErrorOccurred(), clang::Result, clang::SubstitutionFailure, clang::Success, clang::Unevaluated, and clang::Sema::Unevaluated.

◆ FinishTemplateArgumentDeduction() [3/3]

static TemplateDeductionResult FinishTemplateArgumentDeduction ( Sema S,
TemplateDecl Template,
bool  PartialOrdering,
ArrayRef< TemplateArgument TemplateArgs,
SmallVectorImpl< DeducedTemplateArgument > &  Deduced,
TemplateDeductionInfo Info 
)
static

◆ getAsDeclContextOrEnclosing()

static DeclContext * getAsDeclContextOrEnclosing ( Decl D)
static

Definition at line 3037 of file SemaTemplateDeduction.cpp.

References D, and clang::Decl::getDeclContext().

Referenced by FinishTemplateArgumentDeduction().

◆ getDeducedParameterFromExpr() [1/2]

static const NonTypeTemplateParmDecl * getDeducedParameterFromExpr ( const Expr E,
unsigned  Depth 
)
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 166 of file SemaTemplateDeduction.cpp.

References E.

Referenced by DeduceFromInitializerList(), DeduceTemplateArguments(), DeduceTemplateArgumentsByTypeMatch(), getDeducedParameterFromExpr(), and MarkUsedTemplateParameters().

◆ getDeducedParameterFromExpr() [2/2]

static const NonTypeTemplateParmDecl * getDeducedParameterFromExpr ( TemplateDeductionInfo Info,
Expr E 
)
static

◆ 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 1361 of file SemaTemplateDeduction.cpp.

References clang::FunctionTemplateDecl::getTemplatedDecl().

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

◆ GetImplicitObjectParameterType()

static QualType GetImplicitObjectParameterType ( ASTContext Context,
const CXXMethodDecl Method,
QualType  RawType,
bool  IsOtherRvr 
)
static

◆ getLastTemplateSpecType()

static const TemplateSpecializationType * getLastTemplateSpecType ( QualType  QT)
static

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

Parameters
Sthe Sema
TemplateParamsthe template parameters that we are deducing
Pthe parameter type
Athe argument type
Infoinformation about the template argument deduction itself
Deducedthe 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 661 of file SemaTemplateDeduction.cpp.

References clang::TemplateSpecializationType::desugar(), clang::Type::getAs(), clang::QualType::getTypePtr(), clang::TemplateSpecializationType::isSugared(), and clang::T.

Referenced by DeduceTemplateSpecArguments().

◆ getMoreSpecialized()

template<typename TemplateLikeDecl , typename PrimaryDel >
static TemplateLikeDecl * getMoreSpecialized ( Sema S,
QualType  T1,
QualType  T2,
TemplateLikeDecl *  P1,
PrimaryDel *  P2,
TemplateDeductionInfo Info 
)
static

Returns the more specialized template specialization between T1/P1 and T2/P2.

  • If IsMoreSpecialThanPrimaryCheck is true, T1/P1 is the partial specialization and T2/P2 is the primary template.
  • otherwise, both T1/P1 and T2/P2 are the partial specialization.
Parameters
T1the type of the first template partial specialization
T2if IsMoreSpecialThanPrimaryCheck is true, the type of the second template partial specialization; otherwise, the type of the primary template.
P1the first template partial specialization
P2if IsMoreSpecialThanPrimaryCheck is true, the second template partial specialization; otherwise, the primary template.
Returns
- If IsMoreSpecialThanPrimaryCheck is true, returns P1 if P1 is more specialized, returns nullptr if P1 is not more specialized.
  • otherwise, returns the more specialized template partial specialization. If neither partial specialization is more specialized, returns NULL.

Definition at line 5987 of file SemaTemplateDeduction.cpp.

References clang::Sema::Context, clang::Sema::getASTContext(), clang::TemplateArgument::getKind(), clang::ASTContext::getLangOpts(), clang::Sema::IsAtLeastAsConstrained(), isAtLeastAsSpecializedAs(), clang::TemplateArgument::Pack, clang::TemplateArgument::pack_elements(), clang::TemplateArgument::pack_size(), clang::TemplateParameterList::size(), clang::Sema::TemplateParameterListsAreEqual(), and clang::Sema::TPL_TemplateParamsEquivalent.

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

◆ 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 3740 of file SemaTemplateDeduction.cpp.

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

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

◆ getTemplateParameterWithDefault()

static NamedDecl * getTemplateParameterWithDefault ( Sema S,
NamedDecl A,
TemplateArgument  Default 
)
static

Create a shallow copy of a given template parameter declaration, with empty source locations and using the given TemplateArgument as it's default argument.

Returns
The new template parameter declaration.

Definition at line 517 of file SemaTemplateDeduction.cpp.

References clang::C, clang::Sema::Context, clang::TemplateTypeParmDecl::Create(), clang::TemplateTemplateParmDecl::Create(), clang::NonTypeTemplateParmDecl::Create(), clang::Default, clang::Decl::getDeclContext(), clang::Decl::getKind(), clang::Sema::getTrivialTemplateArgumentLoc(), and clang::T.

Referenced by DeduceTemplateArguments().

◆ GetTypeOfFunction()

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

◆ hasDeducibleTemplateParameters()

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

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

Referenced by DeduceTemplateArgumentsByTypeMatch().

◆ 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 2549 of file SemaTemplateDeduction.cpp.

References hasPackExpansionBeforeEnd(), and clang::TemplateArgument::Pack.

Referenced by DeduceTemplateArguments(), hasPackExpansionBeforeEnd(), 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 118 of file SemaTemplateDeduction.cpp.

References X.

Referenced by checkDeducedTemplateArguments(), DeduceTemplateArguments(), and isSameTemplateArg().

◆ 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 2532 of file SemaTemplateDeduction.cpp.

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

Referenced by DeduceTemplateArguments().

◆ instantiateExplicitSpecifierDeferred()

static TemplateDeductionResult instantiateExplicitSpecifierDeferred ( Sema S,
FunctionDecl Specialization,
const MultiLevelTemplateArgumentList SubstArgs,
TemplateDeductionInfo Info,
FunctionTemplateDecl FunctionTemplate,
ArrayRef< TemplateArgument DeducedArgs 
)
static

◆ isAtLeastAsSpecializedAs() [1/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
TemplateLikeDeclThe kind of P2, which must be a TemplateDecl or {Class,Var}TemplatePartialSpecializationDecl.
Parameters
T1The injected-class-name of P1 (faked for a variable template).
T2The injected-class-name of P2 (faked for a variable template).

Definition at line 5846 of file SemaTemplateDeduction.cpp.

References DeduceTemplateArgumentsByTypeMatch(), clang::sema::TemplateDeductionInfo::getLocation(), clang::Sema::InstantiatingTemplate::isInvalid(), clang::Sema::runWithSufficientStackSpace(), clang::Success, and clang::TDF_None.

◆ isAtLeastAsSpecializedAs() [2/2]

static bool isAtLeastAsSpecializedAs ( Sema S,
SourceLocation  Loc,
const FunctionTemplateDecl FT1,
const FunctionTemplateDecl FT2,
TemplatePartialOrderingContext  TPOC,
bool  Reversed,
const SmallVector< QualType > &  Args1,
const SmallVector< QualType > &  Args2 
)
static

◆ isForwardingReference()

static bool isForwardingReference ( QualType  Param,
unsigned  FirstInnerIndex 
)
static

Determine whether a type denotes a forwarding reference.

Definition at line 1369 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 794 of file SemaTemplateDeduction.cpp.

References clang::Type::getCanonicalTypeInternal(), clang::QualType::getTypePtr(), IsPossiblyOpaquelyQualifiedTypeInternal(), and clang::T.

Referenced by DeduceTemplateArgumentsByTypeMatch().

◆ IsPossiblyOpaquelyQualifiedTypeInternal()

static bool IsPossiblyOpaquelyQualifiedTypeInternal ( const Type T)
static

◆ isSameDeclaration()

static bool isSameDeclaration ( Decl X,
Decl Y 
)
static

Determine whether two declaration pointers refer to the same declaration.

Definition at line 202 of file SemaTemplateDeduction.cpp.

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

Referenced by checkDeducedTemplateArguments(), DeduceTemplateArguments(), clang::Sema::FinishTemplateArgumentDeduction(), and isSameTemplateArg().

◆ isSameTemplateArg()

static bool isSameTemplateArg ( ASTContext Context,
TemplateArgument  X,
const TemplateArgument Y,
bool  PartialOrdering,
bool  PackExpansionMatchesPack = false 
)
static

◆ isSimpleTemplateIdType()

static bool isSimpleTemplateIdType ( QualType  T)
static

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

Definition at line 3408 of file SemaTemplateDeduction.cpp.

References clang::Type::getAs(), and clang::T.

Referenced by AdjustFunctionParmAndArgTypesForDeduction(), and CheckOriginalCallArgDeduction().

◆ makeTemplateParameter()

static TemplateParameter makeTemplateParameter ( Decl D)
static

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

Definition at line 801 of file SemaTemplateDeduction.cpp.

References D.

Referenced by ConvertDeducedTemplateArguments(), FinishTemplateArgumentDeduction(), and clang::Sema::SubstituteExplicitTemplateArguments().

◆ MarkUsedTemplateParameters() [1/5]

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

◆ MarkUsedTemplateParameters() [2/5]

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

◆ MarkUsedTemplateParameters() [3/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 6300 of file SemaTemplateDeduction.cpp.

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

◆ MarkUsedTemplateParameters() [4/5]

static void MarkUsedTemplateParameters ( ASTContext Ctx,
QualType  T,
bool  OnlyDeduced,
unsigned  Level,
llvm::SmallBitVector &  Deduced 
)
static

◆ 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 6317 of file SemaTemplateDeduction.cpp.

References MarkUsedTemplateParameters(), and Used.

◆ ResolveOverloadForDeduction()

static QualType ResolveOverloadForDeduction ( Sema S,
TemplateParameterList TemplateParams,
Expr Arg,
QualType  ParamType,
bool  ParamWasReference,
TemplateSpecCandidateSet FailedTSC = nullptr 
)
static