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) {
63 Replacement.Profile(ID);
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();
218 auto D = TemplateNameDependence::None;
229 D |= TemplateNameDependence::UnexpandedPack;
232 llvm_unreachable(
"overloaded templates shouldn't survive to here.");
237 if (
auto *TTP = dyn_cast<TemplateTemplateParmDecl>(
Template)) {
238 D |= TemplateNameDependence::DependentInstantiation;
239 if (TTP->isParameterPack())
240 D |= TemplateNameDependence::UnexpandedPack;
247 Template->getDeclContext()->isDependentContext())
248 D |= TemplateNameDependence::DependentInstantiation;
250 D |= TemplateNameDependence::DependentInstantiation;
260 return getDependence() & TemplateNameDependence::Instantiation;
264 return getDependence() & TemplateNameDependence::UnexpandedPack;
269 auto handleAnonymousTTP = [](
TemplateDecl *TD, raw_ostream &OS) {
272 OS <<
"template-parameter-" << TTP->getDepth() <<
"-" << TTP->getIndex();
289 if (handleAnonymousTTP(
Template, OS))
294 Template->printQualifiedName(OS, Policy);
298 NNS->print(OS, Policy);
299 if (QTN->hasTemplateKeyword())
308 if (handleAnonymousTTP(UTD, OS))
313 isa<TemplateTemplateParmDecl>(UTD))
314 OS << II->deuglifiedName();
319 NNS->
print(OS, Policy);
322 if (DTN->isIdentifier())
323 OS << DTN->getIdentifier()->getName();
328 subst->getReplacement().print(OS, Policy, Qual);
331 OS << *SubstPack->getParameterPack();
333 Assumed->getDeclName().print(OS, Policy);
337 (*OTS->
begin())->printName(OS, Policy);
344 llvm::raw_string_ostream OS(NameStr);
352 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.
void print(raw_ostream &Out, unsigned Indentation=0, bool PrintInstantiation=false) const
Represents a dependent template name that cannot be resolved prior to template instantiation.
One of these records is kept for each identifier that is lexed.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
A structure for storing the information associated with an overloaded template name.
Represents a template name as written in source code.
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 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.
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 ...
The JSON file list parser is used to communicate input to InstallAPI.
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 ...