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

Zequan Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 14 07:39:09 PST 2023


================
@@ -0,0 +1,48 @@
+// RUN: %clang_cl --target=x86_64-windows-msvc /c /Z7 -o %t.obj -- %s
+// RUN: llvm-pdbutil dump -all %t.obj | FileCheck %s
+
+class Foo {
+ public:
+  void foo() {
+    int aa = 4;
+    int bb = 5;
+    int cc = 6;
+    auto f = [=] {
+      int aaa = a + aa;
+      int bbb = b + bb;
+      int ccc = c + cc;
+    };
+    f();
+  }
+
+ private:
+  int a = 1;
+  int b = 2;
+  int c = 3;
+};
+
+int main() {
+  Foo f;
+  f.foo();
+
+  return 0;
+}
+
+// CHECK:                       Types (.debug$T)
+// CHECK-NEXT: ============================================================
+// CHECK:[[FooIndex:0x[^ ]*]] | LF_CLASS [size = 36] `Foo`
+// CHECK:         unique name: `.?AVFoo@@`
+// CHECK:[[FooIndex:0x[^ ]*]] | LF_FIELDLIST [size = 52]
----------------
ZequanWu wrote:

Nit: You are creating multiple `FooIndex` but not using it. The purpose of regex string substitution is to capture a pattern that will show up later. Different patterns should have different names. Here, it could be `[[FooFieldIndex:0x[^ ]*]]` In order to use the patterns later, use `0x[[FooFieldIndex]]`. Same applies to other indexes.

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


More information about the cfe-commits mailing list