clang API Documentation
Represents a type template specialization; the template must be a class template, a type alias template, or a template template parameter. A template which cannot be resolved to one of these, e.g. because it is written with a dependent scope specifier, is instead represented as a DependentTemplateSpecializationType
.
More...
#include <Type.h>
Public Types | |
typedef const TemplateArgument * | iterator |
Public Member Functions | |
bool | isCurrentInstantiation () const |
bool | isTypeAlias () const |
Determine if this template specialization type is for a type alias template that has been substituted. | |
QualType | getAliasedType () const |
iterator | begin () const |
iterator | end () const |
TemplateName | getTemplateName () const |
Retrieve the name of the template that we are specializing. | |
const TemplateArgument * | getArgs () const |
Retrieve the template arguments. | |
unsigned | getNumArgs () const |
Retrieve the number of template arguments. | |
const TemplateArgument & | getArg (unsigned Idx) const |
Retrieve a specific template argument as a type. | |
bool | isSugared () const |
QualType | desugar () const |
void | Profile (llvm::FoldingSetNodeID &ID, const ASTContext &Ctx) |
Static Public Member Functions | |
static bool | anyDependentTemplateArguments (const TemplateArgumentLoc *Args, unsigned NumArgs, bool &InstantiationDependent) |
Determine whether any of the given template arguments are dependent. | |
static bool | anyDependentTemplateArguments (const TemplateArgumentListInfo &, bool &InstantiationDependent) |
static void | PrintTemplateArgumentList (raw_ostream &OS, const TemplateArgument *Args, unsigned NumArgs, const PrintingPolicy &Policy, bool SkipBrackets=false) |
Print a template argument list, including the '<' and '>' enclosing the template arguments. | |
static void | PrintTemplateArgumentList (raw_ostream &OS, const TemplateArgumentLoc *Args, unsigned NumArgs, const PrintingPolicy &Policy) |
static void | PrintTemplateArgumentList (raw_ostream &OS, const TemplateArgumentListInfo &, const PrintingPolicy &Policy) |
static void | Profile (llvm::FoldingSetNodeID &ID, TemplateName T, const TemplateArgument *Args, unsigned NumArgs, const ASTContext &Context) |
static bool | classof (const Type *T) |
Friends | |
class | ASTContext |
Represents a type template specialization; the template must be a class template, a type alias template, or a template template parameter. A template which cannot be resolved to one of these, e.g. because it is written with a dependent scope specifier, is instead represented as a DependentTemplateSpecializationType
.
A non-dependent template specialization type is always "sugar", typically for a RecordType
. For example, a class template specialization type of vector<int>
will refer to a tag type for the instantiation std::vector<int
, std::allocator<int>>
Template specializations are dependent if either the template or any of the template arguments are dependent, in which case the type may also be canonical.
Instances of this type are allocated with a trailing array of TemplateArguments, followed by a QualType representing the non-canonical aliased type when the template is a type alias template.
typedef const TemplateArgument* clang::TemplateSpecializationType::iterator |
bool TemplateSpecializationType::anyDependentTemplateArguments | ( | const TemplateArgumentLoc * | Args, |
unsigned | NumArgs, | ||
bool & | InstantiationDependent | ||
) | [static] |
Determine whether any of the given template arguments are dependent.
Definition at line 1986 of file Type.cpp.
Referenced by clang::Sema::ActOnClassTemplateSpecialization(), clang::Sema::ActOnFunctionDeclarator(), clang::Sema::ActOnVarTemplateSpecialization(), anyDependentTemplateArguments(), clang::Sema::BuildTemplateIdExpr(), clang::Sema::CheckTemplateIdType(), clang::Sema::CheckVarTemplateId(), DoMarkVarDeclReferenced(), clang::Sema::FindInstantiatedDecl(), and clang::Sema::InstantiateVariableDefinition().
bool TemplateSpecializationType::anyDependentTemplateArguments | ( | const TemplateArgumentListInfo & | Args, |
bool & | InstantiationDependent | ||
) | [static] |
Definition at line 1979 of file Type.cpp.
References anyDependentTemplateArguments(), clang::TemplateArgumentListInfo::getArgumentArray(), and clang::TemplateArgumentListInfo::size().
iterator clang::TemplateSpecializationType::begin | ( | ) | const [inline] |
static bool clang::TemplateSpecializationType::classof | ( | const Type * | T | ) | [inline, static] |
Definition at line 3862 of file Type.h.
References clang::Type::getTypeClass().
QualType clang::TemplateSpecializationType::desugar | ( | ) | const [inline] |
TemplateSpecializationType::iterator clang::TemplateSpecializationType::end | ( | ) | const [inline] |
Definition at line 648 of file TemplateBase.h.
QualType clang::TemplateSpecializationType::getAliasedType | ( | ) | const [inline] |
const TemplateArgument & clang::TemplateSpecializationType::getArg | ( | unsigned | Idx | ) | const [inline] |
Retrieve a specific template argument as a type.
isArgType(Arg)
Definition at line 658 of file TemplateBase.h.
Referenced by IsStructurallyEquivalent(), and MarkUsedTemplateParameters().
const TemplateArgument* clang::TemplateSpecializationType::getArgs | ( | ) | const [inline] |
Retrieve the template arguments.
Definition at line 3835 of file Type.h.
Referenced by DeduceTemplateArguments(), clang::Sema::getTemplateInstantiationArgs(), MarkUsedTemplateParameters(), and clang::ASTNodeImporter::VisitTemplateSpecializationType().
unsigned clang::TemplateSpecializationType::getNumArgs | ( | ) | const [inline] |
Retrieve the number of template arguments.
Definition at line 3840 of file Type.h.
Referenced by DeduceTemplateArguments(), clang::Sema::getTemplateInstantiationArgs(), IsStructurallyEquivalent(), MarkUsedTemplateParameters(), and clang::ASTNodeImporter::VisitTemplateSpecializationType().
TemplateName clang::TemplateSpecializationType::getTemplateName | ( | ) | const [inline] |
Retrieve the name of the template that we are specializing.
Definition at line 3832 of file Type.h.
Referenced by DeduceTemplateArguments(), isEnableIf(), IsSmallVector(), IsStdVector(), IsStructurallyEquivalent(), MarkUsedTemplateParameters(), recoverFromTypeInKnownDependentBase(), clang::TreeTransform< Derived >::TransformTemplateSpecializationType(), and clang::ASTNodeImporter::VisitTemplateSpecializationType().
bool clang::TemplateSpecializationType::isCurrentInstantiation | ( | ) | const [inline] |
bool clang::TemplateSpecializationType::isSugared | ( | ) | const [inline] |
bool clang::TemplateSpecializationType::isTypeAlias | ( | ) | const [inline] |
Determine if this template specialization type is for a type alias template that has been substituted.
Nearly every template specialization type whose template is an alias template will be substituted. However, this is not the case when the specialization contains a pack expansion but the template alias does not have a corresponding parameter pack, e.g.,
void TemplateSpecializationType::PrintTemplateArgumentList | ( | raw_ostream & | OS, |
const TemplateArgument * | Args, | ||
unsigned | NumArgs, | ||
const PrintingPolicy & | Policy, | ||
bool | SkipBrackets = false |
||
) | [static] |
Print a template argument list, including the '<' and '>' enclosing the template arguments.
Definition at line 1341 of file TypePrinter.cpp.
References getKind(), clang::TemplateArgument::Pack, and clang::TemplateArgument::print().
Referenced by clang::ClassTemplateSpecializationDecl::getNameForDiagnostic(), clang::FunctionDecl::getNameForDiagnostic(), clang::VarTemplateSpecializationDecl::getNameForDiagnostic(), clang::NestedNameSpecifier::print(), clang::Sema::PrintInstantiationStack(), clang::NamedDecl::printQualifiedName(), and PrintTemplateArgumentList().
void TemplateSpecializationType::PrintTemplateArgumentList | ( | raw_ostream & | OS, |
const TemplateArgumentLoc * | Args, | ||
unsigned | NumArgs, | ||
const PrintingPolicy & | Policy | ||
) | [static] |
Definition at line 1392 of file TypePrinter.cpp.
void TemplateSpecializationType::PrintTemplateArgumentList | ( | raw_ostream & | OS, |
const TemplateArgumentListInfo & | Args, | ||
const PrintingPolicy & | Policy | ||
) | [static] |
Definition at line 1331 of file TypePrinter.cpp.
References clang::TemplateArgumentListInfo::getArgumentArray(), PrintTemplateArgumentList(), and clang::TemplateArgumentListInfo::size().
void clang::TemplateSpecializationType::Profile | ( | llvm::FoldingSetNodeID & | ID, |
const ASTContext & | Ctx | ||
) | [inline] |
Definition at line 3851 of file Type.h.
Referenced by clang::ASTContext::getCanonicalTemplateSpecializationType(), and Profile().
void TemplateSpecializationType::Profile | ( | llvm::FoldingSetNodeID & | ID, |
TemplateName | T, | ||
const TemplateArgument * | Args, | ||
unsigned | NumArgs, | ||
const ASTContext & | Context | ||
) | [static] |
Definition at line 2047 of file Type.cpp.
References clang::TemplateName::Profile(), and Profile().
friend class ASTContext [friend] |
Reimplemented from clang::Type.