mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-03 19:32:35 +00:00
[modules] When we try to complete the redeclaration chain for a class template
specialization, pull in any lazy specializations of the class template. llvm-svn: 227668
This commit is contained in:
parent
fb8a66fbc5
commit
5089542793
@ -788,9 +788,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 +801,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);
|
||||
@ -1827,9 +1827,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 +1848,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 +2662,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 +2683,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);
|
||||
|
@ -6081,6 +6081,12 @@ Decl *ASTReader::GetExternalDecl(uint32_t ID) {
|
||||
return GetDecl(ID);
|
||||
}
|
||||
|
||||
template<typename TemplateSpecializationDecl>
|
||||
static void completeRedeclChainForTemplateSpecialization(Decl *D) {
|
||||
if (auto *TSD = dyn_cast<TemplateSpecializationDecl>(D))
|
||||
TSD->getSpecializedTemplate()->LoadLazySpecializations();
|
||||
}
|
||||
|
||||
void ASTReader::CompleteRedeclChain(const Decl *D) {
|
||||
if (NumCurrentElementsDeserializing) {
|
||||
// We arrange to not care about the complete redeclaration chain while we're
|
||||
@ -6114,6 +6120,15 @@ void ASTReader::CompleteRedeclChain(const Decl *D) {
|
||||
D->getDeclContext()->decls_begin();
|
||||
}
|
||||
}
|
||||
|
||||
if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
|
||||
CTSD->getSpecializedTemplate()->LoadLazySpecializations();
|
||||
if (auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D))
|
||||
VTSD->getSpecializedTemplate()->LoadLazySpecializations();
|
||||
if (auto *FD = dyn_cast<FunctionDecl>(D)) {
|
||||
if (auto *Template = FD->getPrimaryTemplate())
|
||||
Template->LoadLazySpecializations();
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t ASTReader::readCXXBaseSpecifiers(ModuleFile &M,
|
||||
|
2
clang/test/Modules/Inputs/merge-template-members/def.h
Normal file
2
clang/test/Modules/Inputs/merge-template-members/def.h
Normal file
@ -0,0 +1,2 @@
|
||||
template<typename> struct A { int n; };
|
||||
template<typename> struct B { typedef A<void> C; };
|
@ -0,0 +1,2 @@
|
||||
module def { header "def.h" export * }
|
||||
module update { header "update.h" export * }
|
@ -0,0 +1,2 @@
|
||||
#include "def.h"
|
||||
B<int>::C use1;
|
10
clang/test/Modules/merge-template-members.cpp
Normal file
10
clang/test/Modules/merge-template-members.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
// RUN: rm -rf %t
|
||||
// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/merge-template-members -verify %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
template<typename> struct A { int n; };
|
||||
template<typename> struct B { typedef A<void> C; };
|
||||
template class B<int>;
|
||||
|
||||
#include "update.h"
|
||||
B<int>::C use2;
|
Loading…
Reference in New Issue
Block a user