summaryrefslogtreecommitdiffstats
path: root/include/clang/AST/DeclTemplate.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/AST/DeclTemplate.h')
-rw-r--r--include/clang/AST/DeclTemplate.h109
1 files changed, 59 insertions, 50 deletions
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index 9283d2d..90cfb20 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/include/clang/AST/DeclTemplate.h
@@ -158,8 +158,8 @@ class TemplateArgumentList {
/// argument list.
unsigned NumArguments;
- TemplateArgumentList(const TemplateArgumentList &Other) LLVM_DELETED_FUNCTION;
- void operator=(const TemplateArgumentList &Other) LLVM_DELETED_FUNCTION;
+ TemplateArgumentList(const TemplateArgumentList &Other) = delete;
+ void operator=(const TemplateArgumentList &Other) = delete;
TemplateArgumentList(const TemplateArgument *Args, unsigned NumArgs,
bool Owned)
@@ -314,7 +314,7 @@ public:
/// \brief The function template from which this function template
/// specialization was generated.
///
- /// The two bits are contain the top 4 values of TemplateSpecializationKind.
+ /// The two bits contain the top 4 values of TemplateSpecializationKind.
llvm::PointerIntPair<FunctionTemplateDecl *, 2> Template;
/// \brief The template arguments used to produce the function template
@@ -545,47 +545,32 @@ protected:
template <typename EntryType> struct SpecEntryTraits {
typedef EntryType DeclType;
- static DeclType *getMostRecentDecl(EntryType *D) {
- return D->getMostRecentDecl();
+ static DeclType *getDecl(EntryType *D) {
+ return D;
+ }
+ static ArrayRef<TemplateArgument> getTemplateArgs(EntryType *D) {
+ return D->getTemplateArgs().asArray();
}
};
- template <typename EntryType,
- typename _SETraits = SpecEntryTraits<EntryType>,
- typename _DeclType = typename _SETraits::DeclType>
- class SpecIterator : public std::iterator<std::forward_iterator_tag,
- _DeclType*, ptrdiff_t,
- _DeclType*, _DeclType*> {
- typedef _SETraits SETraits;
- typedef _DeclType DeclType;
-
- typedef typename llvm::FoldingSetVector<EntryType>::iterator
- SetIteratorType;
-
- SetIteratorType SetIter;
-
- public:
- SpecIterator() : SetIter() {}
- SpecIterator(SetIteratorType SetIter) : SetIter(SetIter) {}
+ template <typename EntryType, typename SETraits = SpecEntryTraits<EntryType>,
+ typename DeclType = typename SETraits::DeclType>
+ struct SpecIterator
+ : llvm::iterator_adaptor_base<
+ SpecIterator<EntryType, SETraits, DeclType>,
+ typename llvm::FoldingSetVector<EntryType>::iterator,
+ typename std::iterator_traits<typename llvm::FoldingSetVector<
+ EntryType>::iterator>::iterator_category,
+ DeclType *, ptrdiff_t, DeclType *, DeclType *> {
+ SpecIterator() {}
+ explicit SpecIterator(
+ typename llvm::FoldingSetVector<EntryType>::iterator SetIter)
+ : SpecIterator::iterator_adaptor_base(std::move(SetIter)) {}
DeclType *operator*() const {
- return SETraits::getMostRecentDecl(&*SetIter);
+ return SETraits::getDecl(&*this->I)->getMostRecentDecl();
}
DeclType *operator->() const { return **this; }
-
- SpecIterator &operator++() { ++SetIter; return *this; }
- SpecIterator operator++(int) {
- SpecIterator tmp(*this);
- ++(*this);
- return tmp;
- }
-
- bool operator==(SpecIterator Other) const {
- return SetIter == Other.SetIter;
- }
- bool operator!=(SpecIterator Other) const {
- return SetIter != Other.SetIter;
- }
};
template <typename EntryType>
@@ -598,6 +583,10 @@ protected:
findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
ArrayRef<TemplateArgument> Args, void *&InsertPos);
+ template <class Derived, class EntryType>
+ void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
+ EntryType *Entry, void *InsertPos);
+
struct CommonBase {
CommonBase() : InstantiatedFromMember(nullptr, false) { }
@@ -737,9 +726,12 @@ template <> struct RedeclarableTemplateDecl::
SpecEntryTraits<FunctionTemplateSpecializationInfo> {
typedef FunctionDecl DeclType;
- static DeclType *
- getMostRecentDecl(FunctionTemplateSpecializationInfo *I) {
- return I->Function->getMostRecentDecl();
+ static DeclType *getDecl(FunctionTemplateSpecializationInfo *I) {
+ return I->Function;
+ }
+ static ArrayRef<TemplateArgument>
+ getTemplateArgs(FunctionTemplateSpecializationInfo *I) {
+ return I->TemplateArguments->asArray();
}
};
@@ -788,9 +780,6 @@ protected:
friend class FunctionDecl;
- /// \brief Load any lazily-loaded specializations from the external source.
- void LoadLazySpecializations() const;
-
/// \brief Retrieve the set of function template specializations of this
/// function template.
llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> &
@@ -804,6 +793,9 @@ protected:
void *InsertPos);
public:
+ /// \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);
@@ -843,6 +835,15 @@ public:
static_cast<const RedeclarableTemplateDecl *>(this)->getPreviousDecl());
}
+ FunctionTemplateDecl *getMostRecentDecl() {
+ return cast<FunctionTemplateDecl>(
+ static_cast<RedeclarableTemplateDecl *>(this)
+ ->getMostRecentDecl());
+ }
+ const FunctionTemplateDecl *getMostRecentDecl() const {
+ return const_cast<FunctionTemplateDecl*>(this)->getMostRecentDecl();
+ }
+
FunctionTemplateDecl *getInstantiatedFromMemberTemplate() {
return cast_or_null<FunctionTemplateDecl>(
RedeclarableTemplateDecl::getInstantiatedFromMemberTemplate());
@@ -903,7 +904,7 @@ 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() LLVM_DELETED_FUNCTION;
+ TemplateParmPosition() = delete;
protected:
TemplateParmPosition(unsigned D, unsigned P)
@@ -1827,9 +1828,6 @@ protected:
uint32_t *LazySpecializations;
};
- /// \brief Load any lazily-loaded specializations from the external source.
- void LoadLazySpecializations() const;
-
/// \brief Retrieve the set of specializations of this class template.
llvm::FoldingSetVector<ClassTemplateSpecializationDecl> &
getSpecializations() const;
@@ -1851,6 +1849,9 @@ protected:
}
public:
+ /// \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);
@@ -2662,9 +2663,6 @@ protected:
uint32_t *LazySpecializations;
};
- /// \brief Load any lazily-loaded specializations from the external source.
- void LoadLazySpecializations() const;
-
/// \brief Retrieve the set of specializations of this variable template.
llvm::FoldingSetVector<VarTemplateSpecializationDecl> &
getSpecializations() const;
@@ -2686,6 +2684,9 @@ protected:
}
public:
+ /// \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);
@@ -2739,6 +2740,14 @@ public:
this)->getPreviousDecl());
}
+ VarTemplateDecl *getMostRecentDecl() {
+ return cast<VarTemplateDecl>(
+ static_cast<RedeclarableTemplateDecl *>(this)->getMostRecentDecl());
+ }
+ const VarTemplateDecl *getMostRecentDecl() const {
+ return const_cast<VarTemplateDecl *>(this)->getMostRecentDecl();
+ }
+
VarTemplateDecl *getInstantiatedFromMemberTemplate() {
return cast_or_null<VarTemplateDecl>(
RedeclarableTemplateDecl::getInstantiatedFromMemberTemplate());
OpenPOWER on IntegriCloud