diff options
author | Reid Kleckner <rnk@google.com> | 2019-12-22 11:37:54 -0800 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2019-12-22 11:40:07 -0800 |
commit | 79cc9e9b304a90598e8def4c8b5354d1f99186eb (patch) | |
tree | 167eb223a5d3e2d9995f4fbfd856ea18b451abaf /clang/lib/AST/DeclTemplate.cpp | |
parent | fb0ccff6e56bde6c42b2ff941861564e24a7a805 (diff) | |
download | bcm5719-llvm-79cc9e9b304a90598e8def4c8b5354d1f99186eb.tar.gz bcm5719-llvm-79cc9e9b304a90598e8def4c8b5354d1f99186eb.zip |
Revert "[Concepts] Constrained partial specializations and function overloads."
This reverts commit d3f5769d5e93b30d4a8b4696381d5e4a304992fa.
Causes crashes on Chromium. Have reproducer, will reduce and send along.
Diffstat (limited to 'clang/lib/AST/DeclTemplate.cpp')
-rw-r--r--[-rwxr-xr-x] | clang/lib/AST/DeclTemplate.cpp | 79 |
1 files changed, 14 insertions, 65 deletions
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index 23734396b76..7e013c6c54d 100755..100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -231,16 +231,15 @@ void RedeclarableTemplateDecl::loadLazySpecializationsImpl() const { } } -template<class EntryType, typename... ProfileArguments> +template<class EntryType> typename RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::DeclType * RedeclarableTemplateDecl::findSpecializationImpl( - llvm::FoldingSetVector<EntryType> &Specs, void *&InsertPos, - ProfileArguments&&... ProfileArgs) { + llvm::FoldingSetVector<EntryType> &Specs, ArrayRef<TemplateArgument> Args, + void *&InsertPos) { using SETraits = SpecEntryTraits<EntryType>; llvm::FoldingSetNodeID ID; - EntryType::Profile(ID, std::forward<ProfileArguments>(ProfileArgs)..., - getASTContext()); + EntryType::Profile(ID, Args, getASTContext()); EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos); return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() : nullptr; } @@ -255,8 +254,8 @@ void RedeclarableTemplateDecl::addSpecializationImpl( #ifndef NDEBUG void *CorrectInsertPos; assert(!findSpecializationImpl(Specializations, - CorrectInsertPos, - SETraits::getTemplateArgs(Entry)) && + SETraits::getTemplateArgs(Entry), + CorrectInsertPos) && InsertPos == CorrectInsertPos && "given incorrect InsertPos for specialization"); #endif @@ -313,7 +312,7 @@ FunctionTemplateDecl::getSpecializations() const { FunctionDecl * FunctionTemplateDecl::findSpecialization(ArrayRef<TemplateArgument> Args, void *&InsertPos) { - return findSpecializationImpl(getSpecializations(), InsertPos, Args); + return findSpecializationImpl(getSpecializations(), Args, InsertPos); } void FunctionTemplateDecl::addSpecialization( @@ -419,7 +418,7 @@ ClassTemplateDecl::newCommon(ASTContext &C) const { ClassTemplateSpecializationDecl * ClassTemplateDecl::findSpecialization(ArrayRef<TemplateArgument> Args, void *&InsertPos) { - return findSpecializationImpl(getSpecializations(), InsertPos, Args); + return findSpecializationImpl(getSpecializations(), Args, InsertPos); } void ClassTemplateDecl::AddSpecialization(ClassTemplateSpecializationDecl *D, @@ -428,48 +427,9 @@ void ClassTemplateDecl::AddSpecialization(ClassTemplateSpecializationDecl *D, } ClassTemplatePartialSpecializationDecl * -ClassTemplateDecl::findPartialSpecialization( - ArrayRef<TemplateArgument> Args, - TemplateParameterList *TPL, void *&InsertPos) { - return findSpecializationImpl(getPartialSpecializations(), InsertPos, Args, - TPL); -} - -static void ProfileTemplateParameterList(ASTContext &C, - llvm::FoldingSetNodeID &ID, const TemplateParameterList *TPL) { - const Expr *RC = TPL->getRequiresClause(); - ID.AddBoolean(RC != nullptr); - if (RC) - RC->Profile(ID, C, /*Canonical=*/true); - ID.AddInteger(TPL->size()); - for (NamedDecl *D : *TPL) { - if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) { - ID.AddInteger(0); - ID.AddBoolean(NTTP->isParameterPack()); - NTTP->getType().getCanonicalType().Profile(ID); - continue; - } - if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(D)) { - ID.AddInteger(1); - ID.AddBoolean(TTP->isParameterPack()); - // TODO: Concepts: profile type-constraints. - continue; - } - const auto *TTP = cast<TemplateTemplateParmDecl>(D); - ID.AddInteger(2); - ID.AddBoolean(TTP->isParameterPack()); - ProfileTemplateParameterList(C, ID, TTP->getTemplateParameters()); - } -} - -void -ClassTemplatePartialSpecializationDecl::Profile(llvm::FoldingSetNodeID &ID, - ArrayRef<TemplateArgument> TemplateArgs, TemplateParameterList *TPL, - ASTContext &Context) { - ID.AddInteger(TemplateArgs.size()); - for (const TemplateArgument &TemplateArg : TemplateArgs) - TemplateArg.Profile(ID, Context); - ProfileTemplateParameterList(Context, ID, TPL); +ClassTemplateDecl::findPartialSpecialization(ArrayRef<TemplateArgument> Args, + void *&InsertPos) { + return findSpecializationImpl(getPartialSpecializations(), Args, InsertPos); } void ClassTemplateDecl::AddPartialSpecialization( @@ -1075,7 +1035,7 @@ VarTemplateDecl::newCommon(ASTContext &C) const { VarTemplateSpecializationDecl * VarTemplateDecl::findSpecialization(ArrayRef<TemplateArgument> Args, void *&InsertPos) { - return findSpecializationImpl(getSpecializations(), InsertPos, Args); + return findSpecializationImpl(getSpecializations(), Args, InsertPos); } void VarTemplateDecl::AddSpecialization(VarTemplateSpecializationDecl *D, @@ -1085,19 +1045,8 @@ void VarTemplateDecl::AddSpecialization(VarTemplateSpecializationDecl *D, VarTemplatePartialSpecializationDecl * VarTemplateDecl::findPartialSpecialization(ArrayRef<TemplateArgument> Args, - TemplateParameterList *TPL, void *&InsertPos) { - return findSpecializationImpl(getPartialSpecializations(), InsertPos, Args, - TPL); -} - -void -VarTemplatePartialSpecializationDecl::Profile(llvm::FoldingSetNodeID &ID, - ArrayRef<TemplateArgument> TemplateArgs, TemplateParameterList *TPL, - ASTContext &Context) { - ID.AddInteger(TemplateArgs.size()); - for (const TemplateArgument &TemplateArg : TemplateArgs) - TemplateArg.Profile(ID, Context); - ProfileTemplateParameterList(Context, ID, TPL); + void *&InsertPos) { + return findSpecializationImpl(getPartialSpecializations(), Args, InsertPos); } void VarTemplateDecl::AddPartialSpecialization( |