diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2016-05-31 06:21:27 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2016-05-31 06:21:27 +0000 |
commit | fa93ce8762e3135eada85f347a94eb5a821ffc7b (patch) | |
tree | b80d9ae07736ad2f05dcd0695ad431e8f8cb5f6d /clang/lib/Sema/SemaDecl.cpp | |
parent | 74b5948f3967f1325fd2ba4218e3d3d71a81d56c (diff) | |
download | bcm5719-llvm-fa93ce8762e3135eada85f347a94eb5a821ffc7b.tar.gz bcm5719-llvm-fa93ce8762e3135eada85f347a94eb5a821ffc7b.zip |
[MSVC] Fix stack overflow in unqualified type lookup logic, by Will
Wilson.
An unqualified lookup for in base classes may cause stack overflow if
the base class is a specialization of current class.
Patch by Will Wilson.
llvm-svn: 271251
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index f845a65a000..64da16add18 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -163,11 +163,17 @@ lookupUnqualifiedTypeNameInBase(Sema &S, const IdentifierInfo &II, auto *TD = TST->getTemplateName().getAsTemplateDecl(); if (!TD) continue; - auto *BasePrimaryTemplate = - dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl()); - if (!BasePrimaryTemplate) - continue; - BaseRD = BasePrimaryTemplate; + if (auto *BasePrimaryTemplate = + dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl())) { + if (BasePrimaryTemplate->getCanonicalDecl() != RD->getCanonicalDecl()) + BaseRD = BasePrimaryTemplate; + else if (auto *CTD = dyn_cast<ClassTemplateDecl>(TD)) { + if (const ClassTemplatePartialSpecializationDecl *PS = + CTD->findPartialSpecialization(Base.getType())) + if (PS->getCanonicalDecl() != RD->getCanonicalDecl()) + BaseRD = PS; + } + } } if (BaseRD) { for (NamedDecl *ND : BaseRD->lookup(&II)) { |