14#ifndef LLVM_CLANG_AST_TEMPLATEBASE_H
15#define LLVM_CLANG_AST_TEMPLATEBASE_H
23#include "llvm/ADT/APInt.h"
24#include "llvm/ADT/APSInt.h"
25#include "llvm/ADT/ArrayRef.h"
26#include "llvm/ADT/SmallVector.h"
27#include "llvm/Support/Compiler.h"
28#include "llvm/Support/TrailingObjects.h"
36class FoldingSetNodeID;
46 static constexpr int NumLowBitsAvailable = 2;
116 LLVM_PREFERRED_TYPE(
bool)
117 unsigned IsDefaulted : 1;
124 LLVM_PREFERRED_TYPE(
bool)
125 unsigned IsDefaulted : 1;
129 unsigned BitWidth : 31;
130 LLVM_PREFERRED_TYPE(
bool)
131 unsigned IsUnsigned : 1;
137 const uint64_t *pVal;
144 LLVM_PREFERRED_TYPE(
bool)
145 unsigned IsDefaulted : 1;
152 LLVM_PREFERRED_TYPE(
bool)
153 unsigned IsDefaulted : 1;
160 LLVM_PREFERRED_TYPE(
bool)
161 unsigned IsDefaulted : 1;
162 UnsignedOrNone NumExpansions;
168 LLVM_PREFERRED_TYPE(
bool)
169 unsigned IsDefaulted : 1;
170 LLVM_PREFERRED_TYPE(
bool)
171 unsigned IsCanonicalExpr : 1;
183 void initFromType(
QualType T,
bool IsNullPtr,
bool IsDefaulted);
185 void initFromIntegral(
const ASTContext &Ctx,
const llvm::APSInt &
Value,
188 const APValue &
V,
bool IsDefaulted);
197 bool IsDefaulted =
false) {
198 initFromType(
T, isNullPtr, IsDefaulted);
204 initFromDeclaration(
D, QT, IsDefaulted);
214 bool IsDefaulted =
false);
256 bool IsDefaulted =
false) {
280 this->Args.Kind =
Pack;
281 this->Args.IsDefaulted =
false;
282 this->Args.Args =
Args.data();
283 this->Args.NumArgs =
Args.size();
369 using namespace llvm;
374 unsigned NumWords = APInt::getNumWords(
Integer.BitWidth);
467 bool IncludeType)
const;
489 return cast<TemplateTemplateArgLocInfo *>(Pointer);
504 return cast<TypeSourceInfo *>(Pointer);
522 llvm::PointerUnion<TemplateTemplateArgLocInfo *, Expr *, TypeSourceInfo *>
537 : Argument(Argument), LocInfo(Opaque) {}
540 : Argument(Argument), LocInfo(TInfo) {
545 : Argument(Argument), LocInfo(
E) {
643 : LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc) {}
655 unsigned size()
const {
return Arguments.size(); }
658 return Arguments.data();
677 :
private llvm::TrailingObjects<ASTTemplateArgumentListInfo,
678 TemplateArgumentLoc> {
681 friend TrailingObjects;
703 return getTrailingObjects();
755 TemplateArgumentDependence &Deps);
static StringRef bytes(const std::vector< T, Allocator > &v)
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat],...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Information about one declarator, including the parsed type information and the identifier.
This represents one expression.
A C++ nested-name-specifier augmented with source location information.
A (possibly-)qualified type.
static QualType getFromOpaquePtr(const void *Ptr)
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getBegin() const
The streaming interface shared between DiagnosticBuilder and PartialDiagnostic.
A convenient class for passing around template argument information.
SourceLocation getRAngleLoc() const
void setLAngleLoc(SourceLocation Loc)
void setRAngleLoc(SourceLocation Loc)
TemplateArgumentListInfo(SourceLocation LAngleLoc, SourceLocation RAngleLoc)
const TemplateArgumentLoc * getArgumentArray() const
void addArgument(const TemplateArgumentLoc &Loc)
ArrayRef< TemplateArgumentLoc > arguments() const
TemplateArgumentListInfo()=default
const TemplateArgumentLoc & operator[](unsigned I) const
SourceLocation getLAngleLoc() const
TemplateArgumentLoc & operator[](unsigned I)
Location wrapper for a TemplateArgument.
SourceLocation getLocation() const
SourceLocation getTemplateEllipsisLoc() const
Expr * getSourceStructuralValueExpression() const
Expr * getSourceIntegralExpression() const
TemplateArgumentLocInfo getLocInfo() const
const TemplateArgument & getArgument() const
TemplateArgumentLoc(const TemplateArgument &Argument, TemplateArgumentLocInfo Opaque)
SourceLocation getTemplateNameLoc() const
SourceLocation getTemplateKWLoc() const
TypeSourceInfo * getTypeSourceInfo() const
TemplateArgumentLoc(const TemplateArgument &Argument, TypeSourceInfo *TInfo)
Expr * getSourceNullPtrExpression() const
TemplateArgumentLoc(const TemplateArgument &Argument, Expr *E)
SourceRange getSourceRange() const LLVM_READONLY
Expr * getSourceDeclExpression() const
Expr * getSourceExpression() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Represents a template argument.
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
void dump(raw_ostream &Out, const ASTContext &Context) const
Debugging aid that dumps the template argument.
QualType getStructuralValueType() const
Get the type of a StructuralValue.
TemplateArgument(const TemplateArgument &Other, QualType Type)
Construct an integral constant template argument with the same value as Other but a different type.
QualType getParamTypeForDecl() const
TemplateArgument(QualType T, bool isNullPtr=false, bool IsDefaulted=false)
Construct a template type argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
bool isDependent() const
Whether this template argument is dependent on a template parameter such that its result can change f...
TemplateArgument(ArrayRef< TemplateArgument > Args)
Construct a template argument that is a template argument pack.
pack_iterator pack_end() const
Iterator referencing one past the last argument of a template argument pack.
bool isInstantiationDependent() const
Whether this template argument is dependent on a template parameter.
constexpr TemplateArgument()
Construct an empty, invalid template argument.
TemplateArgument(TemplateName Name, UnsignedOrNone NumExpansions, bool IsDefaulted=false)
Construct a template argument that is a template pack expansion.
void setIntegralType(QualType T)
TemplateArgument(ValueDecl *D, QualType QT, bool IsDefaulted=false)
Construct a template argument that refers to a (non-dependent) declaration.
pack_iterator pack_begin() const
Iterator referencing the first argument of a template argument pack.
UnsignedOrNone getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
bool isConceptOrConceptTemplateParameter() const
void dump() const
Debugging aid that dumps the template argument to standard error.
void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context) const
Used to insert TemplateArguments into FoldingSets.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
QualType getNullPtrType() const
Retrieve the type for null non-type template argument.
static TemplateArgument CreatePackCopy(ASTContext &Context, ArrayRef< TemplateArgument > Args)
Create a new template argument pack by copying the given set of template arguments.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool containsUnexpandedParameterPack() const
Whether this template argument contains an unexpanded parameter pack.
TemplateArgument getPackExpansionPattern() const
When the template argument is a pack expansion, returns the pattern of the pack expansion.
TemplateArgument(Expr *E, bool IsCanonical, bool IsDefaulted=false)
Construct a template argument that is an expression.
bool isNull() const
Determine whether this template argument has no value.
static TemplateArgument getEmptyPack()
unsigned pack_size() const
The number of template arguments in the given template argument pack.
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
void print(const PrintingPolicy &Policy, raw_ostream &Out, bool IncludeType) const
Print this template argument to the given output stream.
QualType getIntegralType() const
Retrieve the type of the integral value.
bool getIsDefaulted() const
If returns 'true', this TemplateArgument corresponds to a default template parameter.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
TemplateArgument(TemplateName Name, bool IsDefaulted=false)
Construct a template argument that is a template.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
ArgKind
The kind of template argument we're storing.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
TemplateArgumentDependence getDependence() const
bool isCanonicalExpr() const
bool isPackExpansion() const
Determine whether this template argument is a pack expansion.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
void setIsDefaulted(bool v)
Set to 'true' if this TemplateArgument corresponds to a default template parameter.
Represents a C++ template name within the type system.
static TemplateName getFromVoidPointer(void *Ptr)
Build a template name from a void pointer.
A container of type source information.
The base class of the type hierarchy.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
The JSON file list parser is used to communicate input to InstallAPI.
@ Create
'create' clause, allowed on Compute and Combined constructs, plus 'data', 'enter data',...
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
const FunctionProtoType * T
@ 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...
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments.
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
const TemplateArgumentLoc & operator[](unsigned I) const
SourceLocation getLAngleLoc() const
ArrayRef< TemplateArgumentLoc > arguments() const
unsigned getNumTemplateArgs() const
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
SourceLocation getRAngleLoc() const
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
SourceLocation LAngleLoc
The source location of the left angle bracket ('<').
void copyInto(const TemplateArgumentLoc *ArgArray, TemplateArgumentListInfo &List) const
unsigned NumTemplateArgs
The number of template arguments in TemplateArgs.
void initializeFrom(SourceLocation TemplateKWLoc, const TemplateArgumentListInfo &List, TemplateArgumentLoc *OutArgArray)
SourceLocation RAngleLoc
The source location of the right angle bracket ('>').
SourceLocation TemplateKWLoc
The source location of the template keyword; this is used as part of the representation of qualified ...
Describes how types, statements, expressions, and declarations should be printed.
SourceLocation TemplateKwLoc
SourceLocation TemplateNameLoc
SourceLocation EllipsisLoc
Location information for a TemplateArgument.
SourceLocation getTemplateEllipsisLoc() const
SourceLocation getTemplateKwLoc() const
TypeSourceInfo * getAsTypeSourceInfo() const
TemplateArgumentLocInfo(TypeSourceInfo *Declarator)
TemplateTemplateArgLocInfo * getTemplate() const
SourceLocation getTemplateNameLoc() const
TemplateArgumentLocInfo()
TemplateArgumentLocInfo(Expr *E)
static void * getAsVoidPointer(clang::Expr *P)
static clang::Expr * getFromVoidPointer(void *P)