15 #ifndef LLVM_CLANG_AST_TEMPLATEBASE_H
16 #define LLVM_CLANG_AST_TEMPLATEBASE_H
20 #include "llvm/ADT/APSInt.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/iterator_range.h"
23 #include "llvm/Support/Compiler.h"
24 #include "llvm/Support/ErrorHandling.h"
25 #include "llvm/Support/TrailingObjects.h"
28 class FoldingSetNodeID;
33 class DiagnosticBuilder;
35 struct PrintingPolicy;
88 unsigned BitWidth : 31;
89 unsigned IsUnsigned : 1;
103 unsigned NumExpansions;
137 assert(D &&
"Expected decl");
203 this->Args.Kind =
Pack;
204 this->Args.Args = Args.data();
205 this->Args.NumArgs = Args.size();
284 using namespace llvm;
288 unsigned NumWords = APInt::getNumWords(
Integer.BitWidth);
289 return APSInt(APInt(
Integer.BitWidth, makeArrayRef(
Integer.pVal, NumWords)),
343 return llvm::makeArrayRef(
Args.Args,
Args.NumArgs);
358 void dump(raw_ostream &Out)
const;
375 void *QualifierLocData;
376 unsigned TemplateNameLoc;
377 unsigned EllipsisLoc;
436 : Argument(Argument), LocInfo(Opaque) {
440 : Argument(Argument), LocInfo(TInfo) {
445 : Argument(Argument), LocInfo(E) {
453 : Argument(Argument), LocInfo(QualifierLoc, TemplateNameLoc, EllipsisLoc) {
462 return getTemplateNameLoc();
480 return LocInfo.getAsTypeSourceInfo();
485 return LocInfo.getAsExpr();
490 return LocInfo.getAsExpr();
495 return LocInfo.getAsExpr();
500 return LocInfo.getAsExpr();
506 return LocInfo.getTemplateQualifierLoc();
512 return LocInfo.getTemplateNameLoc();
517 return LocInfo.getTemplateEllipsisLoc();
537 : LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc) {}
545 unsigned size()
const {
return Arguments.size(); }
548 return Arguments.data();
564 Arguments.push_back(Loc);
574 TemplateArgumentLoc> {
592 return getTrailingObjects<TemplateArgumentLoc>();
596 return getTemplateArgs()[
I];
610 struct LLVM_ALIGNAS(LLVM_PTR_SIZE) ASTTemplateKWAndArgsInfo {
612 SourceLocation LAngleLoc;
615 SourceLocation RAngleLoc;
621 SourceLocation TemplateKWLoc;
624 unsigned NumTemplateArgs;
626 void initializeFrom(SourceLocation TemplateKWLoc,
627 const TemplateArgumentListInfo &List,
628 TemplateArgumentLoc *OutArgArray);
629 void initializeFrom(SourceLocation TemplateKWLoc,
630 const TemplateArgumentListInfo &List,
631 TemplateArgumentLoc *OutArgArray,
bool &Dependent,
632 bool &InstantiationDependent,
633 bool &ContainsUnexpandedParameterPack);
634 void initializeFrom(SourceLocation TemplateKWLoc);
636 void copyInto(
const TemplateArgumentLoc *ArgArray,
637 TemplateArgumentListInfo &List)
const;
640 const DiagnosticBuilder &
operator<<(
const DiagnosticBuilder &DB,
655 assert(Idx <
getNumArgs() &&
"Template argument out of range");
661 assert(Idx <
getNumArgs() &&
"Template argument out of range");
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
Expr * getSourceExpression() const
llvm::iterator_range< pack_iterator > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
TemplateArgument(ArrayRef< TemplateArgument > Args)
Construct a template argument that is a template argument pack.
A (possibly-)qualified type.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
C Language Family Type Representation.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
TemplateArgumentLoc & operator[](unsigned I)
TemplateArgument()
Construct an empty, invalid template argument.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
const DiagnosticBuilder & operator<<(const DiagnosticBuilder &DB, const Attr *At)
The base class of the type hierarchy.
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
A container of type source information.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
void * getAsOpaquePtr() const
const TemplateArgumentLoc * getArgumentArray() const
void setRAngleLoc(SourceLocation Loc)
Information about one declarator, including the parsed type information and the identifier.
Represents an empty template argument, e.g., one that has not been deduced.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Describes how types, statements, expressions, and declarations should be printed. ...
static StringRef bytes(const std::vector< T, Allocator > &v)
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
TemplateArgument(const TemplateArgument &Other, QualType Type)
Construct an integral constant template argument with the same value as Other but a different type...
TemplateArgument(Expr *E)
Construct a template argument that is an expression.
static TemplateArgument getEmptyPack()
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
TemplateArgumentLoc(const TemplateArgument &Argument, TypeSourceInfo *TInfo)
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
TemplateArgumentLoc(const TemplateArgument &Argument, Expr *E)
SourceLocation getLocation() const
Fetches the primary location of the argument.
const TemplateArgument * getArgs() const
Retrieve the template arguments.
const TemplateArgumentLoc & operator[](unsigned I) const
TypeSourceInfo * getTypeSourceInfo() const
SourceLocation getTemplateEllipsisLoc() const
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
A convenient class for passing around template argument information.
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
NestedNameSpecifierLoc getTemplateQualifierLoc() const
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
SourceLocation getRAngleLoc() const
SourceLocation getTemplateNameLoc() const
detail::InMemoryDirectory::const_iterator I
void dump() const
Debugging aid that dumps the template argument to standard error.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
Optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce...
TemplateArgument(TemplateName Name, Optional< unsigned > NumExpansions)
Construct a template argument that is a template pack expansion.
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
ArgKind
The kind of template argument we're storing.
ArgKind getKind() const
Return the kind of stored template argument.
TypeSourceInfo * Declarator
Represents a C++ template name within the type system.
Expr * getSourceNullPtrExpression() const
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
TemplateArgumentLocInfo(TypeSourceInfo *TInfo)
TemplateArgumentListInfo(SourceLocation LAngleLoc, SourceLocation RAngleLoc)
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
SourceLocation getTemplateNameLoc() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
static TemplateName getFromVoidPointer(void *Ptr)
Build a template name from a void pointer.
Expr * getSourceIntegralExpression() const
const TemplateArgument * pack_iterator
Iterator that traverses the elements of a template argument pack.
Encodes a location in the source.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
const TemplateArgument * iterator
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
void setIntegralType(QualType T)
void print(const PrintingPolicy &Policy, raw_ostream &Out) const
Print this template argument to the given output stream.
SourceLocation getTemplateEllipsisLoc() const
TemplateArgumentLocInfo(NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
Used to insert TemplateArguments into FoldingSets.
SourceLocation getLAngleLoc() const
SourceLocation getBegin() const
const TemplateArgumentLoc & operator[](unsigned I) const
static QualType getFromOpaquePtr(const void *Ptr)
void setLAngleLoc(SourceLocation Loc)
void addArgument(const TemplateArgumentLoc &Loc)
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Represents a template argument.
QualType getAsType() const
Retrieve the type for a type template argument.
TemplateArgumentListInfo()
void * getAsVoidPointer() const
Retrieve the template name as a void pointer.
The template argument is a pack expansion of a template name that was provided for a template templat...
TemplateArgumentLocInfo(Expr *E)
bool isNull() const
Determine whether this template argument has no value.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
detail::InMemoryDirectory::const_iterator E
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
Location wrapper for a TemplateArgument.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
The template argument is a type.
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
The template argument is actually a parameter pack.
Expr * getSourceDeclExpression() const
TemplateArgumentLocInfo getLocInfo() const
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
unsigned pack_size() const
The number of template arguments in the given template argument pack.
The template argument is a template name that was provided for a template template parameter...
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
Location information for a TemplateArgument.
TemplateArgument(QualType T, bool isNullPtr=false)
Construct a template type argument.
pack_iterator pack_end() const
Iterator referencing one past the last argument of a template argument pack.
QualType getParamTypeForDecl() const
TypeSourceInfo * getAsTypeSourceInfo() const
TemplateArgument(ValueDecl *D, QualType QT)
Construct a template argument that refers to a declaration, which is either an external declaration o...
TemplateArgument(TemplateName Name)
Construct a template argument that is a template.
TemplateArgumentLoc(const TemplateArgument &Argument, TemplateArgumentLocInfo Opaque)
A trivial tuple used to represent a source range.
TemplateArgumentLoc(const TemplateArgument &Argument, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc=SourceLocation())
unsigned getNumArgs() const
Retrieve the number of template arguments.