clang API Documentation

Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
clang::ClassTemplateSpecializationDecl Class Reference

Represents a class template specialization, which refers to a class template with a given set of template arguments. More...

#include <DeclTemplate.h>

Inheritance diagram for clang::ClassTemplateSpecializationDecl:
Inheritance graph
[legend]
Collaboration diagram for clang::ClassTemplateSpecializationDecl:
Collaboration graph
[legend]

List of all members.

Classes

struct  ExplicitSpecializationInfo
 Further info for explicit template specialization/instantiation.
struct  SpecializedPartialSpecialization
 Structure that stores information about a class template specialization that was instantiated from a class template partial specialization.

Public Member Functions

void getNameForDiagnostic (raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
ClassTemplateSpecializationDeclgetMostRecentDecl ()
 Returns the most recent (re)declaration of this declaration.
ClassTemplateDeclgetSpecializedTemplate () const
 Retrieve the template that this specialization specializes.
const TemplateArgumentListgetTemplateArgs () const
 Retrieve the template arguments of the class template specialization.
TemplateSpecializationKind getSpecializationKind () const
 Determine the kind of specialization that this declaration represents.
bool isExplicitSpecialization () const
bool isExplicitInstantiationOrSpecialization () const
 True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.
void setSpecializationKind (TemplateSpecializationKind TSK)
SourceLocation getPointOfInstantiation () const
 Get the point of instantiation (if any), or null if none.
void setPointOfInstantiation (SourceLocation Loc)
llvm::PointerUnion
< ClassTemplateDecl
*, ClassTemplatePartialSpecializationDecl * > 
getInstantiatedFrom () const
 If this class template specialization is an instantiation of a template (rather than an explicit specialization), return the class template or class template partial specialization from which it was instantiated.
llvm::PointerUnion
< ClassTemplateDecl
*, ClassTemplatePartialSpecializationDecl * > 
getSpecializedTemplateOrPartial () const
 Retrieve the class template or class template partial specialization which was specialized by this.
const TemplateArgumentListgetTemplateInstantiationArgs () const
 Retrieve the set of template arguments that should be used to instantiate members of the class template or class template partial specialization from which this class template specialization was instantiated.
void setInstantiationOf (ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
 Note that this class template specialization is actually an instantiation of the given class template partial specialization whose template arguments have been deduced.
void setInstantiationOf (ClassTemplateDecl *TemplDecl)
 Note that this class template specialization is an instantiation of the given class template.
void setTypeAsWritten (TypeSourceInfo *T)
 Sets the type of this specialization as it was written by the user. This will be a class template specialization type.
TypeSourceInfogetTypeAsWritten () const
 Gets the type of this specialization as it was written by the user, if it was so written.
SourceLocation getExternLoc () const
 Gets the location of the extern keyword, if present.
void setExternLoc (SourceLocation Loc)
 Sets the location of the extern keyword.
void setTemplateKeywordLoc (SourceLocation Loc)
 Sets the location of the template keyword.
SourceLocation getTemplateKeywordLoc () const
 Gets the location of the template keyword, if present.
SourceRange getSourceRange () const override LLVM_READONLY
 Source range that this declaration covers.
void Profile (llvm::FoldingSetNodeID &ID) const

Static Public Member Functions

static
ClassTemplateSpecializationDecl
Create (ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, const TemplateArgument *Args, unsigned NumArgs, ClassTemplateSpecializationDecl *PrevDecl)
static
ClassTemplateSpecializationDecl
CreateDeserialized (ASTContext &C, unsigned ID)
static void Profile (llvm::FoldingSetNodeID &ID, ArrayRef< TemplateArgument > TemplateArgs, ASTContext &Context)
static bool classof (const Decl *D)
static bool classofKind (Kind K)

Protected Member Functions

 ClassTemplateSpecializationDecl (ASTContext &Context, Kind DK, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate, const TemplateArgument *Args, unsigned NumArgs, ClassTemplateSpecializationDecl *PrevDecl)
 ClassTemplateSpecializationDecl (ASTContext &C, Kind DK)

Friends

class ASTDeclReader
class ASTDeclWriter

Detailed Description

Represents a class template specialization, which refers to a class template with a given set of template arguments.

Class template specializations represent both explicit specialization of class templates, as in the example below, and implicit instantiations of class templates.

 template<typename T> class array;

 template<>
 class array<bool> { }; // class template specialization array<bool>

Definition at line 1386 of file DeclTemplate.h.


Constructor & Destructor Documentation

ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl ( ASTContext Context,
Kind  DK,
TagKind  TK,
DeclContext DC,
SourceLocation  StartLoc,
SourceLocation  IdLoc,
ClassTemplateDecl SpecializedTemplate,
const TemplateArgument Args,
unsigned  NumArgs,
ClassTemplateSpecializationDecl PrevDecl 
) [protected]

Definition at line 690 of file DeclTemplate.cpp.

Referenced by Create(), and CreateDeserialized().

Definition at line 706 of file DeclTemplate.cpp.


Member Function Documentation

static bool clang::ClassTemplateSpecializationDecl::classof ( const Decl D) [inline, static]

Reimplemented from clang::CXXRecordDecl.

Reimplemented in clang::ClassTemplatePartialSpecializationDecl.

Definition at line 1640 of file DeclTemplate.h.

References classofKind(), and clang::Decl::getKind().

Reimplemented from clang::CXXRecordDecl.

Reimplemented in clang::ClassTemplatePartialSpecializationDecl.

Definition at line 1641 of file DeclTemplate.h.

Referenced by classof().

ClassTemplateSpecializationDecl * ClassTemplateSpecializationDecl::Create ( ASTContext Context,
TagKind  TK,
DeclContext DC,
SourceLocation  StartLoc,
SourceLocation  IdLoc,
ClassTemplateDecl SpecializedTemplate,
const TemplateArgument Args,
unsigned  NumArgs,
ClassTemplateSpecializationDecl PrevDecl 
) [static]

Gets the location of the extern keyword, if present.

Definition at line 1605 of file DeclTemplate.h.

Referenced by getSourceRange(), and clang::ASTDeclWriter::VisitClassTemplateSpecializationDecl().

If this class template specialization is an instantiation of a template (rather than an explicit specialization), return the class template or class template partial specialization from which it was instantiated.

Definition at line 1530 of file DeclTemplate.h.

References getSpecializationKind(), getSpecializedTemplateOrPartial(), and clang::isTemplateInstantiation().

Referenced by getDefiningModule(), and getSourceRange().

Returns the most recent (re)declaration of this declaration.

Reimplemented from clang::CXXRecordDecl.

Reimplemented in clang::ClassTemplatePartialSpecializationDecl.

Definition at line 1463 of file DeclTemplate.h.

References clang::CXXRecordDecl::getPreviousDecl(), and clang::RecordDecl::isInjectedClassName().

void ClassTemplateSpecializationDecl::getNameForDiagnostic ( raw_ostream &  OS,
const PrintingPolicy Policy,
bool  Qualified 
) const [override, virtual]

getNameForDiagnostic - Appends a human-readable name for this declaration into the given stream.

This is the method invoked by Sema when displaying a NamedDecl in a diagnostic. It does not necessarily produce the same result as printName(); for example, class template specializations are printed with their template arguments.

Reimplemented from clang::NamedDecl.

Definition at line 740 of file DeclTemplate.cpp.

References clang::TemplateArgumentList::data(), getTemplateArgs(), clang::TemplateSpecializationType::PrintTemplateArgumentList(), and clang::TemplateArgumentList::size().

Retrieve the class template or class template partial specialization which was specialized by this.

Definition at line 1542 of file DeclTemplate.h.

Referenced by getInstantiatedFrom(), clang::ASTDeclReader::UpdateDecl(), and clang::ASTDeclWriter::VisitClassTemplateSpecializationDecl().

Retrieve the set of template arguments that should be used to instantiate members of the class template or class template partial specialization from which this class template specialization was instantiated.

Returns:
For a class template specialization instantiated from the primary template, this function will return the same template arguments as getTemplateArgs(). For a class template specialization instantiated from a class template partial specialization, this function will return the deduced template arguments for the class template partial specialization itself.

Definition at line 1561 of file DeclTemplate.h.

References getTemplateArgs().

Referenced by clang::ASTDeclWriter::VisitClassTemplateSpecializationDecl().

Gets the location of the template keyword, if present.

Definition at line 1622 of file DeclTemplate.h.

Referenced by getSourceRange(), and clang::ASTDeclWriter::VisitClassTemplateSpecializationDecl().

Gets the type of this specialization as it was written by the user, if it was so written.

Definition at line 1600 of file DeclTemplate.h.

Referenced by getSourceRange(), and clang::ASTDeclWriter::VisitClassTemplateSpecializationDecl().

True if this declaration is an explicit specialization, explicit instantiation declaration, or explicit instantiation definition.

Definition at line 1496 of file DeclTemplate.h.

References clang::CXXRecordDecl::getTemplateSpecializationKind(), clang::TSK_ExplicitInstantiationDeclaration, clang::TSK_ExplicitInstantiationDefinition, clang::TSK_ExplicitSpecialization, clang::TSK_ImplicitInstantiation, and clang::TSK_Undeclared.

Referenced by shouldConsiderTemplateVisibility().

void clang::ClassTemplateSpecializationDecl::Profile ( llvm::FoldingSetNodeID &  ID) const [inline]

Definition at line 1628 of file DeclTemplate.h.

References clang::TemplateArgumentList::asArray(), and clang::Decl::getASTContext().

Referenced by Profile().

static void clang::ClassTemplateSpecializationDecl::Profile ( llvm::FoldingSetNodeID &  ID,
ArrayRef< TemplateArgument TemplateArgs,
ASTContext Context 
) [inline, static]

Definition at line 1633 of file DeclTemplate.h.

References Profile().

Sets the location of the extern keyword.

Definition at line 1609 of file DeclTemplate.h.

References clang::Decl::getASTContext().

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

Note that this class template specialization is actually an instantiation of the given class template partial specialization whose template arguments have been deduced.

Definition at line 1572 of file DeclTemplate.h.

References clang::Decl::getASTContext().

Referenced by clang::Sema::InstantiateClassTemplateSpecialization(), and clang::ASTDeclReader::UpdateDecl().

Note that this class template specialization is an instantiation of the given class template.

Definition at line 1585 of file DeclTemplate.h.

Sets the location of the template keyword.

Definition at line 1616 of file DeclTemplate.h.

References clang::Decl::getASTContext().

Referenced by clang::Sema::ActOnClassTemplateSpecialization(), and clang::Sema::ActOnExplicitInstantiation().

Sets the type of this specialization as it was written by the user. This will be a class template specialization type.

Definition at line 1593 of file DeclTemplate.h.

References clang::Decl::getASTContext().

Referenced by clang::Sema::ActOnClassTemplateSpecialization(), clang::Sema::ActOnExplicitInstantiation(), and clang::TemplateDeclInstantiator::InstantiateClassTemplatePartialSpecialization().


Friends And Related Function Documentation

friend class ASTDeclReader [friend]

Reimplemented from clang::CXXRecordDecl.

Reimplemented in clang::ClassTemplatePartialSpecializationDecl.

Definition at line 1646 of file DeclTemplate.h.

friend class ASTDeclWriter [friend]

Reimplemented from clang::CXXRecordDecl.

Reimplemented in clang::ClassTemplatePartialSpecializationDecl.

Definition at line 1647 of file DeclTemplate.h.


The documentation for this class was generated from the following files: