llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-debuginfo Author: Ayush Pareek (ayushpareek2003) <details> <summary>Changes</summary> Fix an issue where local lambdas caused a crash when importing the std module in LLDB due to missing capture fields in debug info. Now closures always emit all fields for lambdas by skipping the `isImplicit` check. This unblocks libc++ from using local lambdas freely --- Full diff: https://github.com/llvm/llvm-project/pull/149674.diff 1 Files Affected: - (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+26) ``````````diff diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index e24c68ed02865..a8f9e3e028e9f 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4187,6 +4187,32 @@ llvm::DICompositeType *CGDebugInfo::CreateLimitedType(const RecordType *Ty) { RegionMap[Ty->getDecl()].reset(RealDecl); TypeCache[QualType(Ty, 0).getAsOpaquePtr()].reset(RealDecl); + if (const auto *CXXRD = dyn_cast<CXXRecordDecl>(RD)) { + SmallVector<llvm::Metadata *, 16> EltTys; + const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(CXXRD); + + for (const FieldDecl *Field : CXXRD->fields()) { + if (!CXXRD->isLambda() && Field->isImplicit()) + continue; + + llvm::DIType *FieldType = getOrCreateType(Field->getType(), DefUnit); + unsigned FieldLine = getLineNumber(Field->getLocation()); + uint64_t FieldOffset = Layout.getFieldOffset(Field->getFieldIndex()); + llvm::DIFile *FieldFile = DefUnit; + + llvm::DIDerivedType *Elem = DBuilder.createMemberType( + RealDecl, Field->getName(), FieldFile, FieldLine, + CGM.getContext().getTypeSize(Field->getType()), + getTypeAlignIfRequired(Field->getType(), CGM.getContext()), + FieldOffset, + getAccessFlag(Field->getAccess()), FieldType); + + EltTys.push_back(Elem); + } + // Attach the fields. + DBuilder.replaceArrays(RealDecl, DBuilder.getOrCreateArray(EltTys)); + } + if (const auto *TSpecial = dyn_cast<ClassTemplateSpecializationDecl>(RD)) DBuilder.replaceArrays(RealDecl, llvm::DINodeArray(), CollectCXXTemplateParams(TSpecial, DefUnit)); `````````` </details> https://github.com/llvm/llvm-project/pull/149674 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits