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 unsigned NumExpansions;
168 LLVM_PREFERRED_TYPE(
bool)
169 unsigned IsDefaulted : 1;
181 void initFromType(
QualType T,
bool IsNullPtr,
bool IsDefaulted);
183 void initFromIntegral(
const ASTContext &Ctx,
const llvm::APSInt &
Value,
186 const APValue &
V,
bool IsDefaulted);
194 bool IsDefaulted =
false) {
195 initFromType(
T, isNullPtr, IsDefaulted);
201 initFromDeclaration(
D, QT, IsDefaulted);
211 bool IsDefaulted =
false);
253 bool IsDefaulted =
false) {
279 this->Args.Kind =
Pack;
280 this->Args.IsDefaulted =
false;
281 this->Args.Args =
Args.data();
282 this->Args.NumArgs =
Args.size();
366 using namespace llvm;
371 unsigned NumWords = APInt::getNumWords(
Integer.BitWidth);
459 bool IncludeType)
const;
474 struct TemplateTemplateArgLocInfo {
478 void *QualifierLocData;
483 llvm::PointerUnion<TemplateTemplateArgLocInfo *, Expr *, TypeSourceInfo *>
486 TemplateTemplateArgLocInfo *getTemplate()
const {
487 return cast<TemplateTemplateArgLocInfo *>(Pointer);
502 return cast<TypeSourceInfo *>(Pointer);
508 const auto *Template = getTemplate();
510 Template->QualifierLocData);
514 return getTemplate()->TemplateNameLoc;
518 return getTemplate()->EllipsisLoc;
533 : Argument(Argument), LocInfo(Opaque) {}
536 : Argument(Argument), LocInfo(TInfo) {
541 : Argument(Argument), LocInfo(
E) {
556 : Argument(Argument),
557 LocInfo(Ctx, QualifierLoc, TemplateNameLoc, EllipsisLoc) {
641 : LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc) {}
653 unsigned size()
const {
return Arguments.size(); }
656 return Arguments.data();
675 :
private llvm::TrailingObjects<ASTTemplateArgumentListInfo,
676 TemplateArgumentLoc> {
679 friend TrailingObjects;
701 return getTrailingObjects<TemplateArgumentLoc>();
753 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.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
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)
llvm::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
TypeSourceInfo * getTypeSourceInfo() const
TemplateArgumentLoc(const TemplateArgument &Argument, TypeSourceInfo *TInfo)
Expr * getSourceNullPtrExpression() const
TemplateArgumentLoc(const TemplateArgument &Argument, Expr *E)
SourceRange getSourceRange() const LLVM_READONLY
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Expr * getSourceDeclExpression() const
Expr * getSourceExpression() const
TemplateArgumentLoc(ASTContext &Ctx, const TemplateArgument &Argument, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateNameLoc, SourceLocation EllipsisLoc=SourceLocation())
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.
std::optional< unsigned > getNumTemplateExpansions() const
Retrieve the number of expansions that a template template argument expansion will produce,...
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.
void setIntegralType(QualType T)
TemplateArgument(TemplateName Name, std::optional< unsigned > NumExpansions, bool IsDefaulted=false)
Construct a template argument that is a template pack expansion.
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.
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
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 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 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
unsigned getNumTemplateArgs() const
llvm::ArrayRef< TemplateArgumentLoc > arguments() 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.
Location information for a TemplateArgument.
SourceLocation getTemplateEllipsisLoc() const
NestedNameSpecifierLoc getTemplateQualifierLoc() const
TypeSourceInfo * getAsTypeSourceInfo() const
TemplateArgumentLocInfo(TypeSourceInfo *Declarator)
SourceLocation getTemplateNameLoc() const
TemplateArgumentLocInfo()
TemplateArgumentLocInfo(Expr *E)
static void * getAsVoidPointer(clang::Expr *P)
static clang::Expr * getFromVoidPointer(void *P)