clang API Documentation

Classes | Public Types | Public Member Functions | Static Public Member Functions
clang::TemplateArgument Class Reference

Represents a template argument. More...

#include <TemplateBase.h>

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

List of all members.

Classes

struct  A
struct  DA
 The kind of template argument we're storing.
struct  I
struct  TA
struct  TV

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.

Public Member Functions

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

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.

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 57 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

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 76 of file TemplateBase.cpp.

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

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

llvm::APSInt clang::TemplateArgument::getAsIntegral ( ) 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().

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

Definition at line 225 of file TemplateBase.cpp.

References getKind(), TemplateArg, and TemplateExpansion.

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

Return the array of arguments in this template argument pack.

Definition at line 343 of file TemplateBase.h.

References Args, getKind(), and Pack.

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

Definition at line 87 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.

llvm::iterator_range<pack_iterator> clang::TemplateArgument::pack_elements ( ) 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().

void TemplateArgument::print ( const PrintingPolicy Policy,
raw_ostream &  Out 
) const
void TemplateArgument::Profile ( llvm::FoldingSetNodeID &  ID,
const ASTContext Context 
) const

Definition at line 301 of file TemplateBase.h.

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

Determines whether two template arguments are superficially the same.

Definition at line 286 of file TemplateBase.cpp.

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


Member Data Documentation

Definition at line 110 of file TemplateBase.h.

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

Definition at line 111 of file TemplateBase.h.

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


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