1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

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
This commit is contained in:
Dimitry Andric 2024-03-21 21:50:26 +01:00
parent ce4f1f49e0
commit 49a6e426df

View File

@ -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);