diff options
Diffstat (limited to 'include/clang/AST/DeclTemplate.h')
-rw-r--r-- | include/clang/AST/DeclTemplate.h | 480 |
1 files changed, 243 insertions, 237 deletions
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h index 2879452f2404..7842d7097174 100644 --- a/include/clang/AST/DeclTemplate.h +++ b/include/clang/AST/DeclTemplate.h @@ -1,4 +1,4 @@ -//===-- DeclTemplate.h - Classes for representing C++ templates -*- C++ -*-===// +//===- DeclTemplate.h - Classes for representing C++ templates --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -6,42 +6,60 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -/// +// /// \file /// \brief Defines the C++ template declaration subclasses. -/// +// //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_AST_DECLTEMPLATE_H #define LLVM_CLANG_AST_DECLTEMPLATE_H +#include "clang/AST/Decl.h" +#include "clang/AST/DeclBase.h" #include "clang/AST/DeclCXX.h" +#include "clang/AST/DeclarationName.h" #include "clang/AST/Redeclarable.h" #include "clang/AST/TemplateBase.h" +#include "clang/AST/Type.h" +#include "clang/Basic/LLVM.h" +#include "clang/Basic/SourceLocation.h" +#include "clang/Basic/Specifiers.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" +#include "llvm/ADT/iterator.h" +#include "llvm/ADT/iterator_range.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/TrailingObjects.h" +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <iterator> #include <utility> namespace clang { enum BuiltinTemplateKind : int; -class TemplateParameterList; -class TemplateDecl; -class RedeclarableTemplateDecl; -class FunctionTemplateDecl; class ClassTemplateDecl; class ClassTemplatePartialSpecializationDecl; -class TemplateTypeParmDecl; +class Expr; +class FunctionTemplateDecl; +class IdentifierInfo; class NonTypeTemplateParmDecl; +class TemplateDecl; class TemplateTemplateParmDecl; -class TypeAliasTemplateDecl; +class TemplateTypeParmDecl; +class UnresolvedSetImpl; class VarTemplateDecl; class VarTemplatePartialSpecializationDecl; /// \brief Stores a template parameter of any kind. -typedef llvm::PointerUnion3<TemplateTypeParmDecl*, NonTypeTemplateParmDecl*, - TemplateTemplateParmDecl*> TemplateParameter; +using TemplateParameter = + llvm::PointerUnion3<TemplateTypeParmDecl *, NonTypeTemplateParmDecl *, + TemplateTemplateParmDecl *>; NamedDecl *getAsNamedDecl(TemplateParameter P); @@ -50,7 +68,6 @@ NamedDecl *getAsNamedDecl(TemplateParameter P); class TemplateParameterList final : private llvm::TrailingObjects<TemplateParameterList, NamedDecl *, Expr *> { - /// The location of the 'template' keyword. SourceLocation TemplateLoc; @@ -69,6 +86,10 @@ class TemplateParameterList final unsigned HasRequiresClause : 1; protected: + TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, + ArrayRef<NamedDecl *> Params, SourceLocation RAngleLoc, + Expr *RequiresClause); + size_t numTrailingObjects(OverloadToken<NamedDecl *>) const { return NumParams; } @@ -77,11 +98,11 @@ protected: return HasRequiresClause; } - TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc, - ArrayRef<NamedDecl *> Params, SourceLocation RAngleLoc, - Expr *RequiresClause); - public: + template <size_t N, bool HasRequiresClause> + friend class FixedSizeTemplateParameterListStorage; + friend TrailingObjects; + static TemplateParameterList *Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, @@ -90,10 +111,10 @@ public: Expr *RequiresClause); /// \brief Iterates through the template parameters in this list. - typedef NamedDecl** iterator; + using iterator = NamedDecl **; /// \brief Iterates through the template parameters in this list. - typedef NamedDecl* const* const_iterator; + using const_iterator = NamedDecl * const *; iterator begin() { return getTrailingObjects<NamedDecl *>(); } const_iterator begin() const { return getTrailingObjects<NamedDecl *>(); } @@ -113,7 +134,6 @@ public: assert(Idx < size() && "Template parameter index out-of-range"); return begin()[Idx]; } - const NamedDecl* getParam(unsigned Idx) const { assert(Idx < size() && "Template parameter index out-of-range"); return begin()[Idx]; @@ -157,11 +177,6 @@ public: return SourceRange(TemplateLoc, RAngleLoc); } - friend TrailingObjects; - - template <size_t N, bool HasRequiresClause> - friend class FixedSizeTemplateParameterListStorage; - public: // FIXME: workaround for MSVC 2013; remove when no longer needed using FixedSizeStorageOwner = TrailingObjects::FixedSizeStorageOwner; @@ -201,14 +216,16 @@ class TemplateArgumentList final /// argument list. unsigned NumArguments; - TemplateArgumentList(const TemplateArgumentList &Other) = delete; - void operator=(const TemplateArgumentList &Other) = delete; - // Constructs an instance with an internal Argument list, containing // a copy of the Args array. (Called by CreateCopy) TemplateArgumentList(ArrayRef<TemplateArgument> Args); public: + friend TrailingObjects; + + TemplateArgumentList(const TemplateArgumentList &) = delete; + TemplateArgumentList &operator=(const TemplateArgumentList &) = delete; + /// \brief Type used to indicate that the template argument list itself is a /// stack object. It does not own its template arguments. enum OnStackType { OnStack }; @@ -254,8 +271,6 @@ public: /// \brief Retrieve a pointer to the template argument list. const TemplateArgument *data() const { return Arguments; } - - friend TrailingObjects; }; void *allocateDefaultArgStorageChain(const ASTContext &C); @@ -297,9 +312,11 @@ public: /// Determine whether there is a default argument for this parameter. bool isSet() const { return !ValueOrInherited.isNull(); } + /// Determine whether the default argument for this parameter was inherited /// from a previous declaration of the same entity. bool isInherited() const { return ValueOrInherited.template is<ParmDecl*>(); } + /// Get the default argument's value. This does not consider whether the /// default argument is visible. ArgType get() const { @@ -310,6 +327,7 @@ public: return C->Value; return Storage->ValueOrInherited.template get<ArgType>(); } + /// Get the parameter from which we inherit the default argument, if any. /// This is the parameter on which the default argument was actually written. const ParmDecl *getInheritedFrom() const { @@ -319,11 +337,13 @@ public: return C->PrevDeclWithDefaultArg; return nullptr; } + /// Set the default argument. void set(ArgType Arg) { assert(!isSet() && "default argument already set"); ValueOrInherited = Arg; } + /// Set that the default argument was inherited from another parameter. void setInherited(const ASTContext &C, ParmDecl *InheritedFrom) { assert(!isInherited() && "default argument already inherited"); @@ -334,6 +354,7 @@ public: ValueOrInherited = new (allocateDefaultArgStorageChain(C)) Chain{InheritedFrom, ValueOrInherited.template get<ArgType>()}; } + /// Remove the default argument, even if it was inherited. void clear() { ValueOrInherited = ArgType(); @@ -350,7 +371,7 @@ class ConstrainedTemplateDeclInfo { friend TemplateDecl; public: - ConstrainedTemplateDeclInfo() : TemplateParams(), AssociatedConstraints() {} + ConstrainedTemplateDeclInfo() = default; TemplateParameterList *getTemplateParameters() const { return TemplateParams; @@ -365,8 +386,8 @@ protected: void setAssociatedConstraints(Expr *AC) { AssociatedConstraints = AC; } - TemplateParameterList *TemplateParams; - Expr *AssociatedConstraints; + TemplateParameterList *TemplateParams = nullptr; + Expr *AssociatedConstraints = nullptr; }; @@ -377,13 +398,14 @@ protected: /// reference to the templated scoped declaration: the underlying AST node. class TemplateDecl : public NamedDecl { void anchor() override; + protected: // Construct a template decl with the given name and parameters. // Used when there is no templated element (e.g., for tt-params). TemplateDecl(ConstrainedTemplateDeclInfo *CTDI, Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params) - : NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr, false), + : NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr), TemplateParams(CTDI) { this->setTemplateParameters(Params); } @@ -396,7 +418,7 @@ protected: TemplateDecl(ConstrainedTemplateDeclInfo *CTDI, Kind DK, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl) - : NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl, false), + : NamedDecl(DK, DC, L, Name), TemplatedDecl(Decl), TemplateParams(CTDI) { this->setTemplateParameters(Params); } @@ -428,31 +450,22 @@ public: } /// Get the underlying, templated declaration. - NamedDecl *getTemplatedDecl() const { return TemplatedDecl.getPointer(); } + NamedDecl *getTemplatedDecl() const { return TemplatedDecl; } // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K >= firstTemplate && K <= lastTemplate; } SourceRange getSourceRange() const override LLVM_READONLY { return SourceRange(getTemplateParameters()->getTemplateLoc(), - TemplatedDecl.getPointer()->getSourceRange().getEnd()); + TemplatedDecl->getSourceRange().getEnd()); } - /// Whether this is a (C++ Concepts TS) function or variable concept. - bool isConcept() const { return TemplatedDecl.getInt(); } - void setConcept() { TemplatedDecl.setInt(true); } - protected: - /// \brief The named declaration from which this template was instantiated. - /// (or null). - /// - /// The boolean value will be true to indicate that this template - /// (function or variable) is a concept. - llvm::PointerIntPair<NamedDecl *, 1, bool> TemplatedDecl; - + NamedDecl *TemplatedDecl; /// \brief The template parameter list and optional requires-clause /// associated with this declaration; alternatively, a /// \c ConstrainedTemplateDeclInfo if the associated constraints of the @@ -481,9 +494,9 @@ public: /// \brief Initialize the underlying templated declaration and /// template parameters. void init(NamedDecl *templatedDecl, TemplateParameterList* templateParams) { - assert(!TemplatedDecl.getPointer() && "TemplatedDecl already set!"); + assert(!TemplatedDecl && "TemplatedDecl already set!"); assert(!TemplateParams && "TemplateParams already set!"); - TemplatedDecl.setPointer(templatedDecl); + TemplatedDecl = templatedDecl; TemplateParams = templateParams; } }; @@ -498,11 +511,10 @@ class FunctionTemplateSpecializationInfo : public llvm::FoldingSetNode { const TemplateArgumentList *TemplateArgs, const ASTTemplateArgumentListInfo *TemplateArgsAsWritten, SourceLocation POI) - : Function(FD), - Template(Template, TSK - 1), - TemplateArguments(TemplateArgs), - TemplateArgumentsAsWritten(TemplateArgsAsWritten), - PointOfInstantiation(POI) { } + : Function(FD), Template(Template, TSK - 1), + TemplateArguments(TemplateArgs), + TemplateArgumentsAsWritten(TemplateArgsAsWritten), + PointOfInstantiation(POI) {} public: static FunctionTemplateSpecializationInfo * @@ -604,7 +616,7 @@ public: explicit MemberSpecializationInfo(NamedDecl *IF, TemplateSpecializationKind TSK, SourceLocation POI = SourceLocation()) - : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) { + : MemberAndTSK(IF, TSK - 1), PointOfInstantiation(POI) { assert(TSK != TSK_Undeclared && "Cannot encode undeclared template specializations for members"); } @@ -681,6 +693,8 @@ class DependentFunctionTemplateSpecializationInfo final const TemplateArgumentListInfo &TemplateArgs); public: + friend TrailingObjects; + static DependentFunctionTemplateSpecializationInfo * Create(ASTContext &Context, const UnresolvedSetImpl &Templates, const TemplateArgumentListInfo &TemplateArgs); @@ -716,32 +730,34 @@ public: SourceLocation getRAngleLoc() const { return AngleLocs.getEnd(); } - - friend TrailingObjects; }; /// Declaration of a redeclarable template. class RedeclarableTemplateDecl : public TemplateDecl, public Redeclarable<RedeclarableTemplateDecl> { - typedef Redeclarable<RedeclarableTemplateDecl> redeclarable_base; + using redeclarable_base = Redeclarable<RedeclarableTemplateDecl>; + RedeclarableTemplateDecl *getNextRedeclarationImpl() override { return getNextRedeclaration(); } + RedeclarableTemplateDecl *getPreviousDeclImpl() override { return getPreviousDecl(); } + RedeclarableTemplateDecl *getMostRecentDeclImpl() override { return getMostRecentDecl(); } protected: template <typename EntryType> struct SpecEntryTraits { - typedef EntryType DeclType; + using DeclType = EntryType; static DeclType *getDecl(EntryType *D) { return D; } + static ArrayRef<TemplateArgument> getTemplateArgs(EntryType *D) { return D->getTemplateArgs().asArray(); } @@ -756,7 +772,7 @@ protected: typename std::iterator_traits<typename llvm::FoldingSetVector< EntryType>::iterator>::iterator_category, DeclType *, ptrdiff_t, DeclType *, DeclType *> { - SpecIterator() {} + SpecIterator() = default; explicit SpecIterator( typename llvm::FoldingSetVector<EntryType>::iterator SetIter) : SpecIterator::iterator_adaptor_base(std::move(SetIter)) {} @@ -764,6 +780,7 @@ protected: DeclType *operator*() const { return SETraits::getDecl(&*this->I)->getMostRecentDecl(); } + DeclType *operator->() const { return **this; } }; @@ -773,6 +790,8 @@ protected: return SpecIterator<EntryType>(isEnd ? Specs.end() : Specs.begin()); } + void loadLazySpecializationsImpl() const; + template <class EntryType> typename SpecEntryTraits<EntryType>::DeclType* findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs, ArrayRef<TemplateArgument> Args, void *&InsertPos); @@ -782,7 +801,7 @@ protected: EntryType *Entry, void *InsertPos); struct CommonBase { - CommonBase() : InstantiatedFromMember(nullptr, false) { } + CommonBase() : InstantiatedFromMember(nullptr, false) {} /// \brief The template from which this was most /// directly instantiated (or null). @@ -791,11 +810,18 @@ protected: /// was explicitly specialized. llvm::PointerIntPair<RedeclarableTemplateDecl*, 1, bool> InstantiatedFromMember; + + /// \brief If non-null, points to an array of specializations (including + /// partial specializations) known only by their external declaration IDs. + /// + /// The first value in the array is the number of specializations/partial + /// specializations that follow. + uint32_t *LazySpecializations = nullptr; }; /// \brief Pointer to the common data shared by all declarations of this /// template. - mutable CommonBase *Common; + mutable CommonBase *Common = nullptr; /// \brief Retrieves the "common" pointer shared by all (re-)declarations of /// the same template. Calling this routine may implicitly allocate memory @@ -809,8 +835,8 @@ protected: ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl) - : TemplateDecl(CTDI, DK, DC, L, Name, Params, Decl), redeclarable_base(C), - Common() {} + : TemplateDecl(CTDI, DK, DC, L, Name, Params, Decl), redeclarable_base(C) + {} RedeclarableTemplateDecl(Kind DK, ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, @@ -818,6 +844,9 @@ protected: : RedeclarableTemplateDecl(nullptr, DK, C, DC, L, Name, Params, Decl) {} public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + friend class ASTReader; template <class decl_type> friend class RedeclarableTemplate; /// \brief Retrieves the canonical declaration of this template. @@ -858,7 +887,7 @@ public: } /// \brief Retrieve the member template from which this template was - /// instantiated, or NULL if this template was not instantiated from a + /// instantiated, or nullptr if this template was not instantiated from a /// member template. /// /// A template is instantiated from a member template when the member @@ -902,8 +931,9 @@ public: getCommonPtr()->InstantiatedFromMember.setPointer(TD); } - typedef redeclarable_base::redecl_range redecl_range; - typedef redeclarable_base::redecl_iterator redecl_iterator; + using redecl_range = redeclarable_base::redecl_range; + using redecl_iterator = redeclarable_base::redecl_iterator; + using redeclarable_base::redecls_begin; using redeclarable_base::redecls_end; using redeclarable_base::redecls; @@ -913,22 +943,20 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K >= firstRedeclarableTemplate && K <= lastRedeclarableTemplate; } - - friend class ASTReader; - friend class ASTDeclReader; - friend class ASTDeclWriter; }; template <> struct RedeclarableTemplateDecl:: SpecEntryTraits<FunctionTemplateSpecializationInfo> { - typedef FunctionDecl DeclType; + using DeclType = FunctionDecl; static DeclType *getDecl(FunctionTemplateSpecializationInfo *I) { return I->Function; } + static ArrayRef<TemplateArgument> getTemplateArgs(FunctionTemplateSpecializationInfo *I) { return I->TemplateArguments->asArray(); @@ -938,11 +966,11 @@ SpecEntryTraits<FunctionTemplateSpecializationInfo> { /// Declaration of a template function. class FunctionTemplateDecl : public RedeclarableTemplateDecl { protected: + friend class FunctionDecl; + /// \brief Data that is common to all of the declarations of a given /// function template. struct Common : CommonBase { - Common() : InjectedArgs(), LazySpecializations() { } - /// \brief The function template specializations for this function /// template, including explicit specializations and instantiations. llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> Specializations; @@ -954,14 +982,9 @@ protected: /// many template arguments as template parameaters) for the function /// template, and is allocated lazily, since most function templates do not /// require the use of this information. - TemplateArgument *InjectedArgs; + TemplateArgument *InjectedArgs = nullptr; - /// \brief If non-null, points to an array of specializations known only - /// by their external declaration IDs. - /// - /// The first value in the array is the number of of specializations - /// that follow. - uint32_t *LazySpecializations; + Common() = default; }; FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, @@ -976,8 +999,6 @@ protected: return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr()); } - friend class FunctionDecl; - /// \brief Retrieve the set of function template specializations of this /// function template. llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> & @@ -991,12 +1012,15 @@ protected: void *InsertPos); public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + /// \brief Load any lazily-loaded specializations from the external source. void LoadLazySpecializations() const; /// Get the underlying function declaration of the template. FunctionDecl *getTemplatedDecl() const { - return static_cast<FunctionDecl *>(TemplatedDecl.getPointer()); + return static_cast<FunctionDecl *>(TemplatedDecl); } /// Returns whether this template declaration defines the primary @@ -1020,14 +1044,11 @@ public: } /// \brief Retrieve the previous declaration of this function template, or - /// NULL if no such declaration exists. + /// nullptr if no such declaration exists. FunctionTemplateDecl *getPreviousDecl() { return cast_or_null<FunctionTemplateDecl>( static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl()); } - - /// \brief Retrieve the previous declaration of this function template, or - /// NULL if no such declaration exists. const FunctionTemplateDecl *getPreviousDecl() const { return cast_or_null<FunctionTemplateDecl>( static_cast<const RedeclarableTemplateDecl *>(this)->getPreviousDecl()); @@ -1047,12 +1068,13 @@ public: RedeclarableTemplateDecl::getInstantiatedFromMemberTemplate()); } - typedef SpecIterator<FunctionTemplateSpecializationInfo> spec_iterator; - typedef llvm::iterator_range<spec_iterator> spec_range; + using spec_iterator = SpecIterator<FunctionTemplateSpecializationInfo>; + using spec_range = llvm::iterator_range<spec_iterator>; spec_range specializations() const { return spec_range(spec_begin(), spec_end()); } + spec_iterator spec_begin() const { return makeSpecIterator(getSpecializations(), false); } @@ -1083,9 +1105,6 @@ public: // Implement isa/cast/dyncast support static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == FunctionTemplate; } - - friend class ASTDeclReader; - friend class ASTDeclWriter; }; //===----------------------------------------------------------------------===// @@ -1102,19 +1121,17 @@ public: /// This class is inheritedly privately by different kinds of template /// parameters and is not part of the Decl hierarchy. Just a facility. class TemplateParmPosition { - TemplateParmPosition() = delete; - protected: - TemplateParmPosition(unsigned D, unsigned P) - : Depth(D), Position(P) - { } - // FIXME: These probably don't need to be ints. int:5 for depth, int:8 for // position? Maybe? unsigned Depth; unsigned Position; + TemplateParmPosition(unsigned D, unsigned P) : Depth(D), Position(P) {} + public: + TemplateParmPosition() = delete; + /// Get the nesting depth of the template parameter. unsigned getDepth() const { return Depth; } void setDepth(unsigned D) { Depth = D; } @@ -1134,6 +1151,9 @@ public: /// template<typename T> class vector; /// \endcode class TemplateTypeParmDecl : public TypeDecl { + /// Sema creates these on the stack during auto type deduction. + friend class Sema; + /// \brief Whether this template type parameter was declaration with /// the 'typename' keyword. /// @@ -1141,18 +1161,14 @@ class TemplateTypeParmDecl : public TypeDecl { bool Typename : 1; /// \brief The default template argument, if any. - typedef DefaultArgStorage<TemplateTypeParmDecl, TypeSourceInfo *> - DefArgStorage; + using DefArgStorage = + DefaultArgStorage<TemplateTypeParmDecl, TypeSourceInfo *>; DefArgStorage DefaultArgument; TemplateTypeParmDecl(DeclContext *DC, SourceLocation KeyLoc, SourceLocation IdLoc, IdentifierInfo *Id, bool Typename) - : TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename), - DefaultArgument() { } - - /// Sema creates these on the stack during auto type deduction. - friend class Sema; + : TypeDecl(TemplateTypeParm, DC, IdLoc, Id, KeyLoc), Typename(Typename) {} public: static TemplateTypeParmDecl *Create(const ASTContext &C, DeclContext *DC, @@ -1199,6 +1215,7 @@ public: void setDefaultArgument(TypeSourceInfo *DefArg) { DefaultArgument.set(DefArg); } + /// \brief Set that this default argument was inherited from another /// parameter. void setInheritedDefaultArgument(const ASTContext &C, @@ -1241,9 +1258,12 @@ class NonTypeTemplateParmDecl final protected TemplateParmPosition, private llvm::TrailingObjects<NonTypeTemplateParmDecl, std::pair<QualType, TypeSourceInfo *>> { + friend class ASTDeclReader; + friend TrailingObjects; + /// \brief The default template argument, if any, and whether or not /// it was inherited. - typedef DefaultArgStorage<NonTypeTemplateParmDecl, Expr*> DefArgStorage; + using DefArgStorage = DefaultArgStorage<NonTypeTemplateParmDecl, Expr *>; DefArgStorage DefaultArgument; // FIXME: Collapse this into TemplateParamPosition; or, just move depth/index @@ -1255,10 +1275,10 @@ class NonTypeTemplateParmDecl final /// \brief Whether this non-type template parameter is an "expanded" /// parameter pack, meaning that its type is a pack expansion and we /// already know the set of types that expansion expands to. - bool ExpandedParameterPack; + bool ExpandedParameterPack = false; /// \brief The number of types in an expanded parameter pack. - unsigned NumExpandedTypes; + unsigned NumExpandedTypes = 0; size_t numTrailingObjects( OverloadToken<std::pair<QualType, TypeSourceInfo *>>) const { @@ -1269,10 +1289,8 @@ class NonTypeTemplateParmDecl final SourceLocation IdLoc, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo) - : DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc), - TemplateParmPosition(D, P), ParameterPack(ParameterPack), - ExpandedParameterPack(false), NumExpandedTypes(0) - { } + : DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc), + TemplateParmPosition(D, P), ParameterPack(ParameterPack) {} NonTypeTemplateParmDecl(DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, unsigned D, unsigned P, @@ -1281,9 +1299,6 @@ class NonTypeTemplateParmDecl final ArrayRef<QualType> ExpandedTypes, ArrayRef<TypeSourceInfo *> ExpandedTInfos); - friend class ASTDeclReader; - friend TrailingObjects; - public: static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, @@ -1428,11 +1443,9 @@ class TemplateTemplateParmDecl final protected TemplateParmPosition, private llvm::TrailingObjects<TemplateTemplateParmDecl, TemplateParameterList *> { - void anchor() override; - /// \brief The default template argument, if any. - typedef DefaultArgStorage<TemplateTemplateParmDecl, TemplateArgumentLoc *> - DefArgStorage; + using DefArgStorage = + DefaultArgStorage<TemplateTemplateParmDecl, TemplateArgumentLoc *>; DefArgStorage DefaultArgument; /// \brief Whether this parameter is a parameter pack. @@ -1441,25 +1454,29 @@ class TemplateTemplateParmDecl final /// \brief Whether this template template parameter is an "expanded" /// parameter pack, meaning that it is a pack expansion and we /// already know the set of template parameters that expansion expands to. - bool ExpandedParameterPack; + bool ExpandedParameterPack = false; /// \brief The number of parameters in an expanded parameter pack. - unsigned NumExpandedParams; + unsigned NumExpandedParams = 0; TemplateTemplateParmDecl(DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params) - : TemplateDecl(TemplateTemplateParm, DC, L, Id, Params), - TemplateParmPosition(D, P), ParameterPack(ParameterPack), - ExpandedParameterPack(false), NumExpandedParams(0) - { } + : TemplateDecl(TemplateTemplateParm, DC, L, Id, Params), + TemplateParmPosition(D, P), ParameterPack(ParameterPack) {} TemplateTemplateParmDecl(DeclContext *DC, SourceLocation L, unsigned D, unsigned P, IdentifierInfo *Id, TemplateParameterList *Params, ArrayRef<TemplateParameterList *> Expansions); + void anchor() override; + public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + friend TrailingObjects; + static TemplateTemplateParmDecl *Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, @@ -1579,22 +1596,18 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == TemplateTemplateParm; } - - friend class ASTDeclReader; - friend class ASTDeclWriter; - friend TrailingObjects; }; /// \brief Represents the builtin template declaration which is used to /// implement __make_integer_seq and other builtin templates. It serves /// no real purpose beyond existing as a place to hold template parameters. class BuiltinTemplateDecl : public TemplateDecl { - void anchor() override; + BuiltinTemplateKind BTK; BuiltinTemplateDecl(const ASTContext &C, DeclContext *DC, DeclarationName Name, BuiltinTemplateKind BTK); - BuiltinTemplateKind BTK; + void anchor() override; public: // Implement isa/cast/dyncast support @@ -1629,7 +1642,6 @@ public: /// \endcode class ClassTemplateSpecializationDecl : public CXXRecordDecl, public llvm::FoldingSetNode { - /// \brief Structure that stores information about a class template /// specialization that was instantiated from a class template partial /// specialization. @@ -1650,19 +1662,20 @@ class ClassTemplateSpecializationDecl /// \brief Further info for explicit template specialization/instantiation. struct ExplicitSpecializationInfo { /// \brief The type-as-written. - TypeSourceInfo *TypeAsWritten; + TypeSourceInfo *TypeAsWritten = nullptr; + /// \brief The location of the extern keyword. SourceLocation ExternLoc; + /// \brief The location of the template keyword. SourceLocation TemplateKeywordLoc; - ExplicitSpecializationInfo() - : TypeAsWritten(nullptr), ExternLoc(), TemplateKeywordLoc() {} + ExplicitSpecializationInfo() = default; }; /// \brief Further info for explicit template specialization/instantiation. /// Does not apply to implicit specializations. - ExplicitSpecializationInfo *ExplicitInfo; + ExplicitSpecializationInfo *ExplicitInfo = nullptr; /// \brief The template arguments used to describe this specialization. const TemplateArgumentList *TemplateArgs; @@ -1685,6 +1698,9 @@ protected: explicit ClassTemplateSpecializationDecl(ASTContext &C, Kind DK); public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + static ClassTemplateSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, @@ -1828,6 +1844,7 @@ public: ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo; ExplicitInfo->TypeAsWritten = T; } + /// \brief Gets the type of this specialization as it was written by /// the user, if it was so written. TypeSourceInfo *getTypeAsWritten() const { @@ -1838,6 +1855,7 @@ public: SourceLocation getExternLoc() const { return ExplicitInfo ? ExplicitInfo->ExternLoc : SourceLocation(); } + /// \brief Sets the location of the extern keyword. void setExternLoc(SourceLocation Loc) { if (!ExplicitInfo) @@ -1851,6 +1869,7 @@ public: ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo; ExplicitInfo->TemplateKeywordLoc = Loc; } + /// \brief Gets the location of the template keyword, if present. SourceLocation getTemplateKeywordLoc() const { return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation(); @@ -1871,25 +1890,21 @@ public: } static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K >= firstClassTemplateSpecialization && K <= lastClassTemplateSpecialization; } - - friend class ASTDeclReader; - friend class ASTDeclWriter; }; class ClassTemplatePartialSpecializationDecl : public ClassTemplateSpecializationDecl { - void anchor() override; - /// \brief The list of template parameters - TemplateParameterList* TemplateParams; + TemplateParameterList* TemplateParams = nullptr; /// \brief The source info for the template arguments as written. /// FIXME: redundant with TypeAsWritten? - const ASTTemplateArgumentListInfo *ArgsAsWritten; + const ASTTemplateArgumentListInfo *ArgsAsWritten = nullptr; /// \brief The class template partial specialization from which this /// class template partial specialization was instantiated. @@ -1911,10 +1926,14 @@ class ClassTemplatePartialSpecializationDecl ClassTemplatePartialSpecializationDecl(ASTContext &C) : ClassTemplateSpecializationDecl(C, ClassTemplatePartialSpecialization), - TemplateParams(nullptr), ArgsAsWritten(nullptr), InstantiatedFromMember(nullptr, false) {} + void anchor() override; + public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, @@ -2024,12 +2043,10 @@ public: // FIXME: Add Profile support! static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == ClassTemplatePartialSpecialization; } - - friend class ASTDeclReader; - friend class ASTDeclWriter; }; /// Declaration of a class template. @@ -2038,8 +2055,6 @@ protected: /// \brief Data that is common to all of the declarations of a given /// class template. struct Common : CommonBase { - Common() : LazySpecializations() { } - /// \brief The class template specializations for this class /// template, including explicit specializations and instantiations. llvm::FoldingSetVector<ClassTemplateSpecializationDecl> Specializations; @@ -2052,12 +2067,7 @@ protected: /// \brief The injected-class-name type for this class template. QualType InjectedClassNameType; - /// \brief If non-null, points to an array of specializations (including - /// partial specializations) known only by their external declaration IDs. - /// - /// The first value in the array is the number of of specializations/ - /// partial specializations that follow. - uint32_t *LazySpecializations; + Common() = default; }; /// \brief Retrieve the set of specializations of this class template. @@ -2087,12 +2097,15 @@ protected: } public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + /// \brief Load any lazily-loaded specializations from the external source. void LoadLazySpecializations() const; /// \brief Get the underlying class declarations of the template. CXXRecordDecl *getTemplatedDecl() const { - return static_cast<CXXRecordDecl *>(TemplatedDecl.getPointer()); + return static_cast<CXXRecordDecl *>(TemplatedDecl); } /// \brief Returns whether this template declaration defines the primary @@ -2132,14 +2145,11 @@ public: } /// \brief Retrieve the previous declaration of this class template, or - /// NULL if no such declaration exists. + /// nullptr if no such declaration exists. ClassTemplateDecl *getPreviousDecl() { return cast_or_null<ClassTemplateDecl>( static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl()); } - - /// \brief Retrieve the previous declaration of this class template, or - /// NULL if no such declaration exists. const ClassTemplateDecl *getPreviousDecl() const { return cast_or_null<ClassTemplateDecl>( static_cast<const RedeclarableTemplateDecl *>( @@ -2180,7 +2190,7 @@ public: /// template. /// /// \returns the class template partial specialization that exactly matches - /// the type \p T, or NULL if no such partial specialization exists. + /// the type \p T, or nullptr if no such partial specialization exists. ClassTemplatePartialSpecializationDecl *findPartialSpecialization(QualType T); /// \brief Find a class template partial specialization which was instantiated @@ -2189,8 +2199,8 @@ public: /// \param D a member class template partial specialization. /// /// \returns the class template partial specialization which was instantiated - /// from the given member partial specialization, or NULL if no such partial - /// specialization exists. + /// from the given member partial specialization, or nullptr if no such + /// partial specialization exists. ClassTemplatePartialSpecializationDecl * findPartialSpecInstantiatedFromMember( ClassTemplatePartialSpecializationDecl *D); @@ -2211,8 +2221,8 @@ public: /// \endcode QualType getInjectedClassNameSpecialization(); - typedef SpecIterator<ClassTemplateSpecializationDecl> spec_iterator; - typedef llvm::iterator_range<spec_iterator> spec_range; + using spec_iterator = SpecIterator<ClassTemplateSpecializationDecl>; + using spec_range = llvm::iterator_range<spec_iterator>; spec_range specializations() const { return spec_range(spec_begin(), spec_end()); @@ -2229,9 +2239,6 @@ public: // Implement isa/cast/dyncast support static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == ClassTemplate; } - - friend class ASTDeclReader; - friend class ASTDeclWriter; }; /// \brief Declaration of a friend template. @@ -2249,15 +2256,16 @@ public: /// will yield a FriendDecl, not a FriendTemplateDecl. class FriendTemplateDecl : public Decl { virtual void anchor(); + public: - typedef llvm::PointerUnion<NamedDecl*,TypeSourceInfo*> FriendUnion; + using FriendUnion = llvm::PointerUnion<NamedDecl *,TypeSourceInfo *>; private: // The number of template parameters; always non-zero. - unsigned NumParams; + unsigned NumParams = 0; // The parameter list. - TemplateParameterList **Params; + TemplateParameterList **Params = nullptr; // The declaration that's a friend of this class. FriendUnion Friend; @@ -2271,13 +2279,11 @@ private: : Decl(Decl::FriendTemplate, DC, Loc), NumParams(Params.size()), Params(Params.data()), Friend(Friend), FriendLoc(FriendLoc) {} - FriendTemplateDecl(EmptyShell Empty) - : Decl(Decl::FriendTemplate, Empty), - NumParams(0), - Params(nullptr) - {} + FriendTemplateDecl(EmptyShell Empty) : Decl(Decl::FriendTemplate, Empty) {} public: + friend class ASTDeclReader; + static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef<TemplateParameterList *> Params, FriendUnion Friend, @@ -2316,8 +2322,6 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == Decl::FriendTemplate; } - - friend class ASTDeclReader; }; /// \brief Declaration of an alias template. @@ -2328,7 +2332,7 @@ public: /// \endcode class TypeAliasTemplateDecl : public RedeclarableTemplateDecl { protected: - typedef CommonBase Common; + using Common = CommonBase; TypeAliasTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, @@ -2343,9 +2347,12 @@ protected: } public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + /// Get the underlying function declaration of the template. TypeAliasDecl *getTemplatedDecl() const { - return static_cast<TypeAliasDecl *>(TemplatedDecl.getPointer()); + return static_cast<TypeAliasDecl *>(TemplatedDecl); } @@ -2359,14 +2366,11 @@ public: } /// \brief Retrieve the previous declaration of this function template, or - /// NULL if no such declaration exists. + /// nullptr if no such declaration exists. TypeAliasTemplateDecl *getPreviousDecl() { return cast_or_null<TypeAliasTemplateDecl>( static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl()); } - - /// \brief Retrieve the previous declaration of this function template, or - /// NULL if no such declaration exists. const TypeAliasTemplateDecl *getPreviousDecl() const { return cast_or_null<TypeAliasTemplateDecl>( static_cast<const RedeclarableTemplateDecl *>( @@ -2378,7 +2382,6 @@ public: RedeclarableTemplateDecl::getInstantiatedFromMemberTemplate()); } - /// \brief Create a function template node. static TypeAliasTemplateDecl *Create(ASTContext &C, DeclContext *DC, SourceLocation L, @@ -2392,9 +2395,6 @@ public: // Implement isa/cast/dyncast support static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == TypeAliasTemplate; } - - friend class ASTDeclReader; - friend class ASTDeclWriter; }; /// \brief Declaration of a function specialization at template class scope. @@ -2414,7 +2414,9 @@ public: /// CXXMethodDecl. Then during an instantiation of class A, it will be /// transformed into an actual function specialization. class ClassScopeFunctionSpecializationDecl : public Decl { - virtual void anchor(); + CXXMethodDecl *Specialization; + bool HasExplicitTemplateArgs; + TemplateArgumentListInfo TemplateArgs; ClassScopeFunctionSpecializationDecl(DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool Args, @@ -2424,13 +2426,14 @@ class ClassScopeFunctionSpecializationDecl : public Decl { TemplateArgs(std::move(TemplArgs)) {} ClassScopeFunctionSpecializationDecl(EmptyShell Empty) - : Decl(Decl::ClassScopeFunctionSpecialization, Empty) {} + : Decl(Decl::ClassScopeFunctionSpecialization, Empty) {} - CXXMethodDecl *Specialization; - bool HasExplicitTemplateArgs; - TemplateArgumentListInfo TemplateArgs; + virtual void anchor(); public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + CXXMethodDecl *getSpecialization() const { return Specialization; } bool hasExplicitTemplateArgs() const { return HasExplicitTemplateArgs; } const TemplateArgumentListInfo& templateArgs() const { return TemplateArgs; } @@ -2450,17 +2453,15 @@ public: // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == Decl::ClassScopeFunctionSpecialization; } - - friend class ASTDeclReader; - friend class ASTDeclWriter; }; /// Implementation of inline functions that require the template declarations inline AnyFunctionDecl::AnyFunctionDecl(FunctionTemplateDecl *FTD) - : Function(FTD) { } + : Function(FTD) {} /// \brief Represents a variable template specialization, which refers to /// a variable template with a given set of template arguments. @@ -2498,19 +2499,20 @@ class VarTemplateSpecializationDecl : public VarDecl, /// \brief Further info for explicit template specialization/instantiation. struct ExplicitSpecializationInfo { /// \brief The type-as-written. - TypeSourceInfo *TypeAsWritten; + TypeSourceInfo *TypeAsWritten = nullptr; + /// \brief The location of the extern keyword. SourceLocation ExternLoc; + /// \brief The location of the template keyword. SourceLocation TemplateKeywordLoc; - ExplicitSpecializationInfo() - : TypeAsWritten(nullptr), ExternLoc(), TemplateKeywordLoc() {} + ExplicitSpecializationInfo() = default; }; /// \brief Further info for explicit template specialization/instantiation. /// Does not apply to implicit specializations. - ExplicitSpecializationInfo *ExplicitInfo; + ExplicitSpecializationInfo *ExplicitInfo = nullptr; /// \brief The template arguments used to describe this specialization. const TemplateArgumentList *TemplateArgs; @@ -2523,6 +2525,12 @@ class VarTemplateSpecializationDecl : public VarDecl, /// Really a value of type TemplateSpecializationKind. unsigned SpecializationKind : 3; + /// \brief Whether this declaration is a complete definition of the + /// variable template specialization. We can't otherwise tell apart + /// an instantiated declaration from an instantiated definition with + /// no initializer. + unsigned IsCompleteDefinition : 1; + protected: VarTemplateSpecializationDecl(Kind DK, ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, @@ -2534,6 +2542,10 @@ protected: explicit VarTemplateSpecializationDecl(Kind DK, ASTContext &Context); public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + friend class VarDecl; + static VarTemplateSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, @@ -2596,6 +2608,8 @@ public: PointOfInstantiation = Loc; } + void setCompleteDefinition() { IsCompleteDefinition = true; } + /// \brief If this variable template specialization is an instantiation of /// a template (rather than an explicit specialization), return the /// variable template or variable template partial specialization from which @@ -2668,6 +2682,7 @@ public: ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo; ExplicitInfo->TypeAsWritten = T; } + /// \brief Gets the type of this specialization as it was written by /// the user, if it was so written. TypeSourceInfo *getTypeAsWritten() const { @@ -2678,6 +2693,7 @@ public: SourceLocation getExternLoc() const { return ExplicitInfo ? ExplicitInfo->ExternLoc : SourceLocation(); } + /// \brief Sets the location of the extern keyword. void setExternLoc(SourceLocation Loc) { if (!ExplicitInfo) @@ -2691,6 +2707,7 @@ public: ExplicitInfo = new (getASTContext()) ExplicitSpecializationInfo; ExplicitInfo->TemplateKeywordLoc = Loc; } + /// \brief Gets the location of the template keyword, if present. SourceLocation getTemplateKeywordLoc() const { return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation(); @@ -2709,25 +2726,21 @@ public: } static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K >= firstVarTemplateSpecialization && K <= lastVarTemplateSpecialization; } - - friend class ASTDeclReader; - friend class ASTDeclWriter; }; class VarTemplatePartialSpecializationDecl : public VarTemplateSpecializationDecl { - void anchor() override; - /// \brief The list of template parameters - TemplateParameterList *TemplateParams; + TemplateParameterList *TemplateParams = nullptr; /// \brief The source info for the template arguments as written. /// FIXME: redundant with TypeAsWritten? - const ASTTemplateArgumentListInfo *ArgsAsWritten; + const ASTTemplateArgumentListInfo *ArgsAsWritten = nullptr; /// \brief The variable template partial specialization from which this /// variable template partial specialization was instantiated. @@ -2745,11 +2758,16 @@ class VarTemplatePartialSpecializationDecl const ASTTemplateArgumentListInfo *ArgInfos); VarTemplatePartialSpecializationDecl(ASTContext &Context) - : VarTemplateSpecializationDecl(VarTemplatePartialSpecialization, Context), - TemplateParams(nullptr), ArgsAsWritten(nullptr), - InstantiatedFromMember(nullptr, false) {} + : VarTemplateSpecializationDecl(VarTemplatePartialSpecialization, + Context), + InstantiatedFromMember(nullptr, false) {} + + void anchor() override; public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + static VarTemplatePartialSpecializationDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, @@ -2841,12 +2859,10 @@ public: } static bool classof(const Decl *D) { return classofKind(D->getKind()); } + static bool classofKind(Kind K) { return K == VarTemplatePartialSpecialization; } - - friend class ASTDeclReader; - friend class ASTDeclWriter; }; /// Declaration of a variable template. @@ -2855,8 +2871,6 @@ protected: /// \brief Data that is common to all of the declarations of a given /// variable template. struct Common : CommonBase { - Common() : LazySpecializations() {} - /// \brief The variable template specializations for this variable /// template, including explicit specializations and instantiations. llvm::FoldingSetVector<VarTemplateSpecializationDecl> Specializations; @@ -2866,12 +2880,7 @@ protected: llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> PartialSpecializations; - /// \brief If non-null, points to an array of specializations (including - /// partial specializations) known ownly by their external declaration IDs. - /// - /// The first value in the array is the number of of specializations/ - /// partial specializations that follow. - uint32_t *LazySpecializations; + Common() = default; }; /// \brief Retrieve the set of specializations of this variable template. @@ -2895,12 +2904,15 @@ protected: } public: + friend class ASTDeclReader; + friend class ASTDeclWriter; + /// \brief Load any lazily-loaded specializations from the external source. void LoadLazySpecializations() const; /// \brief Get the underlying variable declarations of the template. VarDecl *getTemplatedDecl() const { - return static_cast<VarDecl *>(TemplatedDecl.getPointer()); + return static_cast<VarDecl *>(TemplatedDecl); } /// \brief Returns whether this template declaration defines the primary @@ -2937,14 +2949,11 @@ public: } /// \brief Retrieve the previous declaration of this variable template, or - /// NULL if no such declaration exists. + /// nullptr if no such declaration exists. VarTemplateDecl *getPreviousDecl() { return cast_or_null<VarTemplateDecl>( static_cast<RedeclarableTemplateDecl *>(this)->getPreviousDecl()); } - - /// \brief Retrieve the previous declaration of this variable template, or - /// NULL if no such declaration exists. const VarTemplateDecl *getPreviousDecl() const { return cast_or_null<VarTemplateDecl>( static_cast<const RedeclarableTemplateDecl *>( @@ -2986,13 +2995,13 @@ public: /// /// \returns the variable template partial specialization which was /// instantiated - /// from the given member partial specialization, or NULL if no such partial - /// specialization exists. + /// from the given member partial specialization, or nullptr if no such + /// partial specialization exists. VarTemplatePartialSpecializationDecl *findPartialSpecInstantiatedFromMember( VarTemplatePartialSpecializationDecl *D); - typedef SpecIterator<VarTemplateSpecializationDecl> spec_iterator; - typedef llvm::iterator_range<spec_iterator> spec_range; + using spec_iterator = SpecIterator<VarTemplateSpecializationDecl>; + using spec_range = llvm::iterator_range<spec_iterator>; spec_range specializations() const { return spec_range(spec_begin(), spec_end()); @@ -3009,9 +3018,6 @@ public: // Implement isa/cast/dyncast support static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classofKind(Kind K) { return K == VarTemplate; } - - friend class ASTDeclReader; - friend class ASTDeclWriter; }; inline NamedDecl *getAsNamedDecl(TemplateParameter P) { @@ -3032,6 +3038,6 @@ inline TemplateDecl *getAsTypeTemplateDecl(Decl *D) { : nullptr; } -} /* end of namespace clang */ +} // namespace clang -#endif +#endif // LLVM_CLANG_AST_DECLTEMPLATE_H |