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

virtual void getNameForDiagnostic (std::string &S, const PrintingPolicy &Policy, bool Qualified) const
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
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, 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
 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, const TemplateArgument *TemplateArgs, unsigned NumTemplateArgs, ASTContext &Context)
static bool classof (const Decl *D)
static bool classofKind (Kind K)
static bool classof (const ClassTemplateSpecializationDecl *)
static bool classof (const ClassTemplatePartialSpecializationDecl *)

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 (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 1213 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 621 of file DeclTemplate.cpp.

Referenced by Create(), and CreateDeserialized().

ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl ( Kind  DK) [explicit, protected]

Definition at line 637 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 1454 of file DeclTemplate.h.

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

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

Reimplemented from clang::CXXRecordDecl.

Definition at line 1460 of file DeclTemplate.h.

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

Reimplemented in clang::ClassTemplatePartialSpecializationDecl.

Definition at line 1464 of file DeclTemplate.h.

static bool clang::ClassTemplateSpecializationDecl::classofKind ( Kind  K) [inline, static]

Reimplemented from clang::CXXRecordDecl.

Reimplemented in clang::ClassTemplatePartialSpecializationDecl.

Definition at line 1455 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]
ClassTemplateSpecializationDecl * ClassTemplateSpecializationDecl::CreateDeserialized ( ASTContext C,
unsigned  ID 
) [static]
SourceLocation clang::ClassTemplateSpecializationDecl::getExternLoc ( ) const [inline]

Gets the location of the extern keyword, if present.

Definition at line 1419 of file DeclTemplate.h.

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

llvm::PointerUnion<ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl *> clang::ClassTemplateSpecializationDecl::getInstantiatedFrom ( ) const [inline]

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 1336 of file DeclTemplate.h.

References getSpecializationKind(), clang::TSK_ExplicitInstantiationDeclaration, clang::TSK_ExplicitInstantiationDefinition, and clang::TSK_ImplicitInstantiation.

Referenced by getSourceRange().

ClassTemplateSpecializationDecl* clang::ClassTemplateSpecializationDecl::getMostRecentDecl ( ) [inline]

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

Reimplemented from clang::CXXRecordDecl.

Reimplemented in clang::ClassTemplatePartialSpecializationDecl.

Definition at line 1286 of file DeclTemplate.h.

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

void ClassTemplateSpecializationDecl::getNameForDiagnostic ( std::string &  S,
const PrintingPolicy Policy,
bool  Qualified 
) const [virtual]

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

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

TODO: use an API that doesn't require so many temporary strings

Reimplemented from clang::NamedDecl.

Definition at line 672 of file DeclTemplate.cpp.

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

SourceLocation clang::ClassTemplateSpecializationDecl::getPointOfInstantiation ( ) const [inline]

Get the point of instantiation (if any), or null if none.

Definition at line 1321 of file DeclTemplate.h.

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

SourceRange ClassTemplateSpecializationDecl::getSourceRange ( ) const [virtual]
TemplateSpecializationKind clang::ClassTemplateSpecializationDecl::getSpecializationKind ( ) const [inline]
ClassTemplateDecl * ClassTemplateSpecializationDecl::getSpecializedTemplate ( ) const
llvm::PointerUnion<ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl *> clang::ClassTemplateSpecializationDecl::getSpecializedTemplateOrPartial ( ) const [inline]

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

Definition at line 1355 of file DeclTemplate.h.

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

const TemplateArgumentList& clang::ClassTemplateSpecializationDecl::getTemplateArgs ( ) const [inline]
const TemplateArgumentList& clang::ClassTemplateSpecializationDecl::getTemplateInstantiationArgs ( ) const [inline]

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 1375 of file DeclTemplate.h.

References getTemplateArgs().

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

SourceLocation clang::ClassTemplateSpecializationDecl::getTemplateKeywordLoc ( ) const [inline]

Gets the location of the template keyword, if present.

Definition at line 1436 of file DeclTemplate.h.

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

TypeSourceInfo* clang::ClassTemplateSpecializationDecl::getTypeAsWritten ( ) const [inline]

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

Definition at line 1414 of file DeclTemplate.h.

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

bool clang::ClassTemplateSpecializationDecl::isExplicitSpecialization ( ) const [inline]
void clang::ClassTemplateSpecializationDecl::Profile ( llvm::FoldingSetNodeID &  ID) const [inline]
static void clang::ClassTemplateSpecializationDecl::Profile ( llvm::FoldingSetNodeID &  ID,
const TemplateArgument TemplateArgs,
unsigned  NumTemplateArgs,
ASTContext Context 
) [inline, static]

Definition at line 1447 of file DeclTemplate.h.

References Arg, and Profile().

void clang::ClassTemplateSpecializationDecl::setExternLoc ( SourceLocation  Loc) [inline]

Sets the location of the extern keyword.

Definition at line 1423 of file DeclTemplate.h.

References clang::Decl::getASTContext().

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

void clang::ClassTemplateSpecializationDecl::setInstantiationOf ( ClassTemplatePartialSpecializationDecl PartialSpec,
TemplateArgumentList TemplateArgs 
) [inline]

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 1386 of file DeclTemplate.h.

References clang::Decl::getASTContext().

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

void clang::ClassTemplateSpecializationDecl::setInstantiationOf ( ClassTemplateDecl TemplDecl) [inline]

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

Definition at line 1399 of file DeclTemplate.h.

void clang::ClassTemplateSpecializationDecl::setPointOfInstantiation ( SourceLocation  Loc) [inline]
void clang::ClassTemplateSpecializationDecl::setSpecializationKind ( TemplateSpecializationKind  TSK) [inline]
void clang::ClassTemplateSpecializationDecl::setTemplateKeywordLoc ( SourceLocation  Loc) [inline]

Sets the location of the template keyword.

Definition at line 1430 of file DeclTemplate.h.

References clang::Decl::getASTContext().

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

void clang::ClassTemplateSpecializationDecl::setTypeAsWritten ( TypeSourceInfo T) [inline]

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

Definition at line 1407 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 1468 of file DeclTemplate.h.

friend class ASTDeclWriter [friend]

Reimplemented from clang::CXXRecordDecl.

Reimplemented in clang::ClassTemplatePartialSpecializationDecl.

Definition at line 1469 of file DeclTemplate.h.


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