Go to the documentation of this file.
26 #include "llvm/ADT/ArrayRef.h"
27 #include "llvm/ADT/FoldingSet.h"
28 #include "llvm/Support/Casting.h"
29 #include "llvm/Support/Compiler.h"
30 #include "llvm/Support/raw_ostream.h"
34 using namespace clang;
48 ID.AddPointer(parameter);
66 Storage = StorageType::getFromOpaqueValue(Ptr);
85 if (
auto *ND = Storage.dyn_cast<
Decl *>()) {
86 if (isa<UsingShadowDecl>(ND))
88 assert(isa<TemplateDecl>(ND));
109 if (
Decl *TemplateOrUsing = Storage.dyn_cast<
Decl *>()) {
111 return cast<TemplateDecl>(USD->getTargetDecl());
113 assert(isa<TemplateDecl>(TemplateOrUsing));
114 return cast<TemplateDecl>(TemplateOrUsing);
118 return QTN->getUnderlyingTemplate().getAsTemplateDecl();
121 return sub->getReplacement().getAsTemplateDecl();
124 return cast<TemplateDecl>(USD->getTargetDecl());
172 if (
Decl *D = Storage.dyn_cast<
Decl *>())
176 return QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
192 assert(
Decl &&
"all declarations of template are friends");
200 case TemplateName::NameKind::QualifiedTemplate:
204 case TemplateName::NameKind::DependentTemplate:
208 case TemplateName::NameKind::SubstTemplateTemplateParmPack:
209 D |= TemplateNameDependence::UnexpandedPack;
211 case TemplateName::NameKind::OverloadedTemplate:
212 llvm_unreachable(
"overloaded templates shouldn't survive to here.");
217 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template)) {
218 D |= TemplateNameDependence::DependentInstantiation;
219 if (TTP->isParameterPack())
220 D |= TemplateNameDependence::UnexpandedPack;
227 Template->getDeclContext()->isDependentContext())
228 D |= TemplateNameDependence::DependentInstantiation;
230 D |= TemplateNameDependence::DependentInstantiation;
240 return getDependence() & TemplateNameDependence::Instantiation;
244 return getDependence() & TemplateNameDependence::UnexpandedPack;
267 OS <<
Template->getIdentifier()->deuglifiedName();
270 TemplateNameDependenceScope::DependentInstantiation)
271 Template->printQualifiedName(OS, Policy);
277 TemplateNameDependenceScope::DependentInstantiation) {
278 QTN->getUnderlyingTemplate().getAsTemplateDecl()->printQualifiedName(
283 QTN->getQualifier()->print(OS, Policy);
284 if (QTN->hasTemplateKeyword())
286 OS << *QTN->getUnderlyingTemplate().getAsTemplateDecl();
289 DTN->getQualifier()->print(OS, Policy);
292 if (DTN->isIdentifier())
293 OS << DTN->getIdentifier()->getName();
298 subst->getReplacement().print(OS, Policy, Qual);
301 OS << *SubstPack->getParameterPack();
303 Assumed->getDeclName().print(OS, Policy);
307 (*OTS->
begin())->printName(OS);
314 llvm::raw_string_ostream OS(NameStr);
322 return DB << NameStr;
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
bool isInstantiationDependent() const
Determines whether this is a template name that somehow depends on a template parameter.
unsigned CleanUglifiedParameters
Whether to strip underscores when printing reserved parameter names.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
@ Parameter
The parameter type of a method or function.
bool containsUnexpandedParameterPack() const
Determines whether this template name contains an unexpanded parameter pack (for C++0x variadic templ...
AssumedTemplateStorage * getAsAssumedTemplateName()
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
Used to insert TemplateArguments into FoldingSets.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
TemplateNameDependence toTemplateNameDependence(NestedNameSpecifierDependence D)
A structure for storing the information associated with an overloaded template name.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
TemplateNameDependence getDependence() const
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
Describes how types, statements, expressions, and declarations should be printed.
OverloadedTemplateStorage * getAsOverloadedStorage()
TemplateName getNameToSubstitute() const
Get the template name to substitute when this template name is used as a template template argument.
bool isDependent() const
Determines whether this is a dependent template name.
constexpr XRayInstrMask None
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
Represents a template argument.
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
@ Template
A single template declaration.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
A structure for storing an already-substituted template template parameter pack.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
bool isNull() const
Determine whether this template name is NULL.
Implementation class used to describe either a set of overloaded template names or an already-substit...
Represents a dependent template name that cannot be resolved prior to template instantiation.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
Represents a C++ template name within the type system.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Decl - This represents one declaration (or definition), e.g.
void dump() const
Debugging aid that dumps the template name to standard error.
Represents a template name that was expressed as a qualified name.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack()
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
void print(raw_ostream &OS, const PrintingPolicy &Policy, Qualified Qual=Qualified::AsWritten) const
Print the template name.
A structure for storing the information associated with a substituted template template parameter.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context)
@ OverloadedTemplate
A set of overloaded template declarations.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()
void Profile(llvm::FoldingSetNodeID &ID)
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
A structure for storing the information associated with a name that has been assumed to be a template...
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...