clang 24.0.0git
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 , PackIndexingTemplate
}
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)
 TemplateName (PackIndexingTemplateStorage *PackIndexing)
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.
TemplateTemplateParmDeclgetAsTemplateTemplateParmDecl () const
 Retrieve the template template parameter that this template name refers to, if any.
std::pair< TemplateName, DefaultArgumentsgetTemplateDeclAndDefaultArgs () const
 Retrieves the underlying template name 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.
std::tuple< NestedNameSpecifier, boolgetQualifierAndTemplateKeyword () const
NestedNameSpecifier getQualifier () const
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.
PackIndexingTemplateStoragegetAsPackIndexingTemplate () const
 Retrieve the pack-index-template-name storage, 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).
bool isConceptName () const
 Determines whether this template name denotes a concept, or a template template parameter denoting one.
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:97

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 251 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.

PackIndexingTemplate 

A pack-index-template-name.

Definition at line 266 of file TemplateName.h.

◆ Qualified

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

Definition at line 418 of file TemplateName.h.

Constructor & Destructor Documentation

◆ TemplateName() [1/11]

◆ TemplateName() [2/11]

TemplateName::TemplateName ( TemplateDecl * Template)
explicit

Definition at line 240 of file TemplateName.cpp.

References Template.

◆ TemplateName() [3/11]

TemplateName::TemplateName ( OverloadedTemplateStorage * Storage)
explicit

Definition at line 241 of file TemplateName.cpp.

◆ TemplateName() [4/11]

TemplateName::TemplateName ( AssumedTemplateStorage * Storage)
explicit

Definition at line 243 of file TemplateName.cpp.

◆ TemplateName() [5/11]

TemplateName::TemplateName ( SubstTemplateTemplateParmStorage * Storage)
explicit

Definition at line 245 of file TemplateName.cpp.

◆ TemplateName() [6/11]

TemplateName::TemplateName ( SubstTemplateTemplateParmPackStorage * Storage)
explicit

Definition at line 247 of file TemplateName.cpp.

◆ TemplateName() [7/11]

TemplateName::TemplateName ( QualifiedTemplateName * Qual)
explicit

Definition at line 249 of file TemplateName.cpp.

◆ TemplateName() [8/11]

TemplateName::TemplateName ( DependentTemplateName * Dep)
explicit

Definition at line 250 of file TemplateName.cpp.

◆ TemplateName() [9/11]

TemplateName::TemplateName ( UsingShadowDecl * Using)
explicit

Definition at line 251 of file TemplateName.cpp.

◆ TemplateName() [10/11]

TemplateName::TemplateName ( DeducedTemplateStorage * Deduced)
explicit

Definition at line 252 of file TemplateName.cpp.

References clang::Deduced.

◆ TemplateName() [11/11]

TemplateName::TemplateName ( PackIndexingTemplateStorage * PackIndexing)
explicit

Definition at line 254 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 528 of file TemplateName.cpp.

References getDependence().

Referenced by clang::Sema::ActOnPackExpansion(), and clang::Sema::ActOnPackIndexingTemplateName().

◆ desugar()

◆ dump() [1/2]

LLVM_DUMP_METHOD void TemplateName::dump ( ) const

Debugging aid that dumps the template name to standard error.

Definition at line 379 of file ASTDumper.cpp.

References clang::ASTNodeTraverser< Derived, NodeDelegateType >::Visit().

◆ dump() [2/2]

void clang::TemplateName::dump ( raw_ostream & OS,
const ASTContext & Context ) const

Debugging aid that dumps the template name.

◆ getAsAssumedTemplateName()

AssumedTemplateStorage * TemplateName::getAsAssumedTemplateName ( ) const

Retrieve information on a name that has been assumed to be a template-name in order to permit a call via ADL.

Definition at line 363 of file TemplateName.cpp.

References clang::UncommonTemplateNameStorage::getAsAssumedTemplateName().

Referenced by clang::Sema::ActOnUndeclaredTypeTemplateName(), clang::ASTContext::getNameForTemplate(), clang::ASTImporter::Import(), IsStructurallyEquivalent(), print(), and TemplateName().

◆ getAsDeducedTemplateName()

◆ getAsDependentTemplateName()

◆ getAsOverloadedTemplate()

OverloadedTemplateStorage * TemplateName::getAsOverloadedTemplate ( ) const

Retrieve the underlying, overloaded function template declarations that this template name refers to, if known.

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 355 of file TemplateName.cpp.

References clang::UncommonTemplateNameStorage::getAsOverloadedStorage().

Referenced by clang::Sema::ActOnVarTemplateSpecialization(), clang::ASTContext::getNameForTemplate(), clang::ASTImporter::Import(), IsStructurallyEquivalent(), clang::Sema::NoteAllFoundTemplates(), print(), and TemplateName().

◆ getAsPackIndexingTemplate()

◆ getAsQualifiedTemplateName()

◆ 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 372 of file TemplateName.cpp.

References clang::UncommonTemplateNameStorage::getAsSubstTemplateTemplateParm().

Referenced by desugar(), clang::TextNodeDumper::dumpBareTemplateName(), getDependence(), clang::ASTContext::getNameForTemplate(), clang::ASTImporter::Import(), print(), TemplateName(), and clang::TreeTransform< Derived >::TransformTemplateName().

◆ 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 381 of file TemplateName.cpp.

References clang::UncommonTemplateNameStorage::getAsSubstTemplateTemplateParmPack().

Referenced by clang::ASTContext::getCanonicalTemplateName(), clang::Sema::getFullyPackExpandedSize(), clang::ASTContext::getNameForTemplate(), clang::ASTImporter::Import(), isConceptName(), IsStructurallyEquivalent(), print(), TemplateName(), and clang::TreeTransform< Derived >::TransformTemplateName().

◆ getAsTemplateDecl()

TemplateDecl * TemplateName::getAsTemplateDecl ( bool IgnoreDeduced = false) const

Retrieve the underlying template declaration that this template name refers to, if known.

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

Definition at line 289 of file TemplateName.cpp.

References desugar(), and getAsDeducedTemplateName().

Referenced by clang::Sema::ActOnClassTemplateSpecialization(), clang::Sema::ActOnExplicitInstantiation(), clang::Sema::ActOnTemplateTemplateArgument(), clang::Sema::ActOnTemplateTemplateParameter(), clang::Sema::ActOnVarTemplateSpecialization(), clang::ODRHash::AddTemplateName(), clang::Sema::BuildTypeConstraint(), clang::Sema::CheckConstraintSatisfaction(), clang::Sema::CheckDeductionGuideDeclarator(), clang::Sema::CheckTemplateIdType(), clang::Sema::CheckTypeConstraint(), DeduceTemplateSpecArguments(), clang::Sema::DeduceTemplateSpecializationFromInitializer(), DiagnoseBadDeduction(), clang::Sema::diagnoseMissingTemplateArguments(), clang::TextNodeDumper::dumpBareConcept(), clang::TextNodeDumper::dumpBareTemplateName(), formImmediatelyDeclaredConstraint(), getAsTemplateTemplateParmDecl(), clang::ASTContext::getCanonicalTemplateName(), GetDeclSpecTypeForDeclarator(), getDependence(), clang::TypeName::getFullyQualifiedTemplateName(), clang::ASTContext::getNameForTemplate(), clang::Sema::GetNameFromUnqualifiedId(), getNestedNameSpecifierIdentifiers(), clang::Sema::getTemplateNameKindForDiagnostics(), clang::ASTImporter::Import(), InventTemplateParameter(), isConceptName(), clang::isPackProducingBuiltinTemplateName(), clang::ASTContext::isSameTypeConstraint(), IsSmallVector(), IsStdVector(), IsStructurallyEquivalent(), isSubstitutedTemplateArgument(), isTemplateArgumentTemplateParameter(), MarkUsedTemplateParameters(), clang::Sema::MatchTemplateParametersToScopeSpecifier(), CXXNameMangler::TemplateArgManglingInfo::needToMangleTemplateParam(), clang::Sema::NoteAllFoundTemplates(), print(), clang::Sema::SubstConceptTemplateArguments(), CXXNameMangler::TemplateArgManglingInfo::TemplateArgManglingInfo(), TemplateName(), clang::TreeTransform< Derived >::TransformTemplateName(), clang::JSONNodeDumper::Visit(), and clang::ASTDeclReader::VisitFriendTemplateDecl().

◆ getAsTemplateTemplateParmDecl()

TemplateTemplateParmDecl * TemplateName::getAsTemplateTemplateParmDecl ( ) const

Retrieve the template template parameter that this template name refers to, if any.

Definition at line 304 of file TemplateName.cpp.

References getAsPackIndexingTemplate(), and getAsTemplateDecl().

Referenced by clang::Sema::ActOnPackIndexingTemplateName(), clang::Sema::CheckTypeConstraint(), and TemplateName().

◆ getAsUsingShadowDecl()

UsingShadowDecl * TemplateName::getAsUsingShadowDecl ( ) const

◆ getAsVoidPointer()

◆ getDependence()

◆ getFromVoidPointer()

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

◆ getKind()

◆ getQualifier()

NestedNameSpecifier clang::TemplateName::getQualifier ( ) const
inline

◆ getQualifierAndTemplateKeyword()

std::tuple< NestedNameSpecifier, bool > TemplateName::getQualifierAndTemplateKeyword ( ) const

Definition at line 398 of file TemplateName.cpp.

Referenced by getQualifier(), and TemplateName().

◆ getTemplateDeclAndDefaultArgs()

std::pair< TemplateName, DefaultArguments > TemplateName::getTemplateDeclAndDefaultArgs ( ) const

Retrieves the underlying template name that this template name refers to, along with the deduced default arguments, if any.

Definition at line 313 of file TemplateName.cpp.

References clang::DefaultArguments::Args, clang::UncommonTemplateNameStorage::getAsDeducedTemplateName(), and clang::DefaultArguments::StartPos.

Referenced by clang::Sema::CheckTemplateIdType(), clang::Sema::CheckTemplateTemplateArgument(), CXXNameMangler::TemplateArgManglingInfo::needToMangleTemplateParam(), and TemplateName().

◆ getUnderlying()

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

◆ isConceptName()

◆ isDependent()

◆ isInstantiationDependent()

bool TemplateName::isInstantiationDependent ( ) const

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

Definition at line 524 of file TemplateName.cpp.

References getDependence().

◆ isNull()

◆ operator!=()

bool clang::TemplateName::operator!= ( TemplateName Other) const
inline

Definition at line 451 of file TemplateName.h.

References operator==(), and clang::Other.

◆ operator==()

bool clang::TemplateName::operator== ( TemplateName Other) const
inline

Structural equality.

Definition at line 450 of file TemplateName.h.

References clang::Other.

Referenced by operator!=().

◆ print()

◆ Profile()

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

Definition at line 437 of file TemplateName.h.


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