clang 20.0.0git
|
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 |
TemplateDecl * | getAsTemplateDecl (bool IgnoreDeduced=false) const |
Retrieve the underlying template declaration that this template name refers to, if known. | |
std::pair< TemplateDecl *, DefaultArguments > | getTemplateDeclAndDefaultArgs () const |
Retrieves the underlying template declaration that this template name refers to, along with the deduced default arguments, if any. | |
OverloadedTemplateStorage * | getAsOverloadedTemplate () const |
Retrieve the underlying, overloaded function template declarations that this template name refers to, if known. | |
AssumedTemplateStorage * | getAsAssumedTemplateName () const |
Retrieve information on a name that has been assumed to be a template-name in order to permit a call via ADL. | |
SubstTemplateTemplateParmStorage * | getAsSubstTemplateTemplateParm () const |
Retrieve the substituted template template parameter, if known. | |
SubstTemplateTemplateParmPackStorage * | getAsSubstTemplateTemplateParmPack () const |
Retrieve the substituted template template parameter pack, if known. | |
QualifiedTemplateName * | getAsQualifiedTemplateName () const |
Retrieve the underlying qualified template name structure, if any. | |
DependentTemplateName * | getAsDependentTemplateName () const |
Retrieve the underlying dependent template name structure, if any. | |
UsingShadowDecl * | getAsUsingShadowDecl () const |
Retrieve the using shadow declaration through which the underlying template declaration is introduced, if any. | |
DeducedTemplateStorage * | getAsDeducedTemplateName () const |
Retrieve the deduced template info, if any. | |
std::optional< TemplateName > | desugar (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. | |
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.
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:
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.
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.
|
strong |
Enumerator | |
---|---|
None | |
AsWritten |
Definition at line 364 of file TemplateName.h.
|
default |
Referenced by desugar().
|
explicit |
Definition at line 129 of file TemplateName.cpp.
|
explicit |
Definition at line 130 of file TemplateName.cpp.
|
explicit |
Definition at line 132 of file TemplateName.cpp.
|
explicit |
Definition at line 134 of file TemplateName.cpp.
|
explicit |
Definition at line 136 of file TemplateName.cpp.
|
explicit |
Definition at line 138 of file TemplateName.cpp.
|
explicit |
Definition at line 139 of file TemplateName.cpp.
|
explicit |
Definition at line 140 of file TemplateName.cpp.
|
explicit |
Definition at line 141 of file TemplateName.cpp.
bool TemplateName::containsUnexpandedParameterPack | ( | ) | const |
Determines whether this template name contains an unexpanded parameter pack (for C++0x variadic templates).
Definition at line 348 of file TemplateName.cpp.
References getDependence().
Referenced by clang::Sema::ActOnPackExpansion(), and clang::Sema::DiagnoseUnexpandedParameterPack().
std::optional< TemplateName > TemplateName::desugar | ( | bool | IgnoreDeduced | ) | const |
Definition at line 210 of file TemplateName.cpp.
References D, getAsDeducedTemplateName(), getAsQualifiedTemplateName(), getAsSubstTemplateTemplateParm(), and TemplateName().
LLVM_DUMP_METHOD void TemplateName::dump | ( | ) | const |
Debugging aid that dumps the template name to standard error.
Definition at line 370 of file ASTDumper.cpp.
References clang::ASTNodeTraverser< Derived, NodeDelegateType >::Visit().
void clang::TemplateName::dump | ( | raw_ostream & | OS, |
const ASTContext & | Context | ||
) | const |
Debugging aid that dumps the template name.
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 234 of file TemplateName.cpp.
References clang::UncommonTemplateNameStorage::getAsAssumedTemplateName().
Referenced by clang::Sema::ActOnCXXNestedNameSpecifier(), clang::Sema::ActOnTemplateIdType(), clang::ASTImporter::Import(), IsStructurallyEquivalent(), and print().
DeducedTemplateStorage * TemplateName::getAsDeducedTemplateName | ( | ) | const |
Retrieve the deduced template info, if any.
Definition at line 277 of file TemplateName.cpp.
References clang::UncommonTemplateNameStorage::getAsDeducedTemplateName().
Referenced by desugar(), clang::TextNodeDumper::dumpBareTemplateName(), getDependence(), and print().
DependentTemplateName * TemplateName::getAsDependentTemplateName | ( | ) | const |
Retrieve the underlying dependent template name structure, if any.
Definition at line 264 of file TemplateName.cpp.
Referenced by clang::Sema::ActOnCXXNestedNameSpecifier(), clang::Sema::ActOnTagTemplateIdType(), clang::Sema::ActOnTemplateIdType(), clang::Sema::ActOnTypenameType(), clang::Sema::CheckTemplateArgument(), clang::TextNodeDumper::dumpBareTemplateName(), clang::ASTContext::getCanonicalTemplateSpecializationType(), getDependence(), clang::ASTContext::getTemplateSpecializationType(), clang::Sema::getTrivialTemplateArgumentLoc(), clang::ASTImporter::Import(), clang::TemplateSpecializationTypeLoc::initializeArgLocs(), IsStructurallyEquivalent(), print(), clang::TreeTransform< Derived >::RebuildDependentTemplateSpecializationType(), clang::TreeTransform< Derived >::TransformDependentTemplateSpecializationType(), and clang::RecursiveASTVisitor< Derived >::TraverseTemplateName().
OverloadedTemplateStorage * TemplateName::getAsOverloadedTemplate | ( | ) | const |
Retrieve the underlying, overloaded function template declarations that this template name refers to, if known.
Definition at line 226 of file TemplateName.cpp.
References clang::UncommonTemplateNameStorage::getAsOverloadedStorage().
Referenced by clang::Sema::ActOnCXXNestedNameSpecifier(), clang::ASTImporter::Import(), IsStructurallyEquivalent(), print(), and clang::SemaCodeCompletion::ProduceTemplateArgumentSignatureHelp().
QualifiedTemplateName * TemplateName::getAsQualifiedTemplateName | ( | ) | const |
Retrieve the underlying qualified template name structure, if any.
Definition at line 260 of file TemplateName.cpp.
Referenced by clang::Sema::CheckDeductionGuideDeclarator(), desugar(), clang::TextNodeDumper::dumpBareTemplateName(), getAsUsingShadowDecl(), getDependence(), clang::TypeName::getFullyQualifiedTemplateName(), clang::Sema::getTrivialTemplateArgumentLoc(), clang::ASTImporter::Import(), clang::TemplateSpecializationTypeLoc::initializeArgLocs(), print(), and clang::RecursiveASTVisitor< Derived >::TraverseTemplateName().
SubstTemplateTemplateParmStorage * TemplateName::getAsSubstTemplateTemplateParm | ( | ) | const |
Retrieve the substituted template template parameter, if known.
Definition at line 243 of file TemplateName.cpp.
References clang::UncommonTemplateNameStorage::getAsSubstTemplateTemplateParm().
Referenced by desugar(), clang::TextNodeDumper::dumpBareTemplateName(), getDependence(), clang::ASTImporter::Import(), and print().
SubstTemplateTemplateParmPackStorage * TemplateName::getAsSubstTemplateTemplateParmPack | ( | ) | const |
Retrieve the substituted template template parameter pack, if known.
Definition at line 252 of file TemplateName.cpp.
References clang::UncommonTemplateNameStorage::getAsSubstTemplateTemplateParmPack().
Referenced by clang::Sema::getFullyPackExpandedSize(), clang::ASTImporter::Import(), IsStructurallyEquivalent(), and print().
TemplateDecl * TemplateName::getAsTemplateDecl | ( | bool | IgnoreDeduced = false | ) | const |
Retrieve the underlying template declaration that this template name refers to, if known.
Definition at line 174 of file TemplateName.cpp.
Referenced by clang::Sema::ActOnCXXNestedNameSpecifier(), clang::Sema::ActOnTagTemplateIdType(), addAssociatedClassesAndNamespaces(), clang::Sema::BuildTypeConstraint(), clang::Sema::CheckDeductionGuideDeclarator(), clang::Sema::CheckTypeConstraint(), DeduceTemplateArguments(), DeduceTemplateSpecArguments(), clang::Sema::DeduceTemplateSpecializationFromInitializer(), DiagnoseBadDeduction(), clang::TextNodeDumper::dumpBareTemplateName(), findOrdinaryMemberInDependentClasses(), clang::ASTContext::getCanonicalTemplateName(), GetDeclSpecTypeForDeclarator(), getDependence(), clang::TypeName::getFullyQualifiedTemplateName(), clang::Sema::GetNameFromUnqualifiedId(), getTemplateDeclAndDefaultArgs(), clang::ASTContext::getTemplateSpecializationType(), clang::ASTImporter::Import(), InventTemplateParameter(), isEnableIf(), IsSmallVector(), clang::Sema::isStdInitializerList(), IsStdVector(), IsStructurallyEquivalent(), isSubstitutedTemplateArgument(), isTemplateArgumentTemplateParameter(), CXXNameMangler::TemplateArgManglingInfo::needToMangleTemplateParam(), print(), clang::SemaCodeCompletion::ProduceTemplateArgumentSignatureHelp(), and CXXNameMangler::TemplateArgManglingInfo::TemplateArgManglingInfo().
UsingShadowDecl * TemplateName::getAsUsingShadowDecl | ( | ) | const |
Retrieve the using shadow declaration through which the underlying template declaration is introduced, if any.
Definition at line 268 of file TemplateName.cpp.
References D, and getAsQualifiedTemplateName().
Referenced by clang::Sema::BuildTypeConstraint(), clang::TextNodeDumper::dumpBareTemplateName(), clang::TypeName::getFullyQualifiedTemplateName(), clang::ASTImporter::Import(), and InventTemplateParameter().
|
inline |
Retrieve the template name as a void pointer.
Definition at line 388 of file TemplateName.h.
Referenced by llvm::PointerLikeTypeTraits< clang::TemplateName >::getAsVoidPointer(), getCommonSugarTypeNode(), getCommonTemplateArgument(), getCommonTemplateName(), getCommonTemplateNameChecked(), isSameTemplateArg(), and clang::QualifiedTemplateName::Profile().
TemplateNameDependence TemplateName::getDependence | ( | ) | const |
Definition at line 285 of file TemplateName.cpp.
References clang::DefaultArguments::Args, AssumedTemplate, D, DeducedTemplate, DependentTemplate, getAsDeducedTemplateName(), getAsDependentTemplateName(), getAsQualifiedTemplateName(), getAsSubstTemplateTemplateParm(), getAsTemplateDecl(), clang::DeducedTemplateStorage::getDefaultArguments(), getDependence(), getKind(), clang::DeducedTemplateStorage::getUnderlying(), OverloadedTemplate, QualifiedTemplate, SubstTemplateTemplateParm, SubstTemplateTemplateParmPack, Template, clang::toTemplateNameDependence(), and UsingTemplate.
Referenced by containsUnexpandedParameterPack(), getDependence(), isDependent(), and isInstantiationDependent().
|
inlinestatic |
Build a template name from a void pointer.
Definition at line 391 of file TemplateName.h.
Referenced by clang::TemplateArgument::getAsTemplate(), clang::TemplateArgument::getAsTemplateOrTemplatePattern(), and llvm::PointerLikeTypeTraits< clang::TemplateName >::getFromVoidPointer().
TemplateName::NameKind TemplateName::getKind | ( | ) | const |
Definition at line 146 of file TemplateName.cpp.
References AssumedTemplate, DeducedTemplate, DependentTemplate, clang::UncommonTemplateNameStorage::getAsAssumedTemplateName(), clang::UncommonTemplateNameStorage::getAsDeducedTemplateName(), clang::UncommonTemplateNameStorage::getAsOverloadedStorage(), clang::UncommonTemplateNameStorage::getAsSubstTemplateTemplateParm(), clang::UncommonTemplateNameStorage::getAsSubstTemplateTemplateParmPack(), OverloadedTemplate, QualifiedTemplate, SubstTemplateTemplateParm, SubstTemplateTemplateParmPack, Template, and UsingTemplate.
Referenced by DiagnoseBadDeduction(), clang::TextNodeDumper::dumpBareTemplateName(), getDependence(), clang::ASTContext::getQualifiedTemplateName(), clang::ASTImporter::Import(), IsStructurallyEquivalent(), and print().
std::pair< TemplateDecl *, DefaultArguments > TemplateName::getTemplateDeclAndDefaultArgs | ( | ) | const |
Retrieves the underlying template declaration that this template name refers to, along with the deduced default arguments, if any.
Definition at line 189 of file TemplateName.cpp.
References clang::DefaultArguments::Args, DeducedTemplate, getAsTemplateDecl(), clang::DeducedTemplateStorage::getDefaultArguments(), clang::TemplateDecl::getTemplateParameters(), clang::DeducedTemplateStorage::getUnderlying(), clang::TemplateParameterList::size(), and clang::DefaultArguments::StartPos.
Referenced by CXXNameMangler::TemplateArgManglingInfo::needToMangleTemplateParam().
|
inline |
Definition at line 472 of file TemplateName.h.
References clang::UncommonTemplateNameStorage::getAsSubstTemplateTemplateParm(), and getUnderlying().
Referenced by getUnderlying().
bool TemplateName::isDependent | ( | ) | const |
Determines whether this is a dependent template name.
Definition at line 340 of file TemplateName.cpp.
References getDependence().
Referenced by clang::Sema::DeduceTemplateSpecializationFromInitializer(), and clang::DeducedTemplateSpecializationType::Profile().
bool TemplateName::isInstantiationDependent | ( | ) | const |
Determines whether this is a template name that somehow depends on a template parameter.
Definition at line 344 of file TemplateName.cpp.
References getDependence().
bool TemplateName::isNull | ( | ) | const |
Determine whether this template name is NULL.
Definition at line 144 of file TemplateName.cpp.
Referenced by clang::Sema::ActOnTemplateTemplateParameter(), clang::Sema::DiagnoseUnexpandedParameterPack(), clang::TreeTransform< Derived >::RebuildDependentTemplateSpecializationType(), clang::Sema::SubstDefaultTemplateArgumentIfAvailable(), clang::TreeTransform< Derived >::TransformTemplateArgument(), and clang::TreeTransform< Derived >::TransformTemplateSpecializationType().
|
inline |
Definition at line 397 of file TemplateName.h.
References clang::operator==(), and clang::Other.
|
inline |
void TemplateName::print | ( | raw_ostream & | OS, |
const PrintingPolicy & | Policy, | ||
Qualified | Qual = Qualified::AsWritten |
||
) | const |
Print the template name.
OS | the output stream to which the template name will be printed. |
Qual | print the (Qualified::None) simple name, (Qualified::AsWritten) any written (possibly partial) qualifier, or (Qualified::Fully) the fully qualified name. |
Definition at line 352 of file TemplateName.cpp.
References clang::DefaultArguments::Args, clang::OverloadedTemplateStorage::begin(), clang::PrintingPolicy::CleanUglifiedParameters, getAsAssumedTemplateName(), getAsDeducedTemplateName(), getAsDependentTemplateName(), getAsOverloadedTemplate(), getAsQualifiedTemplateName(), getAsSubstTemplateTemplateParm(), getAsSubstTemplateTemplateParmPack(), getAsTemplateDecl(), clang::NamedDecl::getIdentifier(), getKind(), clang::getOperatorSpelling(), None, OverloadedTemplate, clang::Decl::print(), clang::printTemplateArgumentList(), clang::DefaultArguments::StartPos, Template, and UsingTemplate.
Referenced by clang::TextNodeDumper::dumpTemplateName(), clang::operator<<(), clang::TemplateArgument::print(), and clang::JSONNodeDumper::VisitTemplateSpecializationType().
|
inline |
Definition at line 383 of file TemplateName.h.
References ID.
Referenced by clang::DeducedTemplateStorage::Profile(), and clang::DeducedTemplateSpecializationType::Profile().