clang  3.7.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
clang::TemplateArgument Class Reference

Represents a template argument. More...

#include <TemplateBase.h>

Inheritance diagram for clang::TemplateArgument:
[legend]
Collaboration diagram for clang::TemplateArgument:
[legend]

Public Types

enum  ArgKind {
  Null = 0, Type, Declaration, NullPtr,
  Integral, Template, TemplateExpansion, Expression,
  Pack
}
 The kind of template argument we're storing. More...
 
typedef const TemplateArgumentpack_iterator
 Iterator that traverses the elements of a template argument pack. More...
 

Public Member Functions

 TemplateArgument ()
 Construct an empty, invalid template argument. More...
 
 TemplateArgument (QualType T, bool isNullPtr=false)
 Construct a template type argument. More...
 
 TemplateArgument (ValueDecl *D, QualType QT)
 Construct a template argument that refers to a declaration, which is either an external declaration or a template declaration. More...
 
 TemplateArgument (ASTContext &Ctx, const llvm::APSInt &Value, QualType Type)
 Construct an integral constant template argument. The memory to store the value is allocated with Ctx. More...
 
 TemplateArgument (const TemplateArgument &Other, QualType Type)
 Construct an integral constant template argument with the same value as Other but a different type. More...
 
 TemplateArgument (TemplateName Name)
 Construct a template argument that is a template. More...
 
 TemplateArgument (TemplateName Name, Optional< unsigned > NumExpansions)
 Construct a template argument that is a template pack expansion. More...
 
 TemplateArgument (Expr *E)
 Construct a template argument that is an expression. More...
 
 TemplateArgument (const TemplateArgument *Args, unsigned NumArgs)
 Construct a template argument that is a template argument pack. More...
 
ArgKind getKind () const
 Return the kind of stored template argument. More...
 
bool isNull () const
 Determine whether this template argument has no value. More...
 
bool isDependent () const
 Whether this template argument is dependent on a template parameter such that its result can change from one instantiation to another. More...
 
bool isInstantiationDependent () const
 Whether this template argument is dependent on a template parameter. More...
 
bool containsUnexpandedParameterPack () const
 Whether this template argument contains an unexpanded parameter pack. More...
 
bool isPackExpansion () const
 Determine whether this template argument is a pack expansion. More...
 
QualType getAsType () const
 Retrieve the type for a type template argument. More...
 
ValueDeclgetAsDecl () const
 Retrieve the declaration for a declaration non-type template argument. More...
 
QualType getParamTypeForDecl () const
 
QualType getNullPtrType () const
 Retrieve the type for null non-type template argument. More...
 
TemplateName getAsTemplate () const
 Retrieve the template name for a template name argument. More...
 
TemplateName getAsTemplateOrTemplatePattern () const
 Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name. More...
 
Optional< unsignedgetNumTemplateExpansions () const
 Retrieve the number of expansions that a template template argument expansion will produce, if known. More...
 
llvm::APSInt getAsIntegral () const
 Retrieve the template argument as an integral value. More...
 
QualType getIntegralType () const
 Retrieve the type of the integral value. More...
 
void setIntegralType (QualType T)
 
ExprgetAsExpr () const
 Retrieve the template argument as an expression. More...
 
pack_iterator pack_begin () const
 Iterator referencing the first argument of a template argument pack. More...
 
pack_iterator pack_end () const
 Iterator referencing one past the last argument of a template argument pack. More...
 
llvm::iterator_range
< pack_iterator
pack_elements () const
 Iterator range referencing all of the elements of a template argument pack. More...
 
unsigned pack_size () const
 The number of template arguments in the given template argument pack. More...
 
ArrayRef< TemplateArgumentgetPackAsArray () const
 Return the array of arguments in this template argument pack. More...
 
bool structurallyEquals (const TemplateArgument &Other) const
 Determines whether two template arguments are superficially the same. More...
 
TemplateArgument getPackExpansionPattern () const
 When the template argument is a pack expansion, returns the pattern of the pack expansion. More...
 
void print (const PrintingPolicy &Policy, raw_ostream &Out) const
 Print this template argument to the given output stream. More...
 
void Profile (llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
 Used to insert TemplateArguments into FoldingSets. More...
 

Static Public Member Functions

static TemplateArgument getEmptyPack ()
 
static TemplateArgument CreatePackCopy (ASTContext &Context, const TemplateArgument *Args, unsigned NumArgs)
 Create a new template argument pack by copying the given set of template arguments. More...
 

Detailed Description

Represents a template argument.

Definition at line 39 of file TemplateBase.h.

Member Typedef Documentation

Iterator that traverses the elements of a template argument pack.

Definition at line 313 of file TemplateBase.h.

Member Enumeration Documentation

The kind of template argument we're storing.

Enumerator
Null 

Represents an empty template argument, e.g., one that has not been deduced.

Type 

The template argument is a type.

Declaration 

The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.

NullPtr 

The template argument is a null pointer or null pointer to member that was provided for a non-type template parameter.

Integral 

The template argument is an integral value stored in an llvm::APSInt that was provided for an integral non-type template parameter.

Template 

The template argument is a template name that was provided for a template template parameter.

TemplateExpansion 

The template argument is a pack expansion of a template name that was provided for a template template parameter.

Expression 

The template argument is an expression, and we've not resolved it to one of the other forms yet, either because it's dependent or because we're representing a non-canonical template argument (for instance, in a TemplateSpecializationType). Also used to represent a non-dependent __uuidof expression (a Microsoft extension).

Pack 

The template argument is actually a parameter pack. Arguments are stored in the Args struct.

Definition at line 42 of file TemplateBase.h.

Constructor & Destructor Documentation

clang::TemplateArgument::TemplateArgument ( )
inline

Construct an empty, invalid template argument.

Definition at line 121 of file TemplateBase.h.

References Null, and TypeOrValue.

Referenced by CreatePackCopy(), getEmptyPack(), and getPackExpansionPattern().

clang::TemplateArgument::TemplateArgument ( QualType  T,
bool  isNullPtr = false 
)
inline

Construct a template type argument.

Definition at line 127 of file TemplateBase.h.

References clang::QualType::getAsOpaquePtr(), NullPtr, Type, and TypeOrValue.

clang::TemplateArgument::TemplateArgument ( ValueDecl D,
QualType  QT 
)
inline

Construct a template argument that refers to a declaration, which is either an external declaration or a template declaration.

Definition at line 135 of file TemplateBase.h.

References Declaration, DeclArg, and clang::QualType::getAsOpaquePtr().

TemplateArgument::TemplateArgument ( ASTContext Ctx,
const llvm::APSInt &  Value,
QualType  Type 
)

Construct an integral constant template argument. The memory to store the value is allocated with Ctx.

Definition at line 72 of file TemplateBase.cpp.

References clang::ASTContext::Allocate(), clang::QualType::getAsOpaquePtr(), Integer, and Integral.

clang::TemplateArgument::TemplateArgument ( const TemplateArgument Other,
QualType  Type 
)
inline

Construct an integral constant template argument with the same value as Other but a different type.

Definition at line 148 of file TemplateBase.h.

References clang::QualType::getAsOpaquePtr(), and Integer.

clang::TemplateArgument::TemplateArgument ( TemplateName  Name)
inline

Construct a template argument that is a template.

This form of template argument is generally used for template template parameters. However, the template name could be a dependent template name that ends up being instantiated to a function template whose address is taken.

Parameters
NameThe template name.

Definition at line 161 of file TemplateBase.h.

References clang::TemplateName::getAsVoidPointer(), Template, and TemplateArg.

clang::TemplateArgument::TemplateArgument ( TemplateName  Name,
Optional< unsigned NumExpansions 
)
inline

Construct a template argument that is a template pack expansion.

This form of template argument is generally used for template template parameters. However, the template name could be a dependent template name that ends up being instantiated to a function template whose address is taken.

Parameters
NameThe template name.
NumExpansionsThe number of expansions that will be generated by instantiating

Definition at line 178 of file TemplateBase.h.

References clang::TemplateName::getAsVoidPointer(), TemplateArg, and TemplateExpansion.

clang::TemplateArgument::TemplateArgument ( Expr E)
inline

Construct a template argument that is an expression.

This form of template argument only occurs in template argument lists used for dependent types and for expression; it will not occur in a non-dependent, canonical template argument list.

Definition at line 192 of file TemplateBase.h.

References Expression, and TypeOrValue.

clang::TemplateArgument::TemplateArgument ( const TemplateArgument Args,
unsigned  NumArgs 
)
inline

Construct a template argument that is a template argument pack.

We assume that storage for the template arguments provided outlives the TemplateArgument itself.

Definition at line 201 of file TemplateBase.h.

References Args, and Pack.

Member Function Documentation

bool TemplateArgument::containsUnexpandedParameterPack ( ) const
TemplateArgument TemplateArgument::CreatePackCopy ( ASTContext Context,
const TemplateArgument Args,
unsigned  NumArgs 
)
static

Create a new template argument pack by copying the given set of template arguments.

Definition at line 91 of file TemplateBase.cpp.

References Context, getEmptyPack(), and TemplateArgument().

Referenced by clang::Sema::CheckTemplateArgumentList(), ConvertDeducedTemplateArgument(), and GenerateInjectedTemplateArgs().

ValueDecl* clang::TemplateArgument::getAsDecl ( ) const
inline
Expr* clang::TemplateArgument::getAsExpr ( ) const
inline
llvm::APSInt clang::TemplateArgument::getAsIntegral ( ) const
inline
TemplateName clang::TemplateArgument::getAsTemplate ( ) const
inline
TemplateName clang::TemplateArgument::getAsTemplateOrTemplatePattern ( ) const
inline
QualType clang::TemplateArgument::getAsType ( ) const
inline
static TemplateArgument clang::TemplateArgument::getEmptyPack ( )
inlinestatic

Definition at line 207 of file TemplateBase.h.

References TemplateArgument().

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

QualType clang::TemplateArgument::getIntegralType ( ) const
inline
ArgKind clang::TemplateArgument::getKind ( ) const
inline

Return the kind of stored template argument.

Definition at line 218 of file TemplateBase.h.

References TypeOrValue.

Referenced by addAssociatedClassesAndNamespaces(), clang::ASTWriter::AddTemplateArgument(), clang::ASTWriter::AddTemplateArgumentLoc(), clang::Sema::BuildExpressionFromDeclTemplateArgument(), clang::Sema::BuildExpressionFromIntegralTemplateArgument(), checkDeducedTemplateArguments(), clang::Sema::CheckTemplateArgument(), clang::Sema::CheckTemplateTypeArgument(), containsUnexpandedParameterPack(), ConvertDeducedTemplateArgument(), DeduceTemplateArguments(), DiagnoseBadDeduction(), clang::comments::DeclInfo::fill(), getAsDecl(), getAsExpr(), getAsIntegral(), getAsTemplate(), getAsTemplateOrTemplatePattern(), getAsType(), clang::ASTContext::getCanonicalTemplateArgument(), getIntegralType(), clang::TemplateArgumentLoc::getLocation(), getNullPtrType(), getNumTemplateExpansions(), getPackAsArray(), getPackExpansionPattern(), getParamTypeForDecl(), clang::TemplateArgumentLoc::getSourceDeclExpression(), clang::TemplateArgumentLoc::getSourceExpression(), clang::TemplateArgumentLoc::getSourceIntegralExpression(), clang::TemplateArgumentLoc::getSourceNullPtrExpression(), clang::TemplateArgumentLoc::getSourceRange(), clang::Sema::getTemplateArgumentPackExpansionPattern(), clang::TemplateArgumentLoc::getTemplateEllipsisLoc(), clang::TemplateArgumentLoc::getTemplateNameLoc(), clang::TemplateArgumentLoc::getTemplateQualifierLoc(), getTrivialTemplateArgumentLoc(), clang::TemplateArgumentLoc::getTypeSourceInfo(), hasTemplateArgumentForDeduction(), clang::ASTNodeImporter::ImportTemplateArgument(), clang::TemplateSpecializationTypeLoc::initializeArgLocs(), clang::TreeTransform< Derived >::InventTemplateArgumentLoc(), isDependent(), isInstantiationDependent(), isNull(), isPackExpansion(), isSameAsPrimaryTemplate(), isSameTemplateArg(), IsStructurallyEquivalent(), isTemplateArgumentTemplateParameter(), MarkUsedTemplateParameters(), clang::operator<<(), pack_begin(), pack_end(), pack_size(), print(), Profile(), clang::ASTReader::ReadTemplateArgumentLoc(), clang::ASTReader::ReadTemplateName(), clang::TreeTransform< Derived >::RebuildPackExpansion(), setIntegralType(), structurallyEquals(), clang::Sema::SubstituteExplicitTemplateArguments(), clang::TemplateArgumentLoc::TemplateArgumentLoc(), clang::TreeTransform< Derived >::TransformTemplateArgument(), clang::TreeTransform< Derived >::TransformTemplateArguments(), clang::RecursiveASTVisitor< Derived >::TraverseTemplateArgument(), and clang::RecursiveASTVisitor< Derived >::TraverseTemplateArgumentLoc().

QualType clang::TemplateArgument::getNullPtrType ( ) const
inline
Optional< unsigned > TemplateArgument::getNumTemplateExpansions ( ) const

Retrieve the number of expansions that a template template argument expansion will produce, if known.

Definition at line 240 of file TemplateBase.cpp.

References getKind(), clang::None, TemplateArg, and TemplateExpansion.

Referenced by clang::ASTWriter::AddTemplateArgument(), clang::ASTContext::getCanonicalTemplateArgument(), clang::Sema::getTemplateArgumentPackExpansionPattern(), and clang::ASTNodeImporter::ImportTemplateArgument().

ArrayRef<TemplateArgument> clang::TemplateArgument::getPackAsArray ( ) const
inline

Return the array of arguments in this template argument pack.

Definition at line 343 of file TemplateBase.h.

References Args, getKind(), and Pack.

TemplateArgument TemplateArgument::getPackExpansionPattern ( ) const
QualType clang::TemplateArgument::getParamTypeForDecl ( ) const
inline
bool TemplateArgument::isDependent ( ) const

Whether this template argument is dependent on a template parameter such that its result can change from one instantiation to another.

Definition at line 102 of file TemplateBase.cpp.

References Declaration, Expression, getAsDecl(), getAsExpr(), getAsTemplate(), getAsType(), clang::Decl::getDeclContext(), getKind(), Integral, clang::TemplateName::isDependent(), clang::DeclContext::isDependentContext(), clang::Type::isDependentType(), Null, NullPtr, P, Pack, pack_elements(), Template, and TemplateExpansion.

bool TemplateArgument::isInstantiationDependent ( ) const
bool clang::TemplateArgument::isNull ( ) const
inline
bool TemplateArgument::isPackExpansion ( ) const
pack_iterator clang::TemplateArgument::pack_begin ( ) const
inline
llvm::iterator_range<pack_iterator> clang::TemplateArgument::pack_elements ( ) const
inline
pack_iterator clang::TemplateArgument::pack_end ( ) const
inline

Iterator referencing one past the last argument of a template argument pack.

Definition at line 324 of file TemplateBase.h.

References Args, getKind(), and Pack.

Referenced by checkDeducedTemplateArguments(), clang::ASTContext::getCanonicalTemplateArgument(), isSameTemplateArg(), pack_elements(), and clang::TreeTransform< Derived >::TransformTemplateArguments().

unsigned clang::TemplateArgument::pack_size ( ) const
inline
void TemplateArgument::print ( const PrintingPolicy Policy,
raw_ostream &  Out 
) const
void TemplateArgument::Profile ( llvm::FoldingSetNodeID &  ID,
const ASTContext Context 
) const
void clang::TemplateArgument::setIntegralType ( QualType  T)
inline

Definition at line 301 of file TemplateBase.h.

References clang::QualType::getAsOpaquePtr(), getKind(), Integer, and Integral.

bool TemplateArgument::structurallyEquals ( const TemplateArgument Other) const

Determines whether two template arguments are superficially the same.

Definition at line 301 of file TemplateBase.cpp.

References Args, Declaration, Expression, getAsDecl(), getAsIntegral(), getIntegralType(), getKind(), Integral, Null, NullPtr, Pack, Template, TemplateExpansion, and TypeOrValue.

Member Data Documentation

struct A clang::TemplateArgument::Args
struct DA clang::TemplateArgument::DeclArg

Definition at line 110 of file TemplateBase.h.

Referenced by getAsDecl(), getParamTypeForDecl(), and TemplateArgument().

struct I clang::TemplateArgument::Integer

Definition at line 111 of file TemplateBase.h.

Referenced by getAsIntegral(), getIntegralType(), setIntegralType(), and TemplateArgument().

struct TA clang::TemplateArgument::TemplateArg
struct TV clang::TemplateArgument::TypeOrValue

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