12 #ifndef LLVM_CLANG_SEMA_TEMPLATE_H
13 #define LLVM_CLANG_SEMA_TEMPLATE_H
18 #include "llvm/ADT/SmallVector.h"
62 unsigned getNumLevels()
const {
return TemplateArgumentLists.size(); }
66 assert(Depth < TemplateArgumentLists.size());
67 assert(Index < TemplateArgumentLists[
getNumLevels() - Depth - 1].size());
68 return TemplateArgumentLists[
getNumLevels() - Depth - 1][Index];
76 assert(Depth < TemplateArgumentLists.size());
78 if (Index >= TemplateArgumentLists[
getNumLevels() - Depth - 1].size())
81 return !(*this)(
Depth, Index).isNull();
87 assert(Depth < TemplateArgumentLists.size());
88 assert(Index < TemplateArgumentLists[
getNumLevels() - Depth - 1].size());
90 TemplateArgumentLists[
getNumLevels() - Depth - 1][Index])
98 TemplateArgs->
size()));
104 TemplateArgumentLists.push_back(Args);
109 return TemplateArgumentLists.front();
142 bool DeducedFromArrayBound;
149 bool DeducedFromArrayBound =
false)
155 const llvm::APSInt &
Value,
157 bool DeducedFromArrayBound)
159 DeducedFromArrayBound(DeducedFromArrayBound) { }
168 DeducedFromArrayBound = Deduced;
188 typedef llvm::SmallDenseMap<
189 const Decl *, llvm::PointerUnion<Decl *, DeclArgumentPack *>, 4>
210 LocalDeclsMap LocalDecls;
225 bool CombineWithOuterScope;
238 unsigned NumArgsInPartiallySubstitutedPack;
247 : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope),
248 Exited(
false), CombineWithOuterScope(CombineWithOuterScope),
249 PartiallySubstitutedPack(nullptr)
265 for (
unsigned I = 0, N = ArgumentPacks.size(); I != N; ++I)
266 delete ArgumentPacks[I];
275 if (
this == Outermost)
return this;
284 newScope->Outer =
nullptr;
288 newScope->PartiallySubstitutedPack = PartiallySubstitutedPack;
289 newScope->ArgsInPartiallySubstitutedPack = ArgsInPartiallySubstitutedPack;
290 newScope->NumArgsInPartiallySubstitutedPack =
291 NumArgsInPartiallySubstitutedPack;
293 for (LocalDeclsMap::iterator I = LocalDecls.begin(), E = LocalDecls.end();
295 const Decl *D = I->first;
296 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored =
297 newScope->LocalDecls[D];
298 if (I->second.is<
Decl *>()) {
299 Stored = I->second.get<
Decl *>();
304 newScope->ArgumentPacks.push_back(NewPack);
316 while (Scope && Scope != Outermost) {
331 llvm::PointerUnion<Decl *, DeclArgumentPack *> *
352 unsigned NumExplicitArgs);
357 assert(PartiallySubstitutedPack &&
"No partially-substituted pack");
358 PartiallySubstitutedPack =
nullptr;
359 ArgsInPartiallySubstitutedPack =
nullptr;
360 NumArgsInPartiallySubstitutedPack = 0;
368 unsigned *NumExplicitArgs =
nullptr)
const;
372 :
public DeclVisitor<TemplateDeclInstantiator, Decl *>
386 OutOfLinePartialSpecs;
393 std::pair<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>, 4>
394 OutOfLineVarPartialSpecs;
400 SubstIndex(SemaRef, SemaRef.ArgumentPackSubstitutionIndex),
401 Owner(Owner), TemplateArgs(TemplateArgs), LateAttrs(nullptr),
402 StartingScope(nullptr) {}
405 #define DECL(DERIVED, BASE) \
406 Decl *Visit ## DERIVED ## Decl(DERIVED ## Decl *D);
407 #define ABSTRACT_DECL(DECL)
410 #define OBJCCONTAINER(DERIVED, BASE)
411 #define FILESCOPEASM(DERIVED, BASE)
412 #define IMPORT(DERIVED, BASE)
413 #define LINKAGESPEC(DERIVED, BASE)
414 #define OBJCCOMPATIBLEALIAS(DERIVED, BASE)
415 #define OBJCMETHOD(DERIVED, BASE)
416 #define OBJCTYPEPARAM(DERIVED, BASE)
417 #define OBJCIVAR(DERIVED, BASE)
418 #define OBJCPROPERTY(DERIVED, BASE)
419 #define OBJCPROPERTYIMPL(DERIVED, BASE)
420 #define EMPTY(DERIVED, BASE)
423 #define BLOCK(DERIVED, BASE)
424 #define CAPTURED(DERIVED, BASE)
425 #define IMPLICITPARAM(DERIVED, BASE)
427 #include "clang/AST/DeclNodes.inc"
431 TemplateParameterList *TemplateParams,
432 bool IsClassScopeSpecialization =
false);
434 TemplateParameterList *TemplateParams);
436 Decl *
VisitVarDecl(VarDecl *D,
bool InstantiatingVarTemplate);
448 StartingScope =
nullptr;
468 return OutOfLinePartialSpecs.begin();
472 return OutOfLineVarPartialSpecs.begin();
480 return OutOfLinePartialSpecs.end();
484 return OutOfLineVarPartialSpecs.end();
519 #endif // LLVM_CLANG_SEMA_TEMPLATE_H
MultiLevelTemplateArgumentList()
Construct an empty set of template argument lists.
DeducedTemplateArgument(ASTContext &Ctx, const llvm::APSInt &Value, QualType ValueType, bool DeducedFromArrayBound)
Construct an integral non-type template argument that has been deduced, possibly from an array bound...
delayed_var_partial_spec_iterator delayed_var_partial_spec_begin()
void InstantiatedLocal(const Decl *D, Decl *Inst)
A stack-allocated class that identifies which local variable declaration instantiations are present i...
void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs)
Add a new outermost level to the multi-level template argument list.
bool hasTemplateArgument(unsigned Depth, unsigned Index) const
Determine whether there is a non-NULL template argument at the given depth and index.
llvm::PointerUnion< Decl *, DeclArgumentPack * > * findInstantiationOf(const Decl *D)
Find the instantiation of the declaration D within the current instantiation scope.
Defines the C++ template declaration subclasses.
Decl * InstantiateTypedefNameDecl(TypedefNameDecl *D, bool IsTypeAlias)
void disableLateAttributeInstantiation()
Declaration of a variable template.
A container of type source information.
TemplateDeclInstantiator(Sema &SemaRef, DeclContext *Owner, const MultiLevelTemplateArgumentList &TemplateArgs)
Partial ordering of function templates for a call to a conversion function.
VarTemplatePartialSpecializationDecl * InstantiateVarTemplatePartialSpecialization(VarTemplateDecl *VarTemplate, VarTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a variable template partial specialization.
void SetPartiallySubstitutedPack(NamedDecl *Pack, const TemplateArgument *ExplicitArgs, unsigned NumExplicitArgs)
Note that the given parameter pack has been partially substituted via explicit specification of templ...
bool SubstQualifier(const DeclaratorDecl *OldDecl, DeclaratorDecl *NewDecl)
void InstantiatedLocalPackArg(const Decl *D, Decl *Inst)
SmallVectorImpl< std::pair< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > >::iterator delayed_partial_spec_iterator
Stores a list of template parameters for a TemplateDecl and its derived classes.
SmallVector< Decl *, 4 > DeclArgumentPack
A set of declarations.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
void setDeducedFromArrayBound(bool Deduced)
Specify whether the given non-type template argument was deduced from an array bound.
bool wasDeducedFromArrayBound() const
For a non-type template argument, determine whether the template argument was deduced from an array b...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void setArgument(unsigned Depth, unsigned Index, TemplateArgument Arg)
Clear out a specific template argument.
Decl * VisitVarTemplateSpecializationDecl(VarTemplateDecl *VarTemplate, VarDecl *FromVar, void *InsertPos, const TemplateArgumentListInfo &TemplateArgsInfo, ArrayRef< TemplateArgument > Converted)
unsigned size() const
Retrieve the number of template arguments in this template argument list.
void Exit()
Exit this local instantiation scope early.
delayed_var_partial_spec_iterator delayed_var_partial_spec_end()
bool InitFunctionInstantiation(FunctionDecl *New, FunctionDecl *Tmpl)
Initializes the common fields of an instantiation function declaration (New) from the corresponding f...
const TemplateArgument & operator()(unsigned Depth, unsigned Index) const
Retrieve the template argument at a given depth and index.
DeducedTemplateArgument(const TemplateArgument &Arg, bool DeducedFromArrayBound=false)
RAII object used to change the argument pack substitution index within a Sema object.
void MakeInstantiatedLocalArgPack(const Decl *D)
Sema - This implements semantic analysis and AST building for C.
Represents a ValueDecl that came out of a declarator. Contains type source information through TypeSo...
delayed_partial_spec_iterator delayed_partial_spec_begin()
Return an iterator to the beginning of the set of "delayed" partial specializations, which must be passed to InstantiateClassTemplatePartialSpecialization once the class definition has been completed.
ClassTemplatePartialSpecializationDecl * InstantiateClassTemplatePartialSpecialization(ClassTemplateDecl *ClassTemplate, ClassTemplatePartialSpecializationDecl *PartialSpec)
Instantiate the declaration of a class template partial specialization.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
Data structure that captures multiple levels of template argument lists for use in template instantia...
const Sema & getSema() const
Captures a template argument whose value has been deduced via c++ template argument deduction...
static void deleteScopes(LocalInstantiationScope *Scope, LocalInstantiationScope *Outermost)
deletes the given scope, and all otuer scopes, down to the given outermost scope. ...
void ResetPartiallySubstitutedPack()
Reset the partially-substituted pack when it is no longer of interest.
NamedDecl * getPartiallySubstitutedPack(const TemplateArgument **ExplicitArgs=nullptr, unsigned *NumExplicitArgs=nullptr) const
Retrieve the partially-substitued template parameter pack.
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
SmallVectorImpl< std::pair< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > >::iterator delayed_var_partial_spec_iterator
TagDecl - Represents the declaration of a struct/union/class/enum.
TemplateParameterList * SubstTemplateParams(TemplateParameterList *List)
Instantiates a nested template parameter list in the current instantiation context.
Represents a static or instance method of a struct/union/class.
Decl * VisitDecl(Decl *D)
Decl * VisitVarDecl(VarDecl *D, bool InstantiatingVarTemplate)
void InstantiateEnumDefinition(EnumDecl *Enum, EnumDecl *Pattern)
A simple visitor class that helps create declaration visitors.
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
~LocalInstantiationScope()
Base class for declarations which introduce a typedef-name.
Represents a template argument.
Decl * VisitFunctionDecl(FunctionDecl *D, TemplateParameterList *TemplateParams)
LocalInstantiationScope * cloneScopes(LocalInstantiationScope *Outermost)
Clone this scope, and all outer scopes, down to the given outermost scope.
LocalInstantiationScope * getStartingScope() const
delayed_partial_spec_iterator delayed_partial_spec_end()
Return an iterator to the end of the set of "delayed" partial specializations, which must be passed t...
MultiLevelTemplateArgumentList(const TemplateArgumentList &TemplateArgs)
Construct a single-level template argument list.
void addOuterTemplateArguments(ArgList Args)
Add a new outmost level to the multi-level template argument list.
TypeSourceInfo * SubstFunctionType(FunctionDecl *D, SmallVectorImpl< ParmVarDecl * > &Params)
LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope=false)
A template argument list.
DeducedTemplateArgument()
void enableLateAttributeInstantiation(Sema::LateInstantiatedAttrVec *LA)
TPOC
The context in which partial ordering of function templates occurs.
Declaration of a class template.
Partial ordering of function templates for a function call.
TemplatePartialOrderingContext(TPOC Value)
Partial ordering of function templates in other contexts, e.g., taking the address of a function temp...
bool InitMethodInstantiation(CXXMethodDecl *New, CXXMethodDecl *Tmpl)
Initializes common fields of an instantiated method declaration (New) from the corresponding fields o...
Decl * VisitCXXMethodDecl(CXXMethodDecl *D, TemplateParameterList *TemplateParams, bool IsClassScopeSpecialization=false)