clang  6.0.0svn
Public Types | Public Member Functions | Static Public Member Functions | List of all members
clang::TemplateName Class Reference

Represents a C++ template name within the type system. More...

#include "clang/AST/TemplateName.h"

Public Types

enum  NameKind {
  Template, OverloadedTemplate, QualifiedTemplate, DependentTemplate,
  SubstTemplateTemplateParm, SubstTemplateTemplateParmPack
}
 

Public Member Functions

 TemplateName ()=default
 
 TemplateName (TemplateDecl *Template)
 
 TemplateName (OverloadedTemplateStorage *Storage)
 
 TemplateName (SubstTemplateTemplateParmStorage *Storage)
 
 TemplateName (SubstTemplateTemplateParmPackStorage *Storage)
 
 TemplateName (QualifiedTemplateName *Qual)
 
 TemplateName (DependentTemplateName *Dep)
 
bool isNull () const
 Determine whether this template name is NULL. More...
 
NameKind getKind () const
 
TemplateDeclgetAsTemplateDecl () const
 Retrieve the underlying template declaration that this template name refers to, if known. More...
 
OverloadedTemplateStoragegetAsOverloadedTemplate () const
 Retrieve the underlying, overloaded function template. More...
 
SubstTemplateTemplateParmStoragegetAsSubstTemplateTemplateParm () const
 Retrieve the substituted template template parameter, if known. More...
 
SubstTemplateTemplateParmPackStoragegetAsSubstTemplateTemplateParmPack () const
 Retrieve the substituted template template parameter pack, if known. More...
 
QualifiedTemplateNamegetAsQualifiedTemplateName () const
 Retrieve the underlying qualified template name structure, if any. More...
 
DependentTemplateNamegetAsDependentTemplateName () const
 Retrieve the underlying dependent template name structure, if any. More...
 
TemplateName getUnderlying () const
 
TemplateName getNameToSubstitute () const
 Get the template name to substitute when this template name is used as a template template argument. More...
 
bool isDependent () const
 Determines whether this is a dependent template name. More...
 
bool isInstantiationDependent () const
 Determines whether this is a template name that somehow depends on a template parameter. More...
 
bool containsUnexpandedParameterPack () const
 Determines whether this template name contains an unexpanded parameter pack (for C++0x variadic templates). More...
 
void print (raw_ostream &OS, const PrintingPolicy &Policy, bool SuppressNNS=false) const
 Print the template name. More...
 
void dump (raw_ostream &OS) const
 Debugging aid that dumps the template name. More...
 
void dump () const
 Debugging aid that dumps the template name to standard error. More...
 
void Profile (llvm::FoldingSetNodeID &ID)
 
void * getAsVoidPointer () const
 Retrieve the template name as a void pointer. More...
 

Static Public Member Functions

static TemplateName getFromVoidPointer (void *Ptr)
 Build a template name from a void pointer. More...
 

Detailed Description

Represents a C++ template name within the type system.

A C++ template name refers to a template within the C++ type system. In most cases, a template name is simply a reference to a class template, e.g.

template<typename T> class X { };
X<int> xi;

Here, the 'X' in X<int> is a template name that refers to the declaration of the class template X, above. Template names can also refer to function templates, C++0x template aliases, etc.

Some template names are dependent. For example, consider:

template<typename MetaFun, typename T1, typename T2> struct apply2 {
typedef typename MetaFun::template apply<T1, T2>::type type;
};

Here, "apply" is treated as a template name within the typename specifier in the typedef. "apply" is a nested template, and can only be understood in the context of

Definition at line 178 of file TemplateName.h.

Member Enumeration Documentation

◆ NameKind

Enumerator
Template 

A single template declaration.

OverloadedTemplate 

A set of overloaded template declarations.

QualifiedTemplate 

A qualified template name, where the qualification is kept to describe the source code as written.

DependentTemplate 

A dependent template name that has not been resolved to a template (or set of templates).

SubstTemplateTemplateParm 

A template template parameter that has been substituted for some other template name.

SubstTemplateTemplateParmPack 

A template template parameter pack that has been substituted for a template template argument pack, but has not yet been expanded into individual arguments.

Definition at line 189 of file TemplateName.h.

Constructor & Destructor Documentation

◆ TemplateName() [1/7]

clang::TemplateName::TemplateName ( )
default

Referenced by getNameToSubstitute().

◆ TemplateName() [2/7]

TemplateName::TemplateName ( TemplateDecl Template)
explicit

Definition at line 67 of file TemplateName.cpp.

◆ TemplateName() [3/7]

TemplateName::TemplateName ( OverloadedTemplateStorage Storage)
explicit

Definition at line 68 of file TemplateName.cpp.

◆ TemplateName() [4/7]

TemplateName::TemplateName ( SubstTemplateTemplateParmStorage Storage)
explicit

Definition at line 70 of file TemplateName.cpp.

◆ TemplateName() [5/7]

TemplateName::TemplateName ( SubstTemplateTemplateParmPackStorage Storage)
explicit

Definition at line 72 of file TemplateName.cpp.

◆ TemplateName() [6/7]

TemplateName::TemplateName ( QualifiedTemplateName Qual)
explicit

Definition at line 74 of file TemplateName.cpp.

◆ TemplateName() [7/7]

TemplateName::TemplateName ( DependentTemplateName Dep)
explicit

Definition at line 75 of file TemplateName.cpp.

Member Function Documentation

◆ containsUnexpandedParameterPack()

bool TemplateName::containsUnexpandedParameterPack ( ) const

Determines whether this template name contains an unexpanded parameter pack (for C++0x variadic templates).

Definition at line 187 of file TemplateName.cpp.

References getAsDependentTemplateName(), getAsSubstTemplateTemplateParmPack(), getAsTemplateDecl(), and Template.

Referenced by clang::Sema::ActOnPackExpansion(), clang::TemplateSpecializationType::anyDependentTemplateArguments(), and clang::Sema::DiagnoseUnexpandedParameterPack().

◆ dump() [1/2]

void TemplateName::dump ( raw_ostream &  OS) const

Debugging aid that dumps the template name.

Definition at line 249 of file TemplateName.cpp.

References print().

◆ dump() [2/2]

LLVM_DUMP_METHOD void TemplateName::dump ( ) const

Debugging aid that dumps the template name to standard error.

Definition at line 256 of file TemplateName.cpp.

◆ getAsDependentTemplateName()

DependentTemplateName * TemplateName::getAsDependentTemplateName ( ) const

◆ getAsOverloadedTemplate()

OverloadedTemplateStorage * TemplateName::getAsOverloadedTemplate ( ) const

Retrieve the underlying, overloaded function template.

Returns
The set of overloaded function templates that this template name refers to, if known. If the template name does not refer to a specific set of function templates because it is a dependent name or refers to a single template, returns NULL.

Definition at line 109 of file TemplateName.cpp.

References clang::UncommonTemplateNameStorage::getAsOverloadedStorage().

Referenced by clang::ASTImporter::Import(), isDependent(), and print().

◆ getAsQualifiedTemplateName()

QualifiedTemplateName * TemplateName::getAsQualifiedTemplateName ( ) const

◆ getAsSubstTemplateTemplateParm()

SubstTemplateTemplateParmStorage * TemplateName::getAsSubstTemplateTemplateParm ( ) const

Retrieve the substituted template template parameter, if known.

Returns
The storage for the substituted template template parameter, if known. Otherwise, returns NULL.

Definition at line 118 of file TemplateName.cpp.

References clang::UncommonTemplateNameStorage::getAsSubstTemplateTemplateParm().

Referenced by getAsTemplateDecl(), and print().

◆ getAsSubstTemplateTemplateParmPack()

SubstTemplateTemplateParmPackStorage * TemplateName::getAsSubstTemplateTemplateParmPack ( ) const

Retrieve the substituted template template parameter pack, if known.

Returns
The storage for the substituted template template parameter pack, if known. Otherwise, returns NULL.

Definition at line 127 of file TemplateName.cpp.

References clang::UncommonTemplateNameStorage::getAsSubstTemplateTemplateParmPack().

Referenced by containsUnexpandedParameterPack(), clang::Sema::getFullyPackExpandedSize(), and print().

◆ getAsTemplateDecl()

TemplateDecl * TemplateName::getAsTemplateDecl ( ) const

◆ getAsVoidPointer()

void* clang::TemplateName::getAsVoidPointer ( ) const
inline

◆ getFromVoidPointer()

static TemplateName clang::TemplateName::getFromVoidPointer ( void *  Ptr)
inlinestatic

Build a template name from a void pointer.

Definition at line 313 of file TemplateName.h.

References clang::operator<<().

Referenced by llvm::PointerLikeTypeTraits< clang::TemplateName >::getFromVoidPointer().

◆ getKind()

TemplateName::NameKind TemplateName::getKind ( ) const

◆ getNameToSubstitute()

TemplateName TemplateName::getNameToSubstitute ( ) const

Get the template name to substitute when this template name is used as a template template argument.

This refers to the most recent declaration of the template, including any default template arguments.

Definition at line 143 of file TemplateName.cpp.

References getAsTemplateDecl(), clang::Decl::getFriendObjectKind(), clang::NamedDecl::getMostRecentDecl(), clang::Decl::getPreviousDecl(), and TemplateName().

◆ getUnderlying()

TemplateName clang::TemplateName::getUnderlying ( ) const
inline

◆ isDependent()

bool TemplateName::isDependent ( ) const

Determines whether this is a dependent template name.

Definition at line 160 of file TemplateName.cpp.

References getAsOverloadedTemplate(), getAsTemplateDecl(), and Template.

Referenced by clang::TemplateArgument::isDependent(), and isInstantiationDependent().

◆ isInstantiationDependent()

bool TemplateName::isInstantiationDependent ( ) const

Determines whether this is a template name that somehow depends on a template parameter.

Definition at line 178 of file TemplateName.cpp.

References getAsQualifiedTemplateName(), and isDependent().

Referenced by clang::TemplateArgument::isInstantiationDependent().

◆ isNull()

bool TemplateName::isNull ( ) const

◆ print()

void TemplateName::print ( raw_ostream &  OS,
const PrintingPolicy Policy,
bool  SuppressNNS = false 
) const

Print the template name.

Parameters
OSthe output stream to which the template name will be printed.
SuppressNNSif true, don't print the nested-name-specifier that precedes the template name (if it has one).

Definition at line 204 of file TemplateName.cpp.

References clang::OverloadedTemplateStorage::begin(), getAsDependentTemplateName(), getAsOverloadedTemplate(), getAsQualifiedTemplateName(), getAsSubstTemplateTemplateParm(), getAsSubstTemplateTemplateParmPack(), clang::getOperatorSpelling(), and Template.

Referenced by dump(), clang::getParameterABISpelling(), clang::operator<<(), and clang::TemplateArgument::print().

◆ Profile()

void clang::TemplateName::Profile ( llvm::FoldingSetNodeID &  ID)
inline

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