aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-08-21 21:03:37 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-08-26 18:05:01 +0000
commit9e1de6e8250355cda0615332d43bbba61d4d873f (patch)
tree80bb65c4a61455b8755fa0c9337e9a8bf368c086
parentc4055d704360af150d4c9f535aef7a53e99f9d75 (diff)
downloadsrc-9e1de6e8250355cda0615332d43bbba61d4d873f.tar.gz
src-9e1de6e8250355cda0615332d43bbba61d4d873f.zip
Apply clang fix for assertion failure compiling multimedia/minitube
Merge commit 79f9cfbc21e0 from llvm git (by Yaxun (Sam) Liu): Do not merge LocalInstantiationScope for template specialization A lambda in a function template may be recursively instantiated. The recursive lambda will cause a lambda function instantiated multiple times, one inside another. The inner LocalInstantiationScope should not be marked as MergeWithParentScope since it already has references to locals properly substituted, otherwise it causes assertion due to the check for duplicate locals in merged LocalInstantiationScope. Reviewed by: Richard Smith Differential Revision: https://reviews.llvm.org/D98068 Reported by: yuri PR: 257978 (cherry picked from commit efa485d5c390b745f53761da9159721243c48b7b)
-rw-r--r--contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index f801e79c8902..f36fa8d11b3b 100644
--- a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4658,10 +4658,13 @@ void Sema::InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
// Introduce a new scope where local variable instantiations will be
// recorded, unless we're actually a member function within a local
// class, in which case we need to merge our results with the parent
- // scope (of the enclosing function).
+ // scope (of the enclosing function). The exception is instantiating
+ // a function template specialization, since the template to be
+ // instantiated already has references to locals properly substituted.
bool MergeWithParentScope = false;
if (CXXRecordDecl *Rec = dyn_cast<CXXRecordDecl>(Function->getDeclContext()))
- MergeWithParentScope = Rec->isLocalClass();
+ MergeWithParentScope =
+ Rec->isLocalClass() && !Function->isFunctionTemplateSpecialization();
LocalInstantiationScope Scope(*this, MergeWithParentScope);