diff options
| author | Vassil Vassilev <v.g.vassilev@gmail.com> | 2017-12-14 23:30:18 +0000 |
|---|---|---|
| committer | Vassil Vassilev <v.g.vassilev@gmail.com> | 2017-12-14 23:30:18 +0000 |
| commit | 61f6429e327a60d52db205b0c46bf49470c77514 (patch) | |
| tree | 488bf7d1d602d5935bfc51f9858b1173ae210228 /clang/lib/AST | |
| parent | 27e7f9c809325cd0f54ad6c0e0f067b1d37a0a21 (diff) | |
| download | bcm5719-llvm-61f6429e327a60d52db205b0c46bf49470c77514.tar.gz bcm5719-llvm-61f6429e327a60d52db205b0c46bf49470c77514.zip | |
D40901: Refactor lazy loading of template specializations. NFC
llvm-svn: 320763
Diffstat (limited to 'clang/lib/AST')
| -rw-r--r-- | clang/lib/AST/DeclTemplate.cpp | 56 |
1 files changed, 17 insertions, 39 deletions
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index 54e8dd86624..a7949b310ce 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -182,6 +182,19 @@ RedeclarableTemplateDecl::CommonBase *RedeclarableTemplateDecl::getCommonPtr() c return Common; } +void RedeclarableTemplateDecl::loadLazySpecializationsImpl() const { + // Grab the most recent declaration to ensure we've loaded any lazy + // redeclarations of this template. + CommonBase *CommonBasePtr = getMostRecentDecl()->getCommonPtr(); + if (CommonBasePtr->LazySpecializations) { + ASTContext &Context = getASTContext(); + uint32_t *Specs = CommonBasePtr->LazySpecializations; + CommonBasePtr->LazySpecializations = nullptr; + for (uint32_t I = 0, N = *Specs++; I != N; ++I) + (void)Context.getExternalSource()->GetExternalDecl(Specs[I]); + } +} + template<class EntryType> typename RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::DeclType * RedeclarableTemplateDecl::findSpecializationImpl( @@ -190,7 +203,7 @@ RedeclarableTemplateDecl::findSpecializationImpl( using SETraits = SpecEntryTraits<EntryType>; llvm::FoldingSetNodeID ID; - EntryType::Profile(ID,Args, getASTContext()); + EntryType::Profile(ID, Args, getASTContext()); EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos); return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() : nullptr; } @@ -251,18 +264,7 @@ FunctionTemplateDecl::newCommon(ASTContext &C) const { } void FunctionTemplateDecl::LoadLazySpecializations() const { - // Grab the most recent declaration to ensure we've loaded any lazy - // redeclarations of this template. - // - // FIXME: Avoid walking the entire redeclaration chain here. - Common *CommonPtr = getMostRecentDecl()->getCommonPtr(); - if (CommonPtr->LazySpecializations) { - ASTContext &Context = getASTContext(); - uint32_t *Specs = CommonPtr->LazySpecializations; - CommonPtr->LazySpecializations = nullptr; - for (uint32_t I = 0, N = *Specs++; I != N; ++I) - (void)Context.getExternalSource()->GetExternalDecl(Specs[I]); - } + loadLazySpecializationsImpl(); } llvm::FoldingSetVector<FunctionTemplateSpecializationInfo> & @@ -330,18 +332,7 @@ ClassTemplateDecl *ClassTemplateDecl::CreateDeserialized(ASTContext &C, } void ClassTemplateDecl::LoadLazySpecializations() const { - // Grab the most recent declaration to ensure we've loaded any lazy - // redeclarations of this template. - // - // FIXME: Avoid walking the entire redeclaration chain here. - Common *CommonPtr = getMostRecentDecl()->getCommonPtr(); - if (CommonPtr->LazySpecializations) { - ASTContext &Context = getASTContext(); - uint32_t *Specs = CommonPtr->LazySpecializations; - CommonPtr->LazySpecializations = nullptr; - for (uint32_t I = 0, N = *Specs++; I != N; ++I) - (void)Context.getExternalSource()->GetExternalDecl(Specs[I]); - } + loadLazySpecializationsImpl(); } llvm::FoldingSetVector<ClassTemplateSpecializationDecl> & @@ -941,21 +932,8 @@ VarTemplateDecl *VarTemplateDecl::CreateDeserialized(ASTContext &C, DeclarationName(), nullptr, nullptr); } -// TODO: Unify across class, function and variable templates? -// May require moving this and Common to RedeclarableTemplateDecl. void VarTemplateDecl::LoadLazySpecializations() const { - // Grab the most recent declaration to ensure we've loaded any lazy - // redeclarations of this template. - // - // FIXME: Avoid walking the entire redeclaration chain here. - Common *CommonPtr = getMostRecentDecl()->getCommonPtr(); - if (CommonPtr->LazySpecializations) { - ASTContext &Context = getASTContext(); - uint32_t *Specs = CommonPtr->LazySpecializations; - CommonPtr->LazySpecializations = nullptr; - for (uint32_t I = 0, N = *Specs++; I != N; ++I) - (void)Context.getExternalSource()->GetExternalDecl(Specs[I]); - } + loadLazySpecializationsImpl(); } llvm::FoldingSetVector<VarTemplateSpecializationDecl> & |

