[llvm] Supports viewing class member variables in lambda when using the vs debugger (PR #71564)

Zequan Wu via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 08:56:53 PST 2023


================
@@ -2605,6 +2605,9 @@ CodeViewDebug::lowerRecordFieldList(const DICompositeType *Ty) {
       MemberBaseType = TypeTable.writeLeafType(BFR);
     }
     uint64_t MemberOffsetInBytes = MemberOffsetInBits / 8;
+    if (Ty->getName().find("<lambda") != std::string::npos) {
+      MemberName = "__this";
+    }
----------------
ZequanWu wrote:

Just realized that this fix should be done in Clang:
https://github.com/llvm/llvm-project/blob/0e42df4031e8b2fec357e07ca5ca3b81adf0b5ad/clang/lib/CodeGen/CGDebugInfo.cpp#L1660-L1662

When emitting codeview, use `__this` for the captured `this`.
```
      StringRef ThisName = CGM.getCodeGenOpts().EmitCodeView ? "__this": "this";
      llvm::DIType *fieldType = createFieldType(
          ThisName, type, f->getLocation(), f->getAccess(),
          layout.getFieldOffset(fieldno), VUnit, RecordTy, CXXDecl);
```

Then, the test can be a C++ file put inside `clang/test/CodeGenCXX`.

https://github.com/llvm/llvm-project/pull/71564


More information about the llvm-commits mailing list