clang API Documentation
#include <DeclTemplate.h>
Public Member Functions | |
SourceRange | getSourceRange () const override LLVM_READONLY |
Source range that this declaration covers. | |
bool | hasDefaultArgument () const |
Determine whether this template parameter has a default argument. | |
Expr * | getDefaultArgument () const |
Retrieve the default argument, if any. | |
SourceLocation | getDefaultArgumentLoc () const |
Retrieve the location of the default argument, if any. | |
bool | defaultArgumentWasInherited () const |
Determines whether the default argument was inherited from a previous declaration of this template. | |
void | setDefaultArgument (Expr *DefArg, bool Inherited) |
Set the default argument for this template parameter, and whether that default argument was inherited from another declaration. | |
void | removeDefaultArgument () |
Removes the default argument of this template parameter. | |
bool | isParameterPack () const |
Whether this parameter is a non-type template parameter pack. | |
bool | isPackExpansion () const |
Whether this parameter pack is a pack expansion. | |
bool | isExpandedParameterPack () const |
Whether this parameter is a non-type template parameter pack that has a known list of different types at different positions. | |
unsigned | getNumExpansionTypes () const |
Retrieves the number of expansion types in an expanded parameter pack. | |
QualType | getExpansionType (unsigned I) const |
Retrieve a particular expansion type within an expanded parameter pack. | |
TypeSourceInfo * | getExpansionTypeSourceInfo (unsigned I) const |
Retrieve a particular expansion type source info within an expanded parameter pack. | |
Static Public Member Functions | |
static NonTypeTemplateParmDecl * | Create (const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo) |
static NonTypeTemplateParmDecl * | Create (const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, const QualType *ExpandedTypes, unsigned NumExpandedTypes, TypeSourceInfo **ExpandedTInfos) |
static NonTypeTemplateParmDecl * | CreateDeserialized (ASTContext &C, unsigned ID) |
static NonTypeTemplateParmDecl * | CreateDeserialized (ASTContext &C, unsigned ID, unsigned NumExpandedTypes) |
static bool | classof (const Decl *D) |
static bool | classofKind (Kind K) |
Friends | |
class | ASTDeclReader |
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in
template<int Size> class array { };
Definition at line 1032 of file DeclTemplate.h.
static bool clang::NonTypeTemplateParmDecl::classof | ( | const Decl * | D | ) | [inline, static] |
Reimplemented from clang::DeclaratorDecl.
Definition at line 1203 of file DeclTemplate.h.
References classofKind(), and clang::Decl::getKind().
static bool clang::NonTypeTemplateParmDecl::classofKind | ( | Kind | K | ) | [inline, static] |
Reimplemented from clang::DeclaratorDecl.
Definition at line 1204 of file DeclTemplate.h.
Referenced by classof().
NonTypeTemplateParmDecl * NonTypeTemplateParmDecl::Create | ( | const ASTContext & | C, |
DeclContext * | DC, | ||
SourceLocation | StartLoc, | ||
SourceLocation | IdLoc, | ||
unsigned | D, | ||
unsigned | P, | ||
IdentifierInfo * | Id, | ||
QualType | T, | ||
bool | ParameterPack, | ||
TypeSourceInfo * | TInfo | ||
) | [static] |
Definition at line 539 of file DeclTemplate.cpp.
References AttributeLangSupport::C.
Referenced by clang::Sema::ActOnNonTypeTemplateParameter(), and clang::ASTNodeImporter::VisitNonTypeTemplateParmDecl().
NonTypeTemplateParmDecl * NonTypeTemplateParmDecl::Create | ( | const ASTContext & | C, |
DeclContext * | DC, | ||
SourceLocation | StartLoc, | ||
SourceLocation | IdLoc, | ||
unsigned | D, | ||
unsigned | P, | ||
IdentifierInfo * | Id, | ||
QualType | T, | ||
TypeSourceInfo * | TInfo, | ||
const QualType * | ExpandedTypes, | ||
unsigned | NumExpandedTypes, | ||
TypeSourceInfo ** | ExpandedTInfos | ||
) | [static] |
Definition at line 549 of file DeclTemplate.cpp.
References AttributeLangSupport::C.
NonTypeTemplateParmDecl * NonTypeTemplateParmDecl::CreateDeserialized | ( | ASTContext & | C, |
unsigned | ID | ||
) | [static] |
Definition at line 564 of file DeclTemplate.cpp.
References AttributeLangSupport::C.
NonTypeTemplateParmDecl * NonTypeTemplateParmDecl::CreateDeserialized | ( | ASTContext & | C, |
unsigned | ID, | ||
unsigned | NumExpandedTypes | ||
) | [static] |
Definition at line 571 of file DeclTemplate.cpp.
References AttributeLangSupport::C.
bool clang::NonTypeTemplateParmDecl::defaultArgumentWasInherited | ( | ) | const [inline] |
Determines whether the default argument was inherited from a previous declaration of this template.
Definition at line 1115 of file DeclTemplate.h.
Referenced by getSourceRange(), and clang::ASTDeclWriter::VisitNonTypeTemplateParmDecl().
Expr* clang::NonTypeTemplateParmDecl::getDefaultArgument | ( | ) | const [inline] |
Retrieve the default argument, if any.
Definition at line 1106 of file DeclTemplate.h.
Referenced by clang::Sema::CheckTemplateParameterList(), getDefaultArgumentLoc(), getSourceRange(), SubstDefaultTemplateArgument(), and clang::ASTDeclWriter::VisitNonTypeTemplateParmDecl().
Retrieve the location of the default argument, if any.
Definition at line 586 of file DeclTemplate.cpp.
References clang::SourceRange::getBegin(), getDefaultArgument(), clang::Stmt::getSourceRange(), and hasDefaultArgument().
Referenced by clang::Sema::CheckTemplateParameterList().
QualType clang::NonTypeTemplateParmDecl::getExpansionType | ( | unsigned | I | ) | const [inline] |
Retrieve a particular expansion type within an expanded parameter pack.
Definition at line 1188 of file DeclTemplate.h.
References clang::QualType::getFromOpaquePtr().
Referenced by clang::ASTDeclWriter::VisitNonTypeTemplateParmDecl().
TypeSourceInfo* clang::NonTypeTemplateParmDecl::getExpansionTypeSourceInfo | ( | unsigned | I | ) | const [inline] |
Retrieve a particular expansion type source info within an expanded parameter pack.
Definition at line 1196 of file DeclTemplate.h.
Referenced by clang::ASTDeclWriter::VisitNonTypeTemplateParmDecl().
unsigned clang::NonTypeTemplateParmDecl::getNumExpansionTypes | ( | ) | const [inline] |
Retrieves the number of expansion types in an expanded parameter pack.
Definition at line 1181 of file DeclTemplate.h.
Referenced by clang::ASTDeclWriter::VisitNonTypeTemplateParmDecl(), and clang::ASTDeclReader::VisitNonTypeTemplateParmDecl().
SourceRange NonTypeTemplateParmDecl::getSourceRange | ( | ) | const [override, virtual] |
Source range that this declaration covers.
Reimplemented from clang::DeclaratorDecl.
Definition at line 579 of file DeclTemplate.cpp.
References defaultArgumentWasInherited(), getDefaultArgument(), clang::DeclaratorDecl::getOuterLocStart(), and hasDefaultArgument().
bool clang::NonTypeTemplateParmDecl::hasDefaultArgument | ( | ) | const [inline] |
Determine whether this template parameter has a default argument.
Definition at line 1101 of file DeclTemplate.h.
Referenced by clang::Sema::CheckTemplateParameterList(), getDefaultArgumentLoc(), and getSourceRange().
bool clang::NonTypeTemplateParmDecl::isExpandedParameterPack | ( | ) | const [inline] |
Whether this parameter is a non-type template parameter pack that has a known list of different types at different positions.
A parameter pack is an expanded parameter pack when the original parameter pack's type was itself a pack expansion, and that expansion has already been expanded. For example, given:
template<typename ...Types> struct X { template<Types ...Values> struct Y { /* ... */ }; };
The parameter pack Values
has a PackExpansionType
as its type, which expands Types
. When Types
is supplied with template arguments by instantiating X
, the instantiation of Values
becomes an expanded parameter pack. For example, instantiating X<int, unsigned int>
results in Values
being an expanded parameter pack with expansion types int
and unsigned
int.
The getExpansionType()
and getExpansionTypeSourceInfo()
functions return the expansion types.
Definition at line 1177 of file DeclTemplate.h.
Referenced by clang::ASTDeclWriter::VisitNonTypeTemplateParmDecl(), and clang::ASTDeclReader::VisitNonTypeTemplateParmDecl().
bool clang::NonTypeTemplateParmDecl::isPackExpansion | ( | ) | const [inline] |
Whether this parameter pack is a pack expansion.
A non-type template parameter pack is a pack expansion if its type contains an unexpanded parameter pack. In this case, we will have built a PackExpansionType wrapping the type.
Definition at line 1149 of file DeclTemplate.h.
References clang::Type::getAs(), and clang::ValueDecl::getType().
bool clang::NonTypeTemplateParmDecl::isParameterPack | ( | ) | const [inline] |
Whether this parameter is a non-type template parameter pack.
If the parameter is a parameter pack, the type may be a PackExpansionType
. In the following example, the Dims
parameter is a parameter pack (whose type is 'unsigned').
template<typename T, unsigned ...Dims> struct multi_array;
Reimplemented from clang::Decl.
Definition at line 1142 of file DeclTemplate.h.
Referenced by isSameTemplateParameter(), IsStructurallyEquivalent(), clang::ASTDeclWriter::VisitNonTypeTemplateParmDecl(), and clang::ASTNodeImporter::VisitNonTypeTemplateParmDecl().
void clang::NonTypeTemplateParmDecl::removeDefaultArgument | ( | ) | [inline] |
Removes the default argument of this template parameter.
Definition at line 1128 of file DeclTemplate.h.
void clang::NonTypeTemplateParmDecl::setDefaultArgument | ( | Expr * | DefArg, |
bool | Inherited | ||
) | [inline] |
Set the default argument for this template parameter, and whether that default argument was inherited from another declaration.
Definition at line 1122 of file DeclTemplate.h.
Referenced by clang::Sema::ActOnNonTypeTemplateParameter(), and clang::ASTDeclReader::VisitNonTypeTemplateParmDecl().
friend class ASTDeclReader [friend] |
Reimplemented from clang::DeclaratorDecl.
Definition at line 1070 of file DeclTemplate.h.