12 #ifndef LLVM_CLANG_SEMA_TEMPLATE_H 13 #define LLVM_CLANG_SEMA_TEMPLATE_H 18 #include "llvm/ADT/SmallVector.h" 52 unsigned NumRetainedOuterLevels = 0;
67 return TemplateArgumentLists.size() + NumRetainedOuterLevels;
73 return TemplateArgumentLists.size();
78 assert(NumRetainedOuterLevels <= Depth && Depth <
getNumLevels());
79 assert(Index < TemplateArgumentLists[
getNumLevels() - Depth - 1].size());
80 return TemplateArgumentLists[
getNumLevels() - Depth - 1][Index];
90 if (Depth < NumRetainedOuterLevels)
93 if (Index >= TemplateArgumentLists[
getNumLevels() - Depth - 1].size())
96 return !(*this)(
Depth, Index).isNull();
102 assert(NumRetainedOuterLevels <= Depth && Depth <
getNumLevels());
103 assert(Index < TemplateArgumentLists[
getNumLevels() - Depth - 1].size());
105 TemplateArgumentLists[
getNumLevels() - Depth - 1][Index])
113 TemplateArgs->
size()));
119 assert(!NumRetainedOuterLevels &&
120 "substituted args outside retained args?");
121 TemplateArgumentLists.push_back(Args);
128 ++NumRetainedOuterLevels;
133 return TemplateArgumentLists.front();
166 bool DeducedFromArrayBound;
173 bool DeducedFromArrayBound =
false)
179 const llvm::APSInt &
Value,
181 bool DeducedFromArrayBound)
183 DeducedFromArrayBound(DeducedFromArrayBound) { }
192 DeducedFromArrayBound = Deduced;
212 typedef llvm::SmallDenseMap<
213 const Decl *, llvm::PointerUnion<Decl *, DeclArgumentPack *>, 4>
234 LocalDeclsMap LocalDecls;
249 bool CombineWithOuterScope;
262 unsigned NumArgsInPartiallySubstitutedPack;
271 : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope),
272 Exited(
false), CombineWithOuterScope(CombineWithOuterScope),
273 PartiallySubstitutedPack(nullptr)
289 for (
unsigned I = 0, N = ArgumentPacks.size(); I != N; ++I)
290 delete ArgumentPacks[I];
299 if (
this == Outermost)
return this;
308 newScope->Outer =
nullptr;
312 newScope->PartiallySubstitutedPack = PartiallySubstitutedPack;
313 newScope->ArgsInPartiallySubstitutedPack = ArgsInPartiallySubstitutedPack;
314 newScope->NumArgsInPartiallySubstitutedPack =
315 NumArgsInPartiallySubstitutedPack;
317 for (LocalDeclsMap::iterator I = LocalDecls.begin(), E = LocalDecls.end();
319 const Decl *D = I->first;
320 llvm::PointerUnion<Decl *, DeclArgumentPack *> &Stored =
321 newScope->LocalDecls[D];
322 if (I->second.is<Decl *>()) {
323 Stored = I->second.get<Decl *>();
325 DeclArgumentPack *OldPack = I->second.get<DeclArgumentPack *>();
326 DeclArgumentPack *NewPack =
new DeclArgumentPack(*OldPack);
328 newScope->ArgumentPacks.push_back(NewPack);
340 while (Scope && Scope != Outermost) {
355 llvm::PointerUnion<Decl *, DeclArgumentPack *> *
358 void InstantiatedLocal(
const Decl *D, Decl *Inst);
359 void InstantiatedLocalPackArg(
const Decl *D,
ParmVarDecl *Inst);
360 void MakeInstantiatedLocalArgPack(
const Decl *D);
374 void SetPartiallySubstitutedPack(
NamedDecl *Pack,
376 unsigned NumExplicitArgs);
381 assert(PartiallySubstitutedPack &&
"No partially-substituted pack");
382 PartiallySubstitutedPack =
nullptr;
383 ArgsInPartiallySubstitutedPack =
nullptr;
384 NumArgsInPartiallySubstitutedPack = 0;
391 getPartiallySubstitutedPack(
const TemplateArgument **ExplicitArgs =
nullptr,
392 unsigned *NumExplicitArgs =
nullptr)
const;
396 :
public DeclVisitor<TemplateDeclInstantiator, Decl *>
410 OutOfLinePartialSpecs;
417 std::pair<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>, 4>
418 OutOfLineVarPartialSpecs;
424 SubstIndex(SemaRef, SemaRef.ArgumentPackSubstitutionIndex),
425 Owner(Owner), TemplateArgs(TemplateArgs), LateAttrs(nullptr),
426 StartingScope(nullptr) {}
429 #define DECL(DERIVED, BASE) \ 430 Decl *Visit ## DERIVED ## Decl(DERIVED ## Decl *D); 431 #define ABSTRACT_DECL(DECL) 434 #define OBJCCONTAINER(DERIVED, BASE) 435 #define FILESCOPEASM(DERIVED, BASE) 436 #define IMPORT(DERIVED, BASE) 437 #define EXPORT(DERIVED, BASE) 438 #define LINKAGESPEC(DERIVED, BASE) 439 #define OBJCCOMPATIBLEALIAS(DERIVED, BASE) 440 #define OBJCMETHOD(DERIVED, BASE) 441 #define OBJCTYPEPARAM(DERIVED, BASE) 442 #define OBJCIVAR(DERIVED, BASE) 443 #define OBJCPROPERTY(DERIVED, BASE) 444 #define OBJCPROPERTYIMPL(DERIVED, BASE) 445 #define EMPTY(DERIVED, BASE) 448 #define BLOCK(DERIVED, BASE) 449 #define CAPTURED(DERIVED, BASE) 450 #define IMPLICITPARAM(DERIVED, BASE) 452 #include "clang/AST/DeclNodes.inc" 455 Decl *VisitCXXMethodDecl(CXXMethodDecl *D,
456 TemplateParameterList *TemplateParams,
457 bool IsClassScopeSpecialization =
false);
458 Decl *VisitFunctionDecl(FunctionDecl *D,
459 TemplateParameterList *TemplateParams);
460 Decl *VisitDecl(Decl *D);
461 Decl *VisitVarDecl(VarDecl *D,
bool InstantiatingVarTemplate,
462 ArrayRef<BindingDecl *> *Bindings =
nullptr);
474 StartingScope =
nullptr;
481 ClassTemplatePartialSpecializationDecl *> >
494 return OutOfLinePartialSpecs.begin();
498 return OutOfLineVarPartialSpecs.begin();
506 return OutOfLinePartialSpecs.end();
510 return OutOfLineVarPartialSpecs.end();
527 Decl *VisitVarTemplateSpecializationDecl(
528 VarTemplateDecl *VarTemplate,
VarDecl *FromVar,
void *InsertPos,
533 ClassTemplatePartialSpecializationDecl *
534 InstantiateClassTemplatePartialSpecialization(
535 ClassTemplateDecl *ClassTemplate,
536 ClassTemplatePartialSpecializationDecl *PartialSpec);
538 InstantiateVarTemplatePartialSpecialization(
539 VarTemplateDecl *VarTemplate,
545 Decl *instantiateUnresolvedUsingDecl(
T *D,
546 bool InstantiatingPackElement =
false);
550 #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...
An instance of this class is created to represent a function declaration or definition.
delayed_var_partial_spec_iterator delayed_var_partial_spec_begin()
A (possibly-)qualified type.
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.
unsigned size() const
Retrieve the number of template arguments in this template argument list.
Decl - This represents one declaration (or definition), e.g.
Defines the C++ template declaration subclasses.
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.
LocalInstantiationScope * getStartingScope() const
VarDecl - An instance of this class is created to represent a variable declaration or definition...
const Sema & getSema() const
SmallVectorImpl< std::pair< ClassTemplateDecl *, ClassTemplatePartialSpecializationDecl * > >::iterator delayed_partial_spec_iterator
Stores a list of template parameters for a TemplateDecl and its derived classes.
ParmVarDecl - Represents a parameter to a function.
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.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SmallVector< ParmVarDecl *, 4 > DeclArgumentPack
A set of declarations.
void setArgument(unsigned Depth, unsigned Index, TemplateArgument Arg)
Clear out a specific template argument.
void Exit()
Exit this local instantiation scope early.
delayed_var_partial_spec_iterator delayed_var_partial_spec_end()
A convenient class for passing around template argument information.
Scope - A scope is a transient data structure that is used while parsing the program.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
DeducedTemplateArgument(const TemplateArgument &Arg, bool DeducedFromArrayBound=false)
RAII object used to change the argument pack substitution index within a Sema object.
Sema - This implements semantic analysis and AST building for C.
Represents a ValueDecl that came out of a declarator.
unsigned getNumSubstitutedLevels() const
Determine the number of substituted levels in this template argument list.
void addOuterRetainedLevel()
Add an outermost level that we are not substituting.
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
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.
const FunctionProtoType * T
Data structure that captures multiple levels of template argument lists for use in template instantia...
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. ...
const TemplateArgument & operator()(unsigned Depth, unsigned Index) const
Retrieve the template argument at a given depth and index.
void ResetPartiallySubstitutedPack()
Reset the partially-substituted pack when it is no longer of interest.
SmallVectorImpl< std::pair< VarTemplateDecl *, VarTemplatePartialSpecializationDecl * > >::iterator delayed_var_partial_spec_iterator
TagDecl - Represents the declaration of a struct/union/class/enum.
Represents a static or instance method of a struct/union/class.
A simple visitor class that helps create declaration visitors.
bool hasTemplateArgument(unsigned Depth, unsigned Index) const
Determine whether there is a non-NULL template argument at the given depth and index.
~LocalInstantiationScope()
Base class for declarations which introduce a typedef-name.
Represents a template argument.
Dataflow Directional Tag Classes.
LocalInstantiationScope * cloneScopes(LocalInstantiationScope *Outermost)
Clone this scope, and all outer scopes, down to the given outermost scope.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
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...
static NamedDecl * findInstantiationOf(ASTContext &Ctx, NamedDecl *D, ForwardIterator first, ForwardIterator last)
EnumDecl - Represents an enum.
MultiLevelTemplateArgumentList(const TemplateArgumentList &TemplateArgs)
Construct a single-level template argument list.
bool wasDeducedFromArrayBound() const
For a non-type template argument, determine whether the template argument was deduced from an array b...
void addOuterTemplateArguments(ArgList Args)
Add a new outmost level to the multi-level template argument list.
LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope=false)
static bool SubstQualifier(Sema &SemaRef, const DeclT *OldDecl, DeclT *NewDecl, const MultiLevelTemplateArgumentList &TemplateArgs)
unsigned getNumLevels() const
Determine the number of levels in this template argument list.
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)
NamedDecl - This represents a decl with a name.
Partial ordering of function templates in other contexts, e.g., taking the address of a function temp...