13#ifndef LLVM_CLANG_AST_TEMPLATENAME_H
14#define LLVM_CLANG_AST_TEMPLATENAME_H
21#include "llvm/ADT/FoldingSet.h"
22#include "llvm/ADT/PointerIntPair.h"
23#include "llvm/ADT/PointerUnion.h"
24#include "llvm/Support/PointerLikeTypeTraits.h"
25#include "llvm/Support/TrailingObjects.h"
85 LLVM_PREFERRED_TYPE(
Kind)
150 OverloadedTemplateStorage(
unsigned size)
154 return reinterpret_cast<NamedDecl **
>(
this + 1);
157 return reinterpret_cast<NamedDecl *
const *
>(
this + 1);
180 public llvm::FoldingSetNode {
182 llvm::PointerIntPair<Decl *, 1, bool> AssociatedDeclAndFinal;
186 Decl *AssociatedDecl,
unsigned Index,
198 bool getFinal()
const;
207 void Profile(llvm::FoldingSetNodeID &ID,
ASTContext &Context);
209 static void Profile(llvm::FoldingSetNodeID &ID,
ASTContext &Context,
211 unsigned Index,
bool Final);
262 explicit TemplateName(
void *Ptr);
340 std::pair<TemplateName, DefaultArguments>
397 std::optional<TemplateName> desugar(
bool IgnoreDeduced)
const;
401 TemplateNameDependence getDependence()
const;
404 bool isDependent()
const;
408 bool isInstantiationDependent()
const;
412 bool containsUnexpandedParameterPack()
const;
416 bool isConceptName()
const;
428 Qualified Qual = Qualified::AsWritten)
const;
438 ID.AddPointer(Storage.getOpaqueValue());
446 return TemplateName(Ptr);
456const StreamingDiagnostic &
operator<<(
const StreamingDiagnostic &DB,
461class SubstTemplateTemplateParmStorage
466 Decl *AssociatedDecl;
468 SubstTemplateTemplateParmStorage(
TemplateName Replacement,
469 Decl *AssociatedDecl,
unsigned Index,
473 ((
PackIndex.toInternalRepresentation()) << 1) | Final),
474 Replacement(Replacement), AssociatedDecl(AssociatedDecl) {
475 assert(AssociatedDecl !=
nullptr);
498 void Profile(llvm::FoldingSetNodeID &ID);
500 static void Profile(llvm::FoldingSetNodeID &ID,
TemplateName Replacement,
501 Decl *AssociatedDecl,
unsigned Index,
506 public llvm::FoldingSetNode {
523 void Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context)
const;
525 static void Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context,
534class PackIndexingTemplateStorage final
536 public llvm::FoldingSetNode,
537 private llvm::TrailingObjects<PackIndexingTemplateStorage, TemplateName> {
539 friend TrailingObjects;
542 llvm::PointerIntPair<Expr *, 1> IndexAndIsFullySubstituted;
545 bool FullySubstituted,
549 std::size_t getExpansionCount()
const {
return Bits.Data; }
557 return IndexAndIsFullySubstituted.getInt();
561 return getTrailingObjects(getExpansionCount());
574 TemplateNameDependence getDependence()
const;
576 void Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context)
const;
578 static void Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context,
602class QualifiedTemplateName :
public llvm::FoldingSetNode {
612 llvm::PointerIntPair<NestedNameSpecifier, 1, bool> Qualifier;
623 : Qualifier(NNS, TemplateKeyword ? 1 : 0), UnderlyingTemplate(
Template) {
646 ID.AddBoolean(TemplateKeyword);
670 void Profile(llvm::FoldingSetNodeID &ID)
const;
673 return PtrOrOp ==
Other.PtrOrOp;
694 llvm::PointerIntPair<NestedNameSpecifier, 1, bool> Qualifier;
702 bool HasTemplateKeyword);
712 TemplateNameDependence getDependence()
const;
714 void Profile(llvm::FoldingSetNodeID &ID)
const {
720 bool HasTemplateKeyword) {
722 ID.AddBoolean(HasTemplateKeyword);
729class DependentTemplateName :
public DependentTemplateStorage,
730 public llvm::FoldingSetNode {
733 DependentTemplateName(
const DependentTemplateStorage &S)
734 : DependentTemplateStorage(S) {}
static llvm::GlobalValue::DLLStorageClassTypes getStorage(CodeGenModule &CGM, StringRef Name)
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
static Decl::Kind getKind(const Decl *D)
static void print(llvm::raw_ostream &OS, const T &V, const Context &Ctx, QualType Ty)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines an enumeration for C++ overloaded operators.
Defines clang::OptionalUnsigned.
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.
TemplateName getUnderlying() const
DefaultArguments getDefaultArguments() const
void Profile(llvm::FoldingSetNodeID &ID) const
IdentifierOrOverloadedOperator getName() const
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
DependentTemplateStorage(NestedNameSpecifier Qualifier, IdentifierOrOverloadedOperator Name, bool HasTemplateKeyword)
static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier NNS, IdentifierOrOverloadedOperator Name, bool HasTemplateKeyword)
bool hasTemplateKeyword() const
Was this template name was preceeded by the template keyword?
This represents one expression.
One of these records is kept for each identifier that is lexed.
This represents a decl that may have a name.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void Profile(llvm::FoldingSetNodeID &ID) const
A structure for storing the information associated with an overloaded template name.
llvm::ArrayRef< NamedDecl * > decls() const
NamedDecl *const * iterator
A structure for storing a pack-index-template-name ([temp.names]).
bool isFullySubstituted() const
TemplateName getPattern() const
Expr * getIndexExpr() const
bool expandsToEmptyPack() const
ArrayRef< TemplateName > getExpansions() const
Represents a template name as written in source code.
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
static void Profile(llvm::FoldingSetNodeID &ID, NestedNameSpecifier NNS, bool TemplateKeyword, TemplateName TN)
void Profile(llvm::FoldingSetNodeID &ID)
TemplateName getUnderlyingTemplate() const
Return the underlying template name.
bool hasTemplateKeyword() const
Whether the template name was prefixed by the "template" keyword.
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.
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.
TemplateName getReplacement() const
UnsignedOrNone getPackIndex() 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.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
bool isNull() const
Determine whether this template name is NULL.
bool operator==(TemplateName Other) const
Structural equality.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualifiedTemplateName * getAsQualifiedTemplateName() const
Retrieve the underlying qualified template name structure, if any.
NestedNameSpecifier getQualifier() const
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
std::pair< TemplateName, DefaultArguments > getTemplateDeclAndDefaultArgs() const
Retrieves the underlying template name that this template name refers to, along with the deduced defa...
static TemplateName getFromVoidPointer(void *Ptr)
Build a template name from a void pointer.
bool operator!=(TemplateName Other) const
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ PackIndexingTemplate
A pack-index-template-name.
@ 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,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ 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.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
void Profile(llvm::FoldingSetNodeID &ID)
TemplateTemplateParmDecl * getAsTemplateTemplateParmDecl() const
Retrieve the template template parameter that this template name refers to, if any.
TemplateName getUnderlying() const
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm() const
Retrieve the substituted template template parameter, if known.
std::tuple< NestedNameSpecifier, bool > getQualifierAndTemplateKeyword() const
void dump(raw_ostream &OS, const ASTContext &Context) const
Debugging aid that dumps the template name.
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...
PackIndexingTemplateStorage * getAsPackIndexingTemplate()
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack()
UncommonTemplateNameStorage(Kind Kind, unsigned Index, unsigned Data)
@ SubstTemplateTemplateParm
@ SubstTemplateTemplateParmPack
SubstTemplateTemplateParmStorage * getAsSubstTemplateTemplateParm()
AssumedTemplateStorage * getAsAssumedTemplateName()
DeducedTemplateStorage * getAsDeducedTemplateName()
OverloadedTemplateStorage * getAsOverloadedStorage()
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Top level wrappers for InstallAPI frontend operations.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
OptionalUnsigned< unsigned > UnsignedOrNone
@ Template
We are parsing a template declaration.
@ Deduced
The normal deduced case.
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
@ PackIndex
Index of a pack indexing expression or specifier.
@ Other
Other implicit parameter.
Diagnostic wrappers for TextAPI types for error reporting.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
ArrayRef< TemplateArgument > Args
IdentifierOrOverloadedOperator()=default
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
bool operator==(const IdentifierOrOverloadedOperator &Other) const
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
static constexpr OptionalUnsigned fromInternalRepresentation(underlying_type Rep)
Describes how types, statements, expressions, and declarations should be printed.
unsigned Data
The pack index, or the number of stored templates or template arguments, depending on which subclass ...
static void * getAsVoidPointer(clang::Expr *P)
static clang::Expr * getFromVoidPointer(void *P)
static constexpr int NumLowBitsAvailable
static void * getAsVoidPointer(clang::TemplateName TN)
static constexpr int NumLowBitsAvailable
static clang::TemplateName getFromVoidPointer(void *Ptr)