summaryrefslogtreecommitdiffstats
path: root/include/clang/AST/DeclTemplate.h
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
committerdim <dim@FreeBSD.org>2014-11-24 09:15:30 +0000
commit173a4f43a911175643bda81ee675e8d9269056ea (patch)
tree47df2c12b57214af6c31e47404b005675b8b7ffc /include/clang/AST/DeclTemplate.h
parent88f7a7d5251a2d813460274c92decc143a11569b (diff)
downloadFreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.zip
FreeBSD-src-173a4f43a911175643bda81ee675e8d9269056ea.tar.gz
Vendor import of clang RELEASE_350/final tag r216957 (effectively, 3.5.0 release):
https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_350/final@216957
Diffstat (limited to 'include/clang/AST/DeclTemplate.h')
-rw-r--r--include/clang/AST/DeclTemplate.h288
1 files changed, 137 insertions, 151 deletions
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index 24bd28a..980a06e 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/include/clang/AST/DeclTemplate.h
@@ -86,11 +86,11 @@ public:
unsigned size() const { return NumParams; }
- llvm::ArrayRef<NamedDecl*> asArray() {
- return llvm::ArrayRef<NamedDecl*>(begin(), size());
+ ArrayRef<NamedDecl*> asArray() {
+ return ArrayRef<NamedDecl*>(begin(), size());
}
- llvm::ArrayRef<const NamedDecl*> asArray() const {
- return llvm::ArrayRef<const NamedDecl*>(begin(), size());
+ ArrayRef<const NamedDecl*> asArray() const {
+ return ArrayRef<const NamedDecl*>(begin(), size());
}
NamedDecl* getParam(unsigned Idx) {
@@ -203,8 +203,8 @@ public:
const TemplateArgument &operator[](unsigned Idx) const { return get(Idx); }
/// \brief Produce this as an array ref.
- llvm::ArrayRef<TemplateArgument> asArray() const {
- return llvm::ArrayRef<TemplateArgument>(data(), size());
+ ArrayRef<TemplateArgument> asArray() const {
+ return ArrayRef<TemplateArgument>(data(), size());
}
/// \brief Retrieve the number of template arguments in this
@@ -227,18 +227,20 @@ public:
/// The TemplateDecl class stores the list of template parameters and a
/// reference to the templated scoped declaration: the underlying AST node.
class TemplateDecl : public NamedDecl {
- virtual void anchor();
+ void anchor() override;
protected:
// This is probably never used.
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
DeclarationName Name)
- : NamedDecl(DK, DC, L, Name), TemplatedDecl(0), TemplateParams(0) { }
+ : NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr),
+ TemplateParams(nullptr) {}
// Construct a template decl with the given name and parameters.
// Used when there is not templated element (tt-params, alias?).
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
DeclarationName Name, TemplateParameterList *Params)
- : NamedDecl(DK, DC, L, Name), TemplatedDecl(0), TemplateParams(Params) { }
+ : NamedDecl(DK, DC, L, Name), TemplatedDecl(nullptr),
+ TemplateParams(Params) {}
// Construct a template decl with name, parameters, and templated element.
TemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
@@ -261,7 +263,7 @@ public:
return K >= firstTemplate && K <= lastTemplate;
}
- SourceRange getSourceRange() const LLVM_READONLY {
+ SourceRange getSourceRange() const override LLVM_READONLY {
return SourceRange(TemplateParams->getTemplateLoc(),
TemplatedDecl->getSourceRange().getEnd());
}
@@ -274,8 +276,8 @@ public:
/// \brief Initialize the underlying templated declaration and
/// template parameters.
void init(NamedDecl *templatedDecl, TemplateParameterList* templateParams) {
- assert(TemplatedDecl == 0 && "TemplatedDecl already set!");
- assert(TemplateParams == 0 && "TemplateParams already set!");
+ assert(!TemplatedDecl && "TemplatedDecl already set!");
+ assert(!TemplateParams && "TemplateParams already set!");
TemplatedDecl = templatedDecl;
TemplateParams = templateParams;
}
@@ -378,16 +380,15 @@ public:
}
void Profile(llvm::FoldingSetNodeID &ID) {
- Profile(ID, TemplateArguments->data(),
- TemplateArguments->size(),
+ Profile(ID, TemplateArguments->asArray(),
Function->getASTContext());
}
static void
- Profile(llvm::FoldingSetNodeID &ID, const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs, ASTContext &Context) {
- ID.AddInteger(NumTemplateArgs);
- for (unsigned Arg = 0; Arg != NumTemplateArgs; ++Arg)
+ Profile(llvm::FoldingSetNodeID &ID, ArrayRef<TemplateArgument> TemplateArgs,
+ ASTContext &Context) {
+ ID.AddInteger(TemplateArgs.size());
+ for (unsigned Arg = 0; Arg != TemplateArgs.size(); ++Arg)
TemplateArgs[Arg].Profile(ID, Context);
}
};
@@ -530,13 +531,13 @@ class RedeclarableTemplateDecl : public TemplateDecl,
public Redeclarable<RedeclarableTemplateDecl>
{
typedef Redeclarable<RedeclarableTemplateDecl> redeclarable_base;
- virtual RedeclarableTemplateDecl *getNextRedeclaration() {
- return RedeclLink.getNext();
+ RedeclarableTemplateDecl *getNextRedeclarationImpl() override {
+ return getNextRedeclaration();
}
- virtual RedeclarableTemplateDecl *getPreviousDeclImpl() {
+ RedeclarableTemplateDecl *getPreviousDeclImpl() override {
return getPreviousDecl();
}
- virtual RedeclarableTemplateDecl *getMostRecentDeclImpl() {
+ RedeclarableTemplateDecl *getMostRecentDeclImpl() override {
return getMostRecentDecl();
}
@@ -595,11 +596,10 @@ protected:
template <class EntryType> typename SpecEntryTraits<EntryType>::DeclType*
findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
- const TemplateArgument *Args, unsigned NumArgs,
- void *&InsertPos);
+ ArrayRef<TemplateArgument> Args, void *&InsertPos);
struct CommonBase {
- CommonBase() : InstantiatedFromMember(0, false) { }
+ CommonBase() : InstantiatedFromMember(nullptr, false) { }
/// \brief The template from which this was most
/// directly instantiated (or null).
@@ -622,16 +622,19 @@ protected:
virtual CommonBase *newCommon(ASTContext &C) const = 0;
// Construct a template decl with name, parameters, and templated element.
- RedeclarableTemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
- DeclarationName Name, TemplateParameterList *Params,
- NamedDecl *Decl)
- : TemplateDecl(DK, DC, L, Name, Params, Decl), Common() { }
+ RedeclarableTemplateDecl(Kind DK, ASTContext &C, DeclContext *DC,
+ SourceLocation L, DeclarationName Name,
+ TemplateParameterList *Params, NamedDecl *Decl)
+ : TemplateDecl(DK, DC, L, Name, Params, Decl), redeclarable_base(C),
+ Common() {}
public:
template <class decl_type> friend class RedeclarableTemplate;
/// \brief Retrieves the canonical declaration of this template.
- RedeclarableTemplateDecl *getCanonicalDecl() { return getFirstDecl(); }
+ RedeclarableTemplateDecl *getCanonicalDecl() override {
+ return getFirstDecl();
+ }
const RedeclarableTemplateDecl *getCanonicalDecl() const {
return getFirstDecl();
}
@@ -710,9 +713,11 @@ public:
getCommonPtr()->InstantiatedFromMember.setPointer(TD);
}
+ typedef redeclarable_base::redecl_range redecl_range;
typedef redeclarable_base::redecl_iterator redecl_iterator;
using redeclarable_base::redecls_begin;
using redeclarable_base::redecls_end;
+ using redeclarable_base::redecls;
using redeclarable_base::getPreviousDecl;
using redeclarable_base::getMostRecentDecl;
using redeclarable_base::isFirstDecl;
@@ -769,11 +774,13 @@ protected:
uint32_t *LazySpecializations;
};
- FunctionTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name,
- TemplateParameterList *Params, NamedDecl *Decl)
- : RedeclarableTemplateDecl(FunctionTemplate, DC, L, Name, Params, Decl) { }
+ FunctionTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L,
+ DeclarationName Name, TemplateParameterList *Params,
+ NamedDecl *Decl)
+ : RedeclarableTemplateDecl(FunctionTemplate, C, DC, L, Name, Params,
+ Decl) {}
- CommonBase *newCommon(ASTContext &C) const;
+ CommonBase *newCommon(ASTContext &C) const override;
Common *getCommonPtr() const {
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
@@ -810,10 +817,10 @@ public:
/// \brief Return the specialization with the provided arguments if it exists,
/// otherwise return the insertion point.
- FunctionDecl *findSpecialization(const TemplateArgument *Args,
- unsigned NumArgs, void *&InsertPos);
+ FunctionDecl *findSpecialization(ArrayRef<TemplateArgument> Args,
+ void *&InsertPos);
- FunctionTemplateDecl *getCanonicalDecl() {
+ FunctionTemplateDecl *getCanonicalDecl() override {
return cast<FunctionTemplateDecl>(
RedeclarableTemplateDecl::getCanonicalDecl());
}
@@ -842,7 +849,11 @@ public:
}
typedef SpecIterator<FunctionTemplateSpecializationInfo> spec_iterator;
+ typedef llvm::iterator_range<spec_iterator> spec_range;
+ spec_range specializations() const {
+ return spec_range(spec_begin(), spec_end());
+ }
spec_iterator spec_begin() const {
return makeSpecIterator(getSpecializations(), false);
}
@@ -892,12 +903,9 @@ 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 {
-protected:
- // FIXME: This should probably never be called, but it's here as
- TemplateParmPosition()
- : Depth(0), Position(0)
- { /* llvm_unreachable("Cannot create positionless template parameter"); */ }
+ TemplateParmPosition() LLVM_DELETED_FUNCTION;
+protected:
TemplateParmPosition(unsigned D, unsigned P)
: Depth(D), Position(P)
{ }
@@ -967,7 +975,7 @@ public:
/// \brief Determine whether this template parameter has a default
/// argument.
- bool hasDefaultArgument() const { return DefaultArgument != 0; }
+ bool hasDefaultArgument() const { return DefaultArgument != nullptr; }
/// \brief Retrieve the default argument, if any.
QualType getDefaultArgument() const { return DefaultArgument->getType(); }
@@ -992,7 +1000,7 @@ public:
/// \brief Removes the default argument of this template parameter.
void removeDefaultArgument() {
- DefaultArgument = 0;
+ DefaultArgument = nullptr;
InheritedDefault = false;
}
@@ -1009,7 +1017,7 @@ public:
/// \brief Returns whether this is a parameter pack.
bool isParameterPack() const;
- SourceRange getSourceRange() const LLVM_READONLY;
+ SourceRange getSourceRange() const override LLVM_READONLY;
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@@ -1046,7 +1054,7 @@ class NonTypeTemplateParmDecl
IdentifierInfo *Id, QualType T,
bool ParameterPack, TypeSourceInfo *TInfo)
: DeclaratorDecl(NonTypeTemplateParm, DC, IdLoc, Id, T, TInfo, StartLoc),
- TemplateParmPosition(D, P), DefaultArgumentAndInherited(0, false),
+ TemplateParmPosition(D, P), DefaultArgumentAndInherited(nullptr, false),
ParameterPack(ParameterPack), ExpandedParameterPack(false),
NumExpandedTypes(0)
{ }
@@ -1086,12 +1094,12 @@ public:
using TemplateParmPosition::setPosition;
using TemplateParmPosition::getIndex;
- SourceRange getSourceRange() const LLVM_READONLY;
+ SourceRange getSourceRange() const override LLVM_READONLY;
/// \brief Determine whether this template parameter has a default
/// argument.
bool hasDefaultArgument() const {
- return DefaultArgumentAndInherited.getPointer() != 0;
+ return DefaultArgumentAndInherited.getPointer() != nullptr;
}
/// \brief Retrieve the default argument, if any.
@@ -1118,7 +1126,7 @@ public:
/// \brief Removes the default argument of this template parameter.
void removeDefaultArgument() {
- DefaultArgumentAndInherited.setPointer(0);
+ DefaultArgumentAndInherited.setPointer(nullptr);
DefaultArgumentAndInherited.setInt(false);
}
@@ -1206,7 +1214,7 @@ public:
class TemplateTemplateParmDecl : public TemplateDecl,
protected TemplateParmPosition
{
- virtual void anchor();
+ void anchor() override;
/// DefaultArgument - The default template argument, if any.
TemplateArgumentLoc DefaultArgument;
@@ -1347,7 +1355,7 @@ public:
DefaultArgumentWasInherited = false;
}
- SourceRange getSourceRange() const LLVM_READONLY {
+ SourceRange getSourceRange() const override LLVM_READONLY {
SourceLocation End = getLocation();
if (hasDefaultArgument() && !defaultArgumentWasInherited())
End = getDefaultArgument().getSourceRange().getEnd();
@@ -1405,7 +1413,7 @@ class ClassTemplateSpecializationDecl
SourceLocation TemplateKeywordLoc;
ExplicitSpecializationInfo()
- : TypeAsWritten(0), ExternLoc(), TemplateKeywordLoc() {}
+ : TypeAsWritten(nullptr), ExternLoc(), TemplateKeywordLoc() {}
};
/// \brief Further info for explicit template specialization/instantiation.
@@ -1431,7 +1439,7 @@ protected:
unsigned NumArgs,
ClassTemplateSpecializationDecl *PrevDecl);
- explicit ClassTemplateSpecializationDecl(Kind DK);
+ explicit ClassTemplateSpecializationDecl(ASTContext &C, Kind DK);
public:
static ClassTemplateSpecializationDecl *
@@ -1444,10 +1452,14 @@ public:
static ClassTemplateSpecializationDecl *
CreateDeserialized(ASTContext &C, unsigned ID);
- virtual void getNameForDiagnostic(raw_ostream &OS,
- const PrintingPolicy &Policy,
- bool Qualified) const;
+ void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy,
+ bool Qualified) const override;
+ // FIXME: This is broken. CXXRecordDecl::getMostRecentDecl() returns a
+ // different "most recent" declaration from this function for the same
+ // declaration, because we don't override getMostRecentDeclImpl(). But
+ // it's not clear that we should override that, because the most recent
+ // declaration as a CXXRecordDecl sometimes is the injected-class-name.
ClassTemplateSpecializationDecl *getMostRecentDecl() {
CXXRecordDecl *Recent = static_cast<CXXRecordDecl *>(
this)->getMostRecentDecl();
@@ -1516,17 +1528,11 @@ public:
llvm::PointerUnion<ClassTemplateDecl *,
ClassTemplatePartialSpecializationDecl *>
getInstantiatedFrom() const {
- if (getSpecializationKind() != TSK_ImplicitInstantiation &&
- getSpecializationKind() != TSK_ExplicitInstantiationDefinition &&
- getSpecializationKind() != TSK_ExplicitInstantiationDeclaration)
+ if (!isTemplateInstantiation(getSpecializationKind()))
return llvm::PointerUnion<ClassTemplateDecl *,
ClassTemplatePartialSpecializationDecl *>();
- if (SpecializedPartialSpecialization *PartialSpec
- = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
- return PartialSpec->PartialSpecialization;
-
- return SpecializedTemplate.get<ClassTemplateDecl*>();
+ return getSpecializedTemplateOrPartial();
}
/// \brief Retrieve the class template or class template partial
@@ -1592,7 +1598,7 @@ public:
/// \brief Gets the type of this specialization as it was written by
/// the user, if it was so written.
TypeSourceInfo *getTypeAsWritten() const {
- return ExplicitInfo ? ExplicitInfo->TypeAsWritten : 0;
+ return ExplicitInfo ? ExplicitInfo->TypeAsWritten : nullptr;
}
/// \brief Gets the location of the extern keyword, if present.
@@ -1617,17 +1623,17 @@ public:
return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
}
- SourceRange getSourceRange() const LLVM_READONLY;
+ SourceRange getSourceRange() const override LLVM_READONLY;
void Profile(llvm::FoldingSetNodeID &ID) const {
- Profile(ID, TemplateArgs->data(), TemplateArgs->size(), getASTContext());
+ Profile(ID, TemplateArgs->asArray(), getASTContext());
}
static void
- Profile(llvm::FoldingSetNodeID &ID, const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs, ASTContext &Context) {
- ID.AddInteger(NumTemplateArgs);
- for (unsigned Arg = 0; Arg != NumTemplateArgs; ++Arg)
+ Profile(llvm::FoldingSetNodeID &ID, ArrayRef<TemplateArgument> TemplateArgs,
+ ASTContext &Context) {
+ ID.AddInteger(TemplateArgs.size());
+ for (unsigned Arg = 0; Arg != TemplateArgs.size(); ++Arg)
TemplateArgs[Arg].Profile(ID, Context);
}
@@ -1643,7 +1649,7 @@ public:
class ClassTemplatePartialSpecializationDecl
: public ClassTemplateSpecializationDecl {
- virtual void anchor();
+ void anchor() override;
/// \brief The list of template parameters
TemplateParameterList* TemplateParams;
@@ -1671,9 +1677,10 @@ class ClassTemplatePartialSpecializationDecl
const ASTTemplateArgumentListInfo *ArgsAsWritten,
ClassTemplatePartialSpecializationDecl *PrevDecl);
- ClassTemplatePartialSpecializationDecl()
- : ClassTemplateSpecializationDecl(ClassTemplatePartialSpecialization),
- TemplateParams(0), ArgsAsWritten(0), InstantiatedFromMember(0, false) { }
+ ClassTemplatePartialSpecializationDecl(ASTContext &C)
+ : ClassTemplateSpecializationDecl(C, ClassTemplatePartialSpecialization),
+ TemplateParams(nullptr), ArgsAsWritten(nullptr),
+ InstantiatedFromMember(nullptr, false) {}
public:
static ClassTemplatePartialSpecializationDecl *
@@ -1832,15 +1839,12 @@ protected:
llvm::FoldingSetVector<ClassTemplatePartialSpecializationDecl> &
getPartialSpecializations();
- ClassTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name,
- TemplateParameterList *Params, NamedDecl *Decl)
- : RedeclarableTemplateDecl(ClassTemplate, DC, L, Name, Params, Decl) { }
+ ClassTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L,
+ DeclarationName Name, TemplateParameterList *Params,
+ NamedDecl *Decl)
+ : RedeclarableTemplateDecl(ClassTemplate, C, DC, L, Name, Params, Decl) {}
- ClassTemplateDecl(EmptyShell Empty)
- : RedeclarableTemplateDecl(ClassTemplate, 0, SourceLocation(),
- DeclarationName(), 0, 0) { }
-
- CommonBase *newCommon(ASTContext &C) const;
+ CommonBase *newCommon(ASTContext &C) const override;
Common *getCommonPtr() const {
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
@@ -1872,14 +1876,13 @@ public:
/// \brief Return the specialization with the provided arguments if it exists,
/// otherwise return the insertion point.
ClassTemplateSpecializationDecl *
- findSpecialization(const TemplateArgument *Args, unsigned NumArgs,
- void *&InsertPos);
+ findSpecialization(ArrayRef<TemplateArgument> Args, void *&InsertPos);
/// \brief Insert the specified specialization knowing that it is not already
/// in. InsertPos must be obtained from findSpecialization.
void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos);
- ClassTemplateDecl *getCanonicalDecl() {
+ ClassTemplateDecl *getCanonicalDecl() override {
return cast<ClassTemplateDecl>(
RedeclarableTemplateDecl::getCanonicalDecl());
}
@@ -1919,8 +1922,7 @@ public:
/// \brief Return the partial specialization with the provided arguments if it
/// exists, otherwise return the insertion point.
ClassTemplatePartialSpecializationDecl *
- findPartialSpecialization(const TemplateArgument *Args, unsigned NumArgs,
- void *&InsertPos);
+ findPartialSpecialization(ArrayRef<TemplateArgument> Args, void *&InsertPos);
/// \brief Insert the specified partial specialization knowing that it is not
/// already in. InsertPos must be obtained from findPartialSpecialization.
@@ -1970,6 +1972,11 @@ public:
QualType getInjectedClassNameSpecialization();
typedef SpecIterator<ClassTemplateSpecializationDecl> spec_iterator;
+ typedef llvm::iterator_range<spec_iterator> spec_range;
+
+ spec_range specializations() const {
+ return spec_range(spec_begin(), spec_end());
+ }
spec_iterator spec_begin() const {
return makeSpecIterator(getSpecializations(), false);
@@ -1979,17 +1986,6 @@ public:
return makeSpecIterator(getSpecializations(), true);
}
- typedef SpecIterator<ClassTemplatePartialSpecializationDecl>
- partial_spec_iterator;
-
- partial_spec_iterator partial_spec_begin() {
- return makeSpecIterator(getPartialSpecializations(), false);
- }
-
- partial_spec_iterator partial_spec_end() {
- return makeSpecIterator(getPartialSpecializations(), true);
- }
-
// Implement isa/cast/dyncast support
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == ClassTemplate; }
@@ -2045,7 +2041,7 @@ private:
FriendTemplateDecl(EmptyShell Empty)
: Decl(Decl::FriendTemplate, Empty),
NumParams(0),
- Params(0)
+ Params(nullptr)
{}
public:
@@ -2105,11 +2101,13 @@ class TypeAliasTemplateDecl : public RedeclarableTemplateDecl {
protected:
typedef CommonBase Common;
- TypeAliasTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name,
- TemplateParameterList *Params, NamedDecl *Decl)
- : RedeclarableTemplateDecl(TypeAliasTemplate, DC, L, Name, Params, Decl) { }
+ TypeAliasTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L,
+ DeclarationName Name, TemplateParameterList *Params,
+ NamedDecl *Decl)
+ : RedeclarableTemplateDecl(TypeAliasTemplate, C, DC, L, Name, Params,
+ Decl) {}
- CommonBase *newCommon(ASTContext &C) const;
+ CommonBase *newCommon(ASTContext &C) const override;
Common *getCommonPtr() {
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
@@ -2122,7 +2120,7 @@ public:
}
- TypeAliasTemplateDecl *getCanonicalDecl() {
+ TypeAliasTemplateDecl *getCanonicalDecl() override {
return cast<TypeAliasTemplateDecl>(
RedeclarableTemplateDecl::getCanonicalDecl());
}
@@ -2172,7 +2170,7 @@ public:
/// \brief Declaration of a function specialization at template class scope.
///
-/// This is a non standard extension needed to support MSVC.
+/// This is a non-standard extension needed to support MSVC.
///
/// For example:
/// \code
@@ -2214,9 +2212,8 @@ public:
CXXMethodDecl *FD,
bool HasExplicitTemplateArgs,
TemplateArgumentListInfo TemplateArgs) {
- return new (C) ClassScopeFunctionSpecializationDecl(DC , Loc, FD,
- HasExplicitTemplateArgs,
- TemplateArgs);
+ return new (C, DC) ClassScopeFunctionSpecializationDecl(
+ DC, Loc, FD, HasExplicitTemplateArgs, TemplateArgs);
}
static ClassScopeFunctionSpecializationDecl *
@@ -2279,7 +2276,7 @@ class VarTemplateSpecializationDecl : public VarDecl,
SourceLocation TemplateKeywordLoc;
ExplicitSpecializationInfo()
- : TypeAsWritten(0), ExternLoc(), TemplateKeywordLoc() {}
+ : TypeAsWritten(nullptr), ExternLoc(), TemplateKeywordLoc() {}
};
/// \brief Further info for explicit template specialization/instantiation.
@@ -2298,14 +2295,14 @@ class VarTemplateSpecializationDecl : public VarDecl,
unsigned SpecializationKind : 3;
protected:
- VarTemplateSpecializationDecl(ASTContext &Context, Kind DK, DeclContext *DC,
+ VarTemplateSpecializationDecl(Kind DK, ASTContext &Context, DeclContext *DC,
SourceLocation StartLoc, SourceLocation IdLoc,
VarTemplateDecl *SpecializedTemplate,
QualType T, TypeSourceInfo *TInfo,
StorageClass S, const TemplateArgument *Args,
unsigned NumArgs);
- explicit VarTemplateSpecializationDecl(Kind DK);
+ explicit VarTemplateSpecializationDecl(Kind DK, ASTContext &Context);
public:
static VarTemplateSpecializationDecl *
@@ -2316,9 +2313,8 @@ public:
static VarTemplateSpecializationDecl *CreateDeserialized(ASTContext &C,
unsigned ID);
- virtual void getNameForDiagnostic(raw_ostream &OS,
- const PrintingPolicy &Policy,
- bool Qualified) const;
+ void getNameForDiagnostic(raw_ostream &OS, const PrintingPolicy &Policy,
+ bool Qualified) const override;
VarTemplateSpecializationDecl *getMostRecentDecl() {
VarDecl *Recent = static_cast<VarDecl *>(this)->getMostRecentDecl();
@@ -2461,7 +2457,7 @@ public:
/// \brief Gets the type of this specialization as it was written by
/// the user, if it was so written.
TypeSourceInfo *getTypeAsWritten() const {
- return ExplicitInfo ? ExplicitInfo->TypeAsWritten : 0;
+ return ExplicitInfo ? ExplicitInfo->TypeAsWritten : nullptr;
}
/// \brief Gets the location of the extern keyword, if present.
@@ -2487,14 +2483,14 @@ public:
}
void Profile(llvm::FoldingSetNodeID &ID) const {
- Profile(ID, TemplateArgs->data(), TemplateArgs->size(), getASTContext());
+ Profile(ID, TemplateArgs->asArray(), getASTContext());
}
static void Profile(llvm::FoldingSetNodeID &ID,
- const TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs, ASTContext &Context) {
- ID.AddInteger(NumTemplateArgs);
- for (unsigned Arg = 0; Arg != NumTemplateArgs; ++Arg)
+ ArrayRef<TemplateArgument> TemplateArgs,
+ ASTContext &Context) {
+ ID.AddInteger(TemplateArgs.size());
+ for (unsigned Arg = 0; Arg != TemplateArgs.size(); ++Arg)
TemplateArgs[Arg].Profile(ID, Context);
}
@@ -2510,7 +2506,7 @@ public:
class VarTemplatePartialSpecializationDecl
: public VarTemplateSpecializationDecl {
- virtual void anchor();
+ void anchor() override;
/// \brief The list of template parameters
TemplateParameterList *TemplateParams;
@@ -2534,9 +2530,10 @@ class VarTemplatePartialSpecializationDecl
StorageClass S, const TemplateArgument *Args, unsigned NumArgs,
const ASTTemplateArgumentListInfo *ArgInfos);
- VarTemplatePartialSpecializationDecl()
- : VarTemplateSpecializationDecl(VarTemplatePartialSpecialization),
- TemplateParams(0), ArgsAsWritten(0), InstantiatedFromMember(0, false) {}
+ VarTemplatePartialSpecializationDecl(ASTContext &Context)
+ : VarTemplateSpecializationDecl(VarTemplatePartialSpecialization, Context),
+ TemplateParams(nullptr), ArgsAsWritten(nullptr),
+ InstantiatedFromMember(nullptr, false) {}
public:
static VarTemplatePartialSpecializationDecl *
@@ -2677,15 +2674,12 @@ protected:
llvm::FoldingSetVector<VarTemplatePartialSpecializationDecl> &
getPartialSpecializations();
- VarTemplateDecl(DeclContext *DC, SourceLocation L, DeclarationName Name,
- TemplateParameterList *Params, NamedDecl *Decl)
- : RedeclarableTemplateDecl(VarTemplate, DC, L, Name, Params, Decl) {}
+ VarTemplateDecl(ASTContext &C, DeclContext *DC, SourceLocation L,
+ DeclarationName Name, TemplateParameterList *Params,
+ NamedDecl *Decl)
+ : RedeclarableTemplateDecl(VarTemplate, C, DC, L, Name, Params, Decl) {}
- VarTemplateDecl(EmptyShell Empty)
- : RedeclarableTemplateDecl(VarTemplate, 0, SourceLocation(),
- DeclarationName(), 0, 0) {}
-
- CommonBase *newCommon(ASTContext &C) const;
+ CommonBase *newCommon(ASTContext &C) const override;
Common *getCommonPtr() const {
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
@@ -2708,8 +2702,8 @@ public:
/// \brief Create a variable template node.
static VarTemplateDecl *Create(ASTContext &C, DeclContext *DC,
SourceLocation L, DeclarationName Name,
- TemplateParameterList *Params, NamedDecl *Decl,
- VarTemplateDecl *PrevDecl);
+ TemplateParameterList *Params,
+ VarDecl *Decl);
/// \brief Create an empty variable template node.
static VarTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID);
@@ -2717,14 +2711,13 @@ public:
/// \brief Return the specialization with the provided arguments if it exists,
/// otherwise return the insertion point.
VarTemplateSpecializationDecl *
- findSpecialization(const TemplateArgument *Args, unsigned NumArgs,
- void *&InsertPos);
+ findSpecialization(ArrayRef<TemplateArgument> Args, void *&InsertPos);
/// \brief Insert the specified specialization knowing that it is not already
/// in. InsertPos must be obtained from findSpecialization.
void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos);
- VarTemplateDecl *getCanonicalDecl() {
+ VarTemplateDecl *getCanonicalDecl() override {
return cast<VarTemplateDecl>(RedeclarableTemplateDecl::getCanonicalDecl());
}
const VarTemplateDecl *getCanonicalDecl() const {
@@ -2754,8 +2747,7 @@ public:
/// \brief Return the partial specialization with the provided arguments if it
/// exists, otherwise return the insertion point.
VarTemplatePartialSpecializationDecl *
- findPartialSpecialization(const TemplateArgument *Args, unsigned NumArgs,
- void *&InsertPos);
+ findPartialSpecialization(ArrayRef<TemplateArgument> Args, void *&InsertPos);
/// \brief Insert the specified partial specialization knowing that it is not
/// already in. InsertPos must be obtained from findPartialSpecialization.
@@ -2780,6 +2772,11 @@ public:
VarTemplatePartialSpecializationDecl *D);
typedef SpecIterator<VarTemplateSpecializationDecl> spec_iterator;
+ typedef llvm::iterator_range<spec_iterator> spec_range;
+
+ spec_range specializations() const {
+ return spec_range(spec_begin(), spec_end());
+ }
spec_iterator spec_begin() const {
return makeSpecIterator(getSpecializations(), false);
@@ -2789,17 +2786,6 @@ public:
return makeSpecIterator(getSpecializations(), true);
}
- typedef SpecIterator<VarTemplatePartialSpecializationDecl>
- partial_spec_iterator;
-
- partial_spec_iterator partial_spec_begin() {
- return makeSpecIterator(getPartialSpecializations(), false);
- }
-
- partial_spec_iterator partial_spec_end() {
- return makeSpecIterator(getPartialSpecializations(), true);
- }
-
// Implement isa/cast/dyncast support
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classofKind(Kind K) { return K == VarTemplate; }
OpenPOWER on IntegriCloud