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;
134 assert(D &&
"Expected decl");
136 DeclArg.QT = QT.getAsOpaquePtr();
200 this->Args.Kind =
Pack;
201 this->Args.Args = Args.data();
202 this->Args.NumArgs = Args.size();
281 using namespace llvm;
285 unsigned NumWords = APInt::getNumWords(
Integer.BitWidth);
286 return APSInt(APInt(
Integer.BitWidth, makeArrayRef(
Integer.pVal, NumWords)),
344 return llvm::makeArrayRef(
Args.Args,
Args.NumArgs);
359 void dump(raw_ostream &Out)
const;
376 void *QualifierLocData;
377 unsigned TemplateNameLoc;
378 unsigned EllipsisLoc;
390 TemplateArgumentLocInfo(TypeSourceInfo *TInfo) : Declarator(TInfo) {}
392 TemplateArgumentLocInfo(Expr *
E) :
Expression(E) {}
394 TemplateArgumentLocInfo(NestedNameSpecifierLoc QualifierLoc,
395 SourceLocation TemplateNameLoc,
396 SourceLocation EllipsisLoc)
398 Template.Qualifier = QualifierLoc.getNestedNameSpecifier();
399 Template.QualifierLocData = QualifierLoc.getOpaqueData();
400 Template.TemplateNameLoc = TemplateNameLoc.getRawEncoding();
401 Template.EllipsisLoc = EllipsisLoc.getRawEncoding();
404 TypeSourceInfo *getAsTypeSourceInfo()
const {
412 NestedNameSpecifierLoc getTemplateQualifierLoc()
const {
413 return NestedNameSpecifierLoc(
Template.Qualifier,
417 SourceLocation getTemplateNameLoc()
const {
421 SourceLocation getTemplateEllipsisLoc()
const {
437 : Argument(Argument), LocInfo(Opaque) {
441 : Argument(Argument), LocInfo(TInfo) {
446 : Argument(Argument), LocInfo(E) {
454 : Argument(Argument), LocInfo(QualifierLoc, TemplateNameLoc, EllipsisLoc) {
463 return getTemplateNameLoc();
481 return LocInfo.getAsTypeSourceInfo();
486 return LocInfo.getAsExpr();
491 return LocInfo.getAsExpr();
496 return LocInfo.getAsExpr();
501 return LocInfo.getAsExpr();
507 return LocInfo.getTemplateQualifierLoc();
513 return LocInfo.getTemplateNameLoc();
518 return LocInfo.getTemplateEllipsisLoc();
538 : LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc) {}
546 unsigned size()
const {
return Arguments.size(); }
549 return Arguments.data();
565 Arguments.push_back(Loc);
575 TemplateArgumentLoc> {
594 return getTrailingObjects<TemplateArgumentLoc>();
598 return llvm::makeArrayRef(getTemplateArgs(), NumTemplateArgs);
602 return getTemplateArgs()[
I];
638 bool &InstantiationDependent,
639 bool &ContainsUnexpandedParameterPack);
651 return getArgs() + getNumArgs();
656 return getArgs() + getNumArgs();
661 assert(Idx < getNumArgs() &&
"Template argument out of range");
662 return getArgs()[Idx];
667 assert(Idx < getNumArgs() &&
"Template argument out of range");
668 return getArgs()[Idx];
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
Expr * getSourceExpression() const
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.
SourceLocation TemplateKWLoc
The source location of the template keyword; this is used as part of the representation of qualified ...
C Language Family Type Representation.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
TemplateArgumentLoc & operator[](unsigned I)
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.
void * getAsOpaquePtr() const
const TemplateArgumentLoc * getArgumentArray() const
void setRAngleLoc(SourceLocation Loc)
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()
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 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.
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
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
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...
A little helper class used to produce diagnostics.
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
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.
constexpr TemplateArgument()
Construct an empty, invalid template argument.
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.
TemplateArgumentListInfo(SourceLocation LAngleLoc, SourceLocation RAngleLoc)
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
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.
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 RAngleLoc
The source location of the right angle bracket ('>').
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...
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
const TemplateArgument & getArg(unsigned Idx) const
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.
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
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...
constexpr TemplateArgumentLoc()
Location information for a TemplateArgument.
pack_iterator pack_end() const
Iterator referencing one past the last argument of a template argument pack.
QualType getParamTypeForDecl() const
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.
constexpr TemplateArgumentLocInfo()
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
TemplateArgumentLoc(const TemplateArgument &Argument, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc=SourceLocation())