Lines Matching +full:class +full:- +full:d
1 //===- DeclTemplate.h - Classes for representing C++ templates --*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
48 class ClassTemplateDecl;
49 class ClassTemplatePartialSpecializationDecl;
50 class Expr;
51 class FunctionTemplateDecl;
52 class IdentifierInfo;
53 class NonTypeTemplateParmDecl;
54 class TemplateDecl;
55 class TemplateTemplateParmDecl;
56 class TemplateTypeParmDecl;
57 class ConceptDecl;
58 class UnresolvedSetImpl;
59 class VarTemplateDecl;
60 class VarTemplatePartialSpecializationDecl;
71 class TemplateParameterList final
93 /// Whether any of the template parameters has constrained-parameter
94 /// constraint-expression.
113 friend class FixedSizeTemplateParameterListStorage;
145 assert(Idx < size() && "Template parameter index out-of-range"); in getParam()
149 assert(Idx < size() && "Template parameter index out-of-range"); in getParam()
174 if (P->isParameterPack()) in hasParameterPack()
179 /// The constraint-expression of the associated requires-clause.
184 /// The constraint-expression of the associated requires-clause.
191 /// constrained-parameters.
218 /// requires-clause (if any) for a TemplateDecl and its derived classes.
221 class FixedSizeTemplateParameterListStorage
243 class TemplateArgumentList final
299 class DefaultArgStorage {
308 "non-pointer argument type?");
313 const DefaultArgStorage &Storage = Parm->getDefaultArgStorage(); in getParmOwningDefaultArg()
316 assert(!Parm->getDefaultArgStorage() in getParmOwningDefaultArg()
337 Storage = &Prev->getDefaultArgStorage(); in get()
338 if (const auto *C = Storage->ValueOrInherited.template dyn_cast<Chain *>()) in get()
339 return C->Value; in get()
340 return Storage->ValueOrInherited.template get<ArgType>(); in get()
346 if (const auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>()) in getInheritedFrom() local
347 return D; in getInheritedFrom()
349 return C->PrevDeclWithDefaultArg; in getInheritedFrom()
364 else if ([[maybe_unused]] auto *D = in setInherited() local
366 assert(C.isSameDefaultTemplateArgument(D, InheritedFrom)); in setInherited()
371 assert(C.isSameDefaultTemplateArgument(Inherited->PrevDeclWithDefaultArg, in setInherited()
373 Inherited->PrevDeclWithDefaultArg = InheritedFrom; in setInherited()
385 //===----------------------------------------------------------------------===//
387 //===----------------------------------------------------------------------===//
389 /// \brief The base class of all kinds of template declarations (e.g.,
390 /// class, function, etc.).
392 /// The TemplateDecl class stores the list of template parameters and a
394 class TemplateDecl : public NamedDecl {
403 // Used when there is no templated element (e.g., for tt-params).
409 friend class ASTDeclReader;
410 friend class ASTDeclWriter;
417 /// \brief Get the total constraint-expression associated with this template,
418 /// including constraint-expressions derived from the requires-clause,
419 /// trailing requires-clause (for functions and methods) and constrained
432 static bool classof(const Decl *D) { return classofKind(D->getKind()); } in classof() argument
439 return SourceRange(getTemplateParameters()->getTemplateLoc(), in getSourceRange()
440 TemplatedDecl->getSourceRange().getEnd()); in getSourceRange()
464 class FunctionTemplateSpecializationInfo final
484 /// FIXME: Normally null; tail-allocate this.
497 : Function(FD, MSInfo ? true : false), Template(Template, TSK - 1), in FunctionTemplateSpecializationInfo()
545 Template.setInt(TSK - 1); in setTemplateSpecializationKind()
588 /// and represents the relationship between the function and the class-scope
589 /// explicit specialization in the original templated class -- whereas our
600 Profile(ID, TemplateArguments->asArray(), getFunction()->getASTContext()); in Profile()
612 /// Provides information a specialization of a member of a class
614 /// member class or member enumeration.
615 class MemberSpecializationInfo {
627 : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) {
649 MemberAndTSK.setInt(TSK - 1); in setTemplateSpecializationKind()
665 /// Provides information about a dependent function-template
669 /// within class templates:
679 /// specializations declared within class templates:
682 /// template \<class T> void foo(T);
683 /// template \<class T> class A {
687 class DependentFunctionTemplateSpecializationInfo final
714 class RedeclarableTemplateDecl : public TemplateDecl,
736 static DeclType *getDecl(EntryType *D) { in getDecl()
737 return D; in getDecl()
740 static ArrayRef<TemplateArgument> getTemplateArgs(EntryType *D) { in getTemplateArgs()
741 return D->getTemplateArgs().asArray(); in getTemplateArgs()
760 return SETraits::getDecl(&*this->I)->getMostRecentDecl();
763 DeclType *operator->() const { return **this; }
774 template <class EntryType, typename ...ProfileArguments>
779 template <class Derived, class EntryType>
794 /// If non-null, points to an array of specializations (including
815 /// Retrieves the "common" pointer shared by all (re-)declarations of
829 friend class ASTDeclReader;
830 friend class ASTDeclWriter;
831 friend class ASTReader;
832 template <class decl_type> friend class RedeclarableTemplate;
861 return getCommonPtr()->InstantiatedFromMember.getInt(); in isMemberSpecialization()
866 assert(getCommonPtr()->InstantiatedFromMember.getPointer() && in setMemberSpecialization()
868 getCommonPtr()->InstantiatedFromMember.setInt(true); in setMemberSpecialization()
876 /// template itself is part of a class template (or member thereof). For
900 /// the class template \c X<T>, i.e.,
908 return getCommonPtr()->InstantiatedFromMember.getPointer(); in getInstantiatedFromMemberTemplate()
912 assert(!getCommonPtr()->InstantiatedFromMember.getPointer()); in setInstantiatedFromMemberTemplate()
913 getCommonPtr()->InstantiatedFromMember.setPointer(TD); in setInstantiatedFromMemberTemplate()
935 static bool classof(const Decl *D) { return classofKind(D->getKind()); } in classof() argument
947 return I->getFunction();
952 return I->TemplateArguments->asArray();
957 class FunctionTemplateDecl : public RedeclarableTemplateDecl {
959 friend class FunctionDecl;
996 friend class ASTDeclReader;
997 friend class ASTDeclWriter;
999 /// Load any lazily-loaded specializations from the external source.
1010 return getTemplatedDecl()->isThisDeclarationADefinition();
1031 static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl());
1035 static_cast<const RedeclarableTemplateDecl *>(this)->getPreviousDecl());
1041 ->getMostRecentDecl());
1044 return const_cast<FunctionTemplateDecl*>(this)->getMostRecentDecl();
1075 return TPL->getParam(TPL->size() - 1)->isImplicit();
1093 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1097 //===----------------------------------------------------------------------===//
1099 //===----------------------------------------------------------------------===//
1105 /// sequentially for out-of-line template members, each template parameter is
1106 /// given a Depth - the nesting of template parameter scopes - and a Position -
1108 /// This class is inheritedly privately by different kinds of template
1110 class TemplateParmPosition {
1116 static constexpr unsigned MaxDepth = (1U << DepthWidth) - 1;
1117 static constexpr unsigned MaxPosition = (1U << PositionWidth) - 1;
1119 TemplateParmPosition(unsigned D, unsigned P) : Depth(D), Position(P) {
1122 assert((D + 1) <= MaxDepth &&
1133 void setDepth(unsigned D) {
1134 assert((D + 1) <= MaxDepth &&
1136 Depth = D;
1155 /// template<typename T> class vector;
1157 class TemplateTypeParmDecl final : public TypeDecl,
1160 friend class Sema;
1162 friend class ASTDeclReader;
1167 /// If false, it was declared with the 'class' keyword.
1170 /// Whether this template type parameter has a type-constraint construct.
1203 SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id,
1215 /// If not, it was either declared with the 'class' keyword or with a
1216 /// type-constraint (see hasTypeConstraint()).
1259 /// the 'typename' or 'class' keyword.
1274 /// type-constraint contains an unexpanded parameter pack.
1279 if (TC->hasExplicitTemplateArgs())
1280 for (const auto &ArgLoc : TC->getTemplateArgsAsWritten()->arguments())
1287 /// list of different type-constraints at different positions.
1290 /// parameter pack's type-constraint was itself a pack expansion, and that
1302 /// its type-constraint. When \c Types is supplied with template arguments by
1325 /// Determine whether this template parameter has a type-constraint.
1330 /// \brief Get the associated-constraints of this template parameter.
1331 /// This will either be the immediately-introduced constraint or empty.
1337 AC.push_back(getTypeConstraint()->getImmediatelyDeclaredConstraint());
1343 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1347 /// NonTypeTemplateParmDecl - Declares a non-type template parameter,
1350 /// template<int Size> class array { };
1352 class NonTypeTemplateParmDecl final
1358 friend class ASTDeclReader;
1370 /// Whether this non-type template parameter is a parameter pack.
1373 /// Whether this non-type template parameter is an "expanded"
1387 SourceLocation IdLoc, unsigned D, unsigned P,
1391 TemplateParmPosition(D, P), ParameterPack(ParameterPack) {}
1394 SourceLocation IdLoc, unsigned D, unsigned P,
1403 SourceLocation IdLoc, unsigned D, unsigned P, const IdentifierInfo *Id,
1408 SourceLocation IdLoc, unsigned D, unsigned P, const IdentifierInfo *Id,
1461 /// Whether this parameter is a non-type template parameter pack.
1474 /// A non-type template parameter pack is a pack expansion if its type
1478 return ParameterPack && getType()->getAs<PackExpansionType>();
1481 /// Whether this parameter is a non-type template parameter pack
1517 assert(I < NumExpandedTypes && "Out-of-range expansion type index");
1526 assert(I < NumExpandedTypes && "Out-of-range expansion type index");
1532 /// Return the constraint introduced by the placeholder type of this non-type
1543 /// Determine whether this non-type template parameter's type has a
1544 /// placeholder with a type-constraint.
1546 auto *AT = getType()->getContainedAutoType();
1547 return AT && AT->isConstrained();
1550 /// \brief Get the associated-constraints of this template parameter.
1551 /// This will either be a vector of size 1 containing the immediately-declared
1562 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1566 /// TemplateTemplateParmDecl - Declares a template template parameter,
1569 /// template <template <typename> class T> class container { };
1573 class TemplateTemplateParmDecl final
1586 /// If false, it was declared with the 'class' keyword.
1603 TemplateTemplateParmDecl(DeclContext *DC, SourceLocation L, unsigned D,
1607 TemplateParmPosition(D, P), Typename(Typename),
1610 TemplateTemplateParmDecl(DeclContext *DC, SourceLocation L, unsigned D,
1618 friend class ASTDeclReader;
1619 friend class ASTDeclWriter;
1623 SourceLocation L, unsigned D,
1628 Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D,
1649 /// the 'typename' or 'class' keyword.
1656 /// template<template <class T> ...MetaFunctions> struct Apply;
1666 getTemplateParameters()->containsUnexpandedParameterPack();
1679 /// template<template<Types> class...Templates> struct Inner;
1699 assert(I < NumExpandedParams && "Out-of-range expansion type index");
1741 return SourceRange(getTemplateParameters()->getTemplateLoc(), End);
1745 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1752 class BuiltinTemplateDecl : public TemplateDecl {
1762 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
1778 /// Provides information about an explicit instantiation of a variable or class
1797 /// Represents a class template specialization, which refers to
1798 /// a class template with a given set of template arguments.
1800 /// Class template specializations represent both explicit
1801 /// specialization of class templates, as in the example below, and
1802 /// implicit instantiations of class templates.
1805 /// template<typename T> class array;
1808 /// class array<bool> { }; // class template specialization array<bool>
1810 class ClassTemplateSpecializationDecl : public CXXRecordDecl,
1812 /// Structure that stores information about a class template
1813 /// specialization that was instantiated from a class template partial
1816 /// The class template partial specialization from which this
1817 /// class template specialization was instantiated.
1820 /// The template argument list deduced for the class template
1854 friend class ASTDeclReader;
1855 friend class ASTDeclWriter;
1873 // declaration as a CXXRecordDecl sometimes is the injected-class-name.
1882 /// Retrieve the template arguments of the class template
1902 /// Is this an explicit specialization at class scope (within the class that
1908 /// template<> struct Inner; // class-scope explicit specialization
1942 /// If this class template specialization is an instantiation of
1944 /// class template or class template partial specialization from which it
1956 /// Retrieve the class template or class template partial
1963 return PartialSpec->PartialSpecialization;
1969 /// to instantiate members of the class template or class template partial
1970 /// specialization from which this class template specialization was
1973 /// \returns For a class template specialization instantiated from the primary
1975 /// getTemplateArgs(). For a class template specialization instantiated from
1976 /// a class template partial specialization, this function will return the
1977 /// deduced template arguments for the class template partial specialization
1982 return *PartialSpec->TemplateArgs;
1987 /// Note that this class template specialization is actually an
1988 /// instantiation of the given class template partial specialization whose
1993 "Already set to a class template partial specialization!");
1995 PS->PartialSpecialization = PartialSpec;
1996 PS->TemplateArgs = TemplateArgs;
2000 /// Note that this class template specialization is an instantiation
2001 /// of the given class template.
2004 "Previously set to a class template partial specialization!");
2012 return Info->TemplateArgsAsWritten;
2020 Info->TemplateArgsAsWritten = ArgsWritten;
2034 return Info->ExternKeywordLoc;
2044 return Info->TemplateKeywordLoc;
2054 Profile(ID, TemplateArgs->asArray(), getASTContext());
2065 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2073 class ClassTemplatePartialSpecializationDecl
2078 /// The class template partial specialization from which this
2079 /// class template partial specialization was instantiated.
2081 /// The boolean value will be true to indicate that this class template
2099 friend class ASTDeclReader;
2100 friend class ASTDeclWriter;
2115 this)->getMostRecentDecl());
2125 /// constrained-parameters.
2130 TemplateParams->getAssociatedConstraints(AC);
2134 return TemplateParams->hasAssociatedConstraints();
2137 /// Retrieve the member class template partial specialization from
2138 /// which this particular class template partial specialization was
2153 /// \c Outer<float>::Inner<U*>, which itself was instantiated from the class
2160 return First->InstantiatedFromMember.getPointer();
2170 First->InstantiatedFromMember.setPointer(PartialSpec);
2173 /// Determines whether this class template partial specialization
2192 return First->InstantiatedFromMember.getInt();
2198 assert(First->InstantiatedFromMember.getPointer() &&
2200 return First->InstantiatedFromMember.setInt(true);
2204 /// specialization. This is not the same as the type-decl-type for
2209 ->getInjectedSpecializationType();
2223 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2230 /// Declaration of a class template.
2231 class ClassTemplateDecl : public RedeclarableTemplateDecl {
2234 /// class template.
2236 /// The class template specializations for this class
2240 /// The class template partial specializations for this class
2245 /// The injected-class-name type for this class template.
2251 /// Retrieve the set of specializations of this class template.
2255 /// Retrieve the set of partial specializations of this class
2277 friend class ASTDeclReader;
2278 friend class ASTDeclWriter;
2279 friend class TemplateDeclInstantiator;
2281 /// Load any lazily-loaded specializations from the external source.
2284 /// Get the underlying class declarations of the template.
2290 /// class pattern.
2292 return getTemplatedDecl()->isThisDeclarationADefinition();
2295 /// \brief Create a class template node.
2302 /// Create an empty class template node.
2312 void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos);
2323 /// Retrieve the previous declaration of this class template, or
2327 static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl());
2332 this)->getPreviousDecl());
2337 static_cast<RedeclarableTemplateDecl *>(this)->getMostRecentDecl());
2340 return const_cast<ClassTemplateDecl*>(this)->getMostRecentDecl();
2356 void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D,
2363 /// Find a class template partial specialization with the given
2366 /// \param T a dependent type that names a specialization of this class
2369 /// \returns the class template partial specialization that exactly matches
2373 /// Find a class template partial specialization which was instantiated
2376 /// \param D a member class template partial specialization.
2378 /// \returns the class template partial specialization which was instantiated
2383 ClassTemplatePartialSpecializationDecl *D);
2386 /// injected-class-name for this class template.
2388 /// The injected-class-name for a class template \c X is \c
2389 /// X<template-args>, where \c template-args is formed from the
2417 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2425 /// template \<typename T> class A {
2426 /// friend class MyVector<T>; // not a friend template
2427 /// template \<typename U> friend class B; // not a friend template
2428 /// template \<typename U> friend class Foo<T>::Nested; // friend template
2432 /// \note This class is not currently in use. All of the above
2434 class FriendTemplateDecl : public Decl {
2441 // The number of template parameters; always non-zero.
2447 // The declaration that's a friend of this class.
2462 friend class ASTDeclReader;
2500 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2510 class TypeAliasTemplateDecl : public RedeclarableTemplateDecl {
2527 friend class ASTDeclReader;
2528 friend class ASTDeclWriter;
2549 static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl());
2554 this)->getPreviousDecl());
2574 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2591 class VarTemplateSpecializationDecl : public VarDecl,
2643 friend class ASTDeclReader;
2644 friend class ASTDeclWriter;
2645 friend class VarDecl;
2659 VarDecl *Recent = static_cast<VarDecl *>(this)->getMostRecentDecl();
2728 return PartialSpec->PartialSpecialization;
2747 return *PartialSpec->TemplateArgs;
2760 PS->PartialSpecialization = PartialSpec;
2761 PS->TemplateArgs = TemplateArgs;
2777 return Info->TemplateArgsAsWritten;
2785 Info->TemplateArgsAsWritten = ArgsWritten;
2799 return Info->ExternKeywordLoc;
2809 return Info->TemplateKeywordLoc;
2819 Profile(ID, TemplateArgs->asArray(), getASTContext());
2830 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2838 class VarTemplatePartialSpecializationDecl
2865 friend class ASTDeclReader;
2866 friend class ASTDeclWriter;
2881 this)->getMostRecentDecl());
2891 /// constrained-parameters.
2896 TemplateParams->getAssociatedConstraints(AC);
2900 return TemplateParams->hasAssociatedConstraints();
2926 return First->InstantiatedFromMember.getPointer();
2932 First->InstantiatedFromMember.setPointer(PartialSpec);
2954 return First->InstantiatedFromMember.getInt();
2960 assert(First->InstantiatedFromMember.getPointer() &&
2962 return First->InstantiatedFromMember.setInt(true);
2976 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
2984 class VarTemplateDecl : public RedeclarableTemplateDecl {
3005 /// Retrieve the set of partial specializations of this class
3022 friend class ASTDeclReader;
3023 friend class ASTDeclWriter;
3025 /// Load any lazily-loaded specializations from the external source.
3036 return getTemplatedDecl()->isThisDeclarationADefinition();
3057 void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos);
3070 static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl());
3075 this)->getPreviousDecl());
3080 static_cast<RedeclarableTemplateDecl *>(this)->getMostRecentDecl());
3083 return const_cast<VarTemplateDecl *>(this)->getMostRecentDecl();
3099 void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D,
3110 /// \param D a member variable template partial specialization.
3117 VarTemplatePartialSpecializationDecl *D);
3135 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3140 class ConceptDecl : public TemplateDecl, public Mergeable<ConceptDecl> {
3160 return SourceRange(getTemplateParameters()->getTemplateLoc(),
3161 ConstraintExpr->getEndLoc());
3165 return isa<TemplateTypeParmDecl>(getTemplateParameters()->getParam(0));
3172 return const_cast<ConceptDecl *>(this)->getCanonicalDecl();
3176 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3179 friend class ASTReader;
3180 friend class ASTDeclReader;
3181 friend class ASTDeclWriter;
3187 class ImplicitConceptSpecializationDecl final
3212 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3215 friend class ASTDeclReader;
3220 /// Template parameter objects represent values of class type used as template
3230 class TemplateParamObjectDecl : public ValueDecl,
3249 friend class ASTContext;
3250 friend class ASTReader;
3251 friend class ASTDeclReader;
3254 /// Print this template parameter object in a human-readable format.
3285 static bool classof(const Decl *D) { return classofKind(D->getKind()); }
3297 inline TemplateDecl *getAsTypeTemplateDecl(Decl *D) {
3298 auto *TD = dyn_cast<TemplateDecl>(D);
3312 /// template<Ts ...NTs, template<Ts> class ...TTs, typename ...Us> struct B;
3320 if (TTP->isExpandedParameterPack())
3321 return TTP->getNumExpansionParameters();
3325 if (NTTP->isExpandedParameterPack())
3326 return NTTP->getNumExpansionTypes();
3330 if (TTP->isExpandedParameterPack())
3331 return TTP->getNumExpansionTemplateParameters();
3339 TemplateParameterList *getReplacedTemplateParameterList(Decl *D);