clang 20.0.0git
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 , AssumedTemplate , QualifiedTemplate ,
  DependentTemplate , SubstTemplateTemplateParm , SubstTemplateTemplateParmPack , UsingTemplate ,
  DeducedTemplate
}
 
enum class  Qualified { None , AsWritten }
 

Public Member Functions

 TemplateName ()=default
 
 TemplateName (TemplateDecl *Template)
 
 TemplateName (OverloadedTemplateStorage *Storage)
 
 TemplateName (AssumedTemplateStorage *Storage)
 
 TemplateName (SubstTemplateTemplateParmStorage *Storage)
 
 TemplateName (SubstTemplateTemplateParmPackStorage *Storage)
 
 TemplateName (QualifiedTemplateName *Qual)
 
 TemplateName (DependentTemplateName *Dep)
 
 TemplateName (UsingShadowDecl *Using)
 
 TemplateName (DeducedTemplateStorage *Deduced)
 
bool isNull () const
 Determine whether this template name is NULL.
 
NameKind getKind () const
 
TemplateDeclgetAsTemplateDecl (bool IgnoreDeduced=false) const
 Retrieve the underlying template declaration that this template name refers to, if known.
 
std::pair< TemplateDecl *, DefaultArgumentsgetTemplateDeclAndDefaultArgs () const
 Retrieves the underlying template declaration that this template name refers to, along with the deduced default arguments, if any.
 
OverloadedTemplateStoragegetAsOverloadedTemplate () const
 Retrieve the underlying, overloaded function template declarations that this template name refers to, if known.
 
AssumedTemplateStoragegetAsAssumedTemplateName () const
 Retrieve information on a name that has been assumed to be a template-name in order to permit a call via ADL.
 
SubstTemplateTemplateParmStoragegetAsSubstTemplateTemplateParm () const
 Retrieve the substituted template template parameter, if known.
 
SubstTemplateTemplateParmPackStoragegetAsSubstTemplateTemplateParmPack () const
 Retrieve the substituted template template parameter pack, if known.
 
QualifiedTemplateNamegetAsQualifiedTemplateName () const
 Retrieve the underlying qualified template name structure, if any.
 
DependentTemplateNamegetAsDependentTemplateName () const
 Retrieve the underlying dependent template name structure, if any.
 
UsingShadowDeclgetAsUsingShadowDecl () const
 Retrieve the using shadow declaration through which the underlying template declaration is introduced, if any.
 
DeducedTemplateStoragegetAsDeducedTemplateName () const
 Retrieve the deduced template info, if any.
 
std::optional< TemplateNamedesugar (bool IgnoreDeduced) const
 
TemplateName getUnderlying () const
 
TemplateNameDependence getDependence () const
 
bool isDependent () const
 Determines whether this is a dependent template name.
 
bool isInstantiationDependent () const
 Determines whether this is a template name that somehow depends on a template parameter.
 
bool containsUnexpandedParameterPack () const
 Determines whether this template name contains an unexpanded parameter pack (for C++0x variadic templates).
 
void print (raw_ostream &OS, const PrintingPolicy &Policy, Qualified Qual=Qualified::AsWritten) const
 Print the template name.
 
void dump (raw_ostream &OS, const ASTContext &Context) const
 Debugging aid that dumps the template name.
 
void dump () const
 Debugging aid that dumps the template name to standard error.
 
void Profile (llvm::FoldingSetNodeID &ID)
 
void * getAsVoidPointer () const
 Retrieve the template name as a void pointer.
 
bool operator== (TemplateName Other) const
 Structural equality.
 
bool operator!= (TemplateName Other) const
 

Static Public Member Functions

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

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;
#define X(type, name)
Definition: Value.h:144

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;
};
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.

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 a template instantiation, hence is represented as a dependent template name.

Definition at line 220 of file TemplateName.h.

Member Enumeration Documentation

◆ NameKind

Enumerator
Template 

A single template declaration.

OverloadedTemplate 

A set of overloaded template declarations.

AssumedTemplate 

An unqualified-id that has been assumed to name a function template that will be found by ADL.

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.

UsingTemplate 

A template name that refers to a template declaration found through a specific using shadow declaration.

DeducedTemplate 

A template name that refers to another TemplateName with deduced default arguments.

Definition at line 235 of file TemplateName.h.

◆ Qualified

enum class clang::TemplateName::Qualified
strong
Enumerator
None 
AsWritten 

Definition at line 364 of file TemplateName.h.

Constructor & Destructor Documentation

◆ TemplateName() [1/10]

clang::TemplateName::TemplateName ( )
default

Referenced by desugar().

◆ TemplateName() [2/10]

TemplateName::TemplateName ( TemplateDecl Template)
explicit

Definition at line