clang API Documentation

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

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

#include <DeclTemplate.h>

Inheritance diagram for clang::VarTemplateSpecializationDecl:
Inheritance graph
[legend]
Collaboration diagram for clang::VarTemplateSpecializationDecl:
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 variable template specialization that was instantiated from a variable template partial specialization.

Public Member Functions

void getNameForDiagnostic (raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const override
VarTemplateSpecializationDeclgetMostRecentDecl ()
 Returns the most recent (re)declaration of this declaration.
VarTemplateDeclgetSpecializedTemplate () const
 Retrieve the template that this specialization specializes.
const TemplateArgumentListgetTemplateArgs () const
 Retrieve the template arguments of the variable template specialization.
void setTemplateArgsInfo (const TemplateArgumentListInfo &ArgsInfo)
const TemplateArgumentListInfogetTemplateArgsInfo () const
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
< VarTemplateDecl
*, VarTemplatePartialSpecializationDecl * > 
getInstantiatedFrom () const
 If this variable template specialization is an instantiation of a template (rather than an explicit specialization), return the variable template or variable template partial specialization from which it was instantiated.
llvm::PointerUnion
< VarTemplateDecl
*, VarTemplatePartialSpecializationDecl * > 
getSpecializedTemplateOrPartial () const
 Retrieve the variable template or variable template partial specialization which was specialized by this.
const TemplateArgumentListgetTemplateInstantiationArgs () const
 Retrieve the set of template arguments that should be used to instantiate the initializer of the variable template or variable template partial specialization from which this variable template specialization was instantiated.
void setInstantiationOf (VarTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs)
 Note that this variable template specialization is actually an instantiation of the given variable template partial specialization whose template arguments have been deduced.
void setInstantiationOf (VarTemplateDecl *TemplDecl)
 Note that this variable template specialization is an instantiation of the given variable template.
void setTypeAsWritten (TypeSourceInfo *T)
 Sets the type of this specialization as it was written by the user.
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.
void Profile (llvm::FoldingSetNodeID &ID) const

Static Public Member Functions

static
VarTemplateSpecializationDecl
Create (ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args, unsigned NumArgs)
static
VarTemplateSpecializationDecl
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

 VarTemplateSpecializationDecl (Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args, unsigned NumArgs)
 VarTemplateSpecializationDecl (Kind DK, ASTContext &Context)

Friends

class ASTDeclReader
class ASTDeclWriter

Detailed Description

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

Variable template specializations represent both explicit specializations of variable templates, as in the example below, and implicit instantiations of variable templates.

 template<typename T> constexpr T pi = T(3.1415926535897932385);

 template<>
 constexpr float pi<float>; // variable template specialization pi<float>

Definition at line 2249 of file DeclTemplate.h.


Constructor & Destructor Documentation

VarTemplateSpecializationDecl::VarTemplateSpecializationDecl ( Kind  DK,
ASTContext Context,
DeclContext DC,
SourceLocation  StartLoc,
SourceLocation  IdLoc,
VarTemplateDecl SpecializedTemplate,
QualType  T,
TypeSourceInfo TInfo,
StorageClass  S,
const TemplateArgument Args,
unsigned  NumArgs 
) [protected]

Definition at line 1057 of file DeclTemplate.cpp.

Referenced by Create(), and CreateDeserialized().

VarTemplateSpecializationDecl::VarTemplateSpecializationDecl ( Kind  DK,
ASTContext Context 
) [explicit, protected]

Definition at line 1068 of file DeclTemplate.cpp.


Member Function Documentation

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

Reimplemented from clang::VarDecl.

Reimplemented in clang::VarTemplatePartialSpecializationDecl.

Definition at line 2497 of file DeclTemplate.h.

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

Reimplemented from clang::VarDecl.

Reimplemented in clang::VarTemplatePartialSpecializationDecl.

Definition at line 2498 of file DeclTemplate.h.

Referenced by classof().

VarTemplateSpecializationDecl * VarTemplateSpecializationDecl::Create ( ASTContext Context,
DeclContext DC,
SourceLocation  StartLoc,
SourceLocation  IdLoc,
VarTemplateDecl SpecializedTemplate,
QualType  T,
TypeSourceInfo TInfo,
StorageClass  S,
const TemplateArgument Args,
unsigned  NumArgs 
) [static]

Reimplemented from clang::VarDecl.

Reimplemented in clang::VarTemplatePartialSpecializationDecl.

Definition at line 1085 of file DeclTemplate.cpp.

References AttributeLangSupport::C, and VarTemplateSpecializationDecl().

Gets the location of the extern keyword, if present.

Definition at line 2464 of file DeclTemplate.h.

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

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

Definition at line 2384 of file DeclTemplate.h.

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

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

Reimplemented from clang::Redeclarable< VarDecl >.

Reimplemented in clang::VarTemplatePartialSpecializationDecl.

Definition at line 2319 of file DeclTemplate.h.

void VarTemplateSpecializationDecl::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 1090 of file DeclTemplate.cpp.

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

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

Reimplemented from clang::VarDecl.

Definition at line 2370 of file DeclTemplate.h.

Referenced by clang::Sema::ActOnVarTemplateSpecialization(), clang::Sema::RequireCompleteExprType(), and clang::ASTDeclWriter::VisitVarTemplateSpecializationDecl().

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

Definition at line 2401 of file DeclTemplate.h.

Referenced by clang::Sema::getTemplateInstantiationArgs(), clang::Sema::InstantiateVariableDefinition(), and clang::ASTDeclWriter::VisitVarTemplateSpecializationDecl().

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

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

Definition at line 2420 of file DeclTemplate.h.

References getTemplateArgs().

Referenced by clang::Sema::InstantiateVariableDefinition(), and clang::ASTDeclWriter::VisitVarTemplateSpecializationDecl().

Gets the location of the template keyword, if present.

Definition at line 2481 of file DeclTemplate.h.

Referenced by clang::Sema::BuildDeclRefExpr(), and clang::ASTDeclWriter::VisitVarTemplateSpecializationDecl().

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

Definition at line 2459 of file DeclTemplate.h.

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

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

Definition at line 2351 of file DeclTemplate.h.

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

Referenced by shouldConsiderTemplateVisibility().

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

Definition at line 2485 of file DeclTemplate.h.

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

Referenced by Profile().

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

Definition at line 2489 of file DeclTemplate.h.

References Profile().

Sets the location of the extern keyword.

Definition at line 2468 of file DeclTemplate.h.

References clang::Decl::getASTContext().

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

Definition at line 2431 of file DeclTemplate.h.

References clang::Decl::getASTContext().

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

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

Definition at line 2444 of file DeclTemplate.h.

Definition at line 2374 of file DeclTemplate.h.

References clang::SourceLocation::isValid().

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

Sets the location of the template keyword.

Definition at line 2475 of file DeclTemplate.h.

References clang::Decl::getASTContext().

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

Sets the type of this specialization as it was written by the user.

Definition at line 2452 of file DeclTemplate.h.

References clang::Decl::getASTContext().

Referenced by clang::TemplateDeclInstantiator::InstantiateVarTemplatePartialSpecialization().


Friends And Related Function Documentation

friend class ASTDeclReader [friend]

Reimplemented from clang::VarDecl.

Reimplemented in clang::VarTemplatePartialSpecializationDecl.

Definition at line 2503 of file DeclTemplate.h.

friend class ASTDeclWriter [friend]

Reimplemented from clang::DeclaratorDecl.

Reimplemented in clang::VarTemplatePartialSpecializationDecl.

Definition at line 2504 of file DeclTemplate.h.


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