aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2024-03-21 20:50:26 +0000
committerDimitry Andric <dim@FreeBSD.org>2024-04-06 20:14:31 +0000
commit49a6e426df84eff1ae54905a02f66910a6a177d3 (patch)
tree9ce2893a0a0c04f15412e58516f7575590669140 /contrib
parentce4f1f49e036fd806b534decfe38020dae32a384 (diff)
downloadsrc-49a6e426df84eff1ae54905a02f66910a6a177d3.tar.gz
src-49a6e426df84eff1ae54905a02f66910a6a177d3.zip
Merge commit f5f3d5d6534f from llvm-project (by Qizhi Hu):
[Clang][Sema] Fix a crash in lambda instantiation (#85565) Fix https://github.com/llvm/llvm-project/issues/85343 When build lambda expression in lambda instantiation, `ThisType` is required in `Sema::CheckCXXThisCapture` to build `this` capture. Set `this` type by import `Sema::CXXThisScopeRAII` and it will be used later in lambda expression transformation. Co-authored-by: huqizhi <836744285@qq.com> This fixes 'Assertion failed: (!isNull() && "Cannot retrieve a NULL type pointer"), function getCommonPtr" when building the x11-wm/wayfire port. PR: 276104 MFC after: 1 month
Diffstat (limited to 'contrib')
-rw-r--r--contrib/llvm-project/clang/lib/Sema/TreeTransform.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/contrib/llvm-project/clang/lib/Sema/TreeTransform.h b/contrib/llvm-project/clang/lib/Sema/TreeTransform.h
index e55e752b9cc3..2f012cade6b9 100644
--- a/contrib/llvm-project/clang/lib/Sema/TreeTransform.h
+++ b/contrib/llvm-project/clang/lib/Sema/TreeTransform.h
@@ -13516,6 +13516,16 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
// Capturing 'this' is trivial.
if (C->capturesThis()) {
+ // If this is a lambda that is part of a default member initialiser
+ // and which we're instantiating outside the class that 'this' is
+ // supposed to refer to, adjust the type of 'this' accordingly.
+ //
+ // Otherwise, leave the type of 'this' as-is.
+ Sema::CXXThisScopeRAII ThisScope(
+ getSema(),
+ dyn_cast_if_present<CXXRecordDecl>(
+ getSema().getFunctionLevelDeclContext()),
+ Qualifiers());
getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
/*BuildAndDiagnose*/ true, nullptr,
C->getCaptureKind() == LCK_StarThis);