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"
44 return cast<TemplateTemplateParmDecl>(
51 return cast<TemplateTemplateParmDecl>(
62 unsigned Index, std::optional<unsigned> PackIndex) {
64 ID.AddPointer(AssociatedDecl);
66 ID.AddInteger(PackIndex ? *PackIndex + 1 : 0);
74 Arguments(ArgPack.data()), AssociatedDeclAndFinal(AssociatedDecl, Final) {
75 assert(AssociatedDecl !=
nullptr);
85 return AssociatedDeclAndFinal.getPointer();
89 return AssociatedDeclAndFinal.getInt();
93 llvm::FoldingSetNodeID &ID,
ASTContext &Context,
97 ID.AddPointer(AssociatedDecl);
103 Storage = StorageType::getFromOpaqueValue(Ptr);
108 : Storage(Storage) {}
110 : Storage(Storage) {}
112 : Storage(Storage) {}
114 : Storage(Storage) {}
122 if (
auto *ND = Storage.dyn_cast<
Decl *>()) {
123 if (isa<UsingShadowDecl>(ND))
125 assert(isa<TemplateDecl>(ND));
146 if (
Decl *TemplateOrUsing = Storage.dyn_cast<
Decl *>()) {
148 return cast<TemplateDecl>(USD->getTargetDecl());
150 assert(isa<TemplateDecl>(TemplateOrUsing));
151 return cast<TemplateDecl>(TemplateOrUsing);
155 return QTN->getUnderlyingTemplate().getAsTemplateDecl();
158 return sub->getReplacement().getAsTemplateDecl();
161 return cast<TemplateDecl>(USD->getTargetDecl());
209 if (
Decl *D = Storage.dyn_cast<
Decl *>())
213 return QTN->getUnderlyingTemplate().getAsUsingShadowDecl();
229 assert(
Decl &&
"all declarations of template are friends");
235 auto D = TemplateNameDependence::None;
246 D |= TemplateNameDependence::UnexpandedPack;
249 llvm_unreachable(
"overloaded templates shouldn't survive to here.");
254 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template)) {
255 D |= TemplateNameDependence::DependentInstantiation;
256 if (TTP->isParameterPack())
257 D |= TemplateNameDependence::UnexpandedPack;
264 Template->getDeclContext()->isDependentContext())
265 D |= TemplateNameDependence::DependentInstantiation;
267 D |= TemplateNameDependence::DependentInstantiation;
277 return getDependence() & TemplateNameDependence::Instantiation;
281 return getDependence() & TemplateNameDependence::UnexpandedPack;
286 ID.AddPointer(USD->getCanonicalDecl());
288 ID.AddPointer(TD->getCanonicalDecl());
290 ID.AddPointer(Storage.getOpaqueValue());
313 OS <<
Template->getIdentifier()->deuglifiedName();
316 TemplateNameDependenceScope::DependentInstantiation)
317 Template->printQualifiedName(OS, Policy);
323 TemplateNameDependenceScope::DependentInstantiation) {
324 QTN->getUnderlyingTemplate().getAsTemplateDecl()->printQualifiedName(
329 QTN->getQualifier()->print(OS, Policy);
330 if (QTN->hasTemplateKeyword())
332 OS << *QTN->getUnderlyingTemplate().getAsTemplateDecl();
335 DTN->getQualifier()->print(OS, Policy);
338 if (DTN->isIdentifier())
339 OS << DTN->getIdentifier()->getName();
344 subst->getReplacement().print(OS, Policy, Qual);
347 OS << *SubstPack->getParameterPack();
349 Assumed->getDeclName().print(OS, Policy);
353 (*OTS->
begin())->printName(OS, Policy);
360 llvm::raw_string_ostream OS(NameStr);
368 return DB << NameStr;
Defines the Diagnostic-related interfaces.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::LangOptions interface.
Defines an enumeration for C++ overloaded operators.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A structure for storing the information associated with a name that has been assumed to be a template...
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
Represents a dependent template name that cannot be resolved prior to template instantiation.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
A structure for storing the information associated with an overloaded template name.
Represents a template name that was expressed as a qualified name.
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
A structure for storing an already-substituted template template parameter pack.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
void Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context)
TemplateTemplateParmDecl * getParameterPack() const
Retrieve the template template parameter pack being substituted.
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
SubstTemplateTemplateParmPackStorage(ArrayRef< TemplateArgument > ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final)
A structure for storing the information associated with a substituted template template parameter.
std::optional< unsigned > getPackIndex() const
void Profile(llvm::FoldingSetNodeID &ID)
TemplateTemplateParmDecl * getParameter() const
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
Represents a template argument.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
Used to insert TemplateArguments into FoldingSets.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateNameDependence getDependence() const
bool isNull() const
Determine whether this template name is NULL.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
void dump() const
Debugging aid that dumps the template name to standard error.
void Profile(llvm::FoldingSetNodeID &ID)
void print(raw_ostream &OS, const PrintingPolicy &Policy, Qualified Qual=Qualified::AsWritten) const
Print the template name.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
bool containsUnexpandedParameterPack() const
Determines whether this template name contains an unexpanded parameter pack (for C++0x variadic templ...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ Template
A single template declaration.
@ 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,...
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
UsingShadowDecl * getAsUsingShadowDecl() const
Retrieve the using shadow declaration through which the underlying template declaration is introduced...
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
bool isDependent() const
Determines whether this is a dependent template name.
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
bool isInstantiationDependent() const
Determines whether this is a template name that somehow depends on a template parameter.
TemplateName getNameToSubstitute() const
Get the template name to substitute when this template name is used as a template template argument.
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Implementation class used to describe either a set of overloaded template names or an already-substit...
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack()
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()
AssumedTemplateStorage * getAsAssumedTemplateName()
OverloadedTemplateStorage * getAsOverloadedStorage()
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
TemplateNameDependence toTemplateNameDependence(NestedNameSpecifierDependence D)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
TemplateParameterList * getReplacedTemplateParameterList(Decl *D)
Internal helper used by Subst* nodes to retrieve the parameter list for their AssociatedDecl.
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
Describes how types, statements, expressions, and declarations should be printed.
unsigned CleanUglifiedParameters
Whether to strip underscores when printing reserved parameter names.
unsigned Data
The pack index, or the number of stored templates or template arguments, depending on which subclass ...