[clang] 7c3c243 - Supports viewing class member variables in lambda when using the vs debugger (#71564)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 21 15:33:20 PST 2023
Author: GkvJwa
Date: 2023-11-21T15:33:16-08:00
New Revision: 7c3c243c9bf80377fcad6c7699dc9aaedd650a18
URL: https://github.com/llvm/llvm-project/commit/7c3c243c9bf80377fcad6c7699dc9aaedd650a18
DIFF: https://github.com/llvm/llvm-project/commit/7c3c243c9bf80377fcad6c7699dc9aaedd650a18.diff
LOG: Supports viewing class member variables in lambda when using the vs debugger (#71564)
Use "__this" in DataMemberRecord, make vs debugger can be parsed normally
Fixes #71562
Added:
clang/test/CodeGenCXX/debug-info-lambda-this.cpp
Modified:
clang/lib/CodeGen/CGDebugInfo.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 0b52d99ad07f164..3b4932cc4a30f6b 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1657,8 +1657,10 @@ void CGDebugInfo::CollectRecordLambdaFields(
FieldDecl *f = *Field;
llvm::DIFile *VUnit = getOrCreateFile(f->getLocation());
QualType type = f->getType();
+ StringRef ThisName =
+ CGM.getCodeGenOpts().EmitCodeView ? "__this" : "this";
llvm::DIType *fieldType = createFieldType(
- "this", type, f->getLocation(), f->getAccess(),
+ ThisName, type, f->getLocation(), f->getAccess(),
layout.getFieldOffset(fieldno), VUnit, RecordTy, CXXDecl);
elements.push_back(fieldType);
diff --git a/clang/test/CodeGenCXX/debug-info-lambda-this.cpp b/clang/test/CodeGenCXX/debug-info-lambda-this.cpp
new file mode 100644
index 000000000000000..0a2f08ea4aa6d8e
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-lambda-this.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited -gcodeview -emit-llvm -o - | FileCheck %s
+
+class Foo {
+ public:
+ void foo() {
+ int aa = 2;
+ auto f = [=] {
+ int aaa = a + aa;
+ };
+ f();
+ }
+
+ private:
+ int a = 1;
+};
+
+int main() {
+ Foo f;
+ f.foo();
+
+ return 0;
+}
+
+// CHECK: !{![[FOO_THIS:[0-9]+]], ![[FOO_AA:[0-9]+]], ![[FOO_OPERATOR:[0-9]+]]}
+// CHECK-NEXT: ![[FOO_THIS]] = !DIDerivedType(tag: DW_TAG_member, name: "__this", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[#]], size: [[#]])
+// CHECK-NEXT: ![[FOO_AA]] = !DIDerivedType(tag: DW_TAG_member, name: "aa", scope: ![[#]], file: ![[#]], line: [[#]], baseType: ![[#]], size: [[#]], offset: [[#]])
+// CHECK-NEXT: ![[FOO_OPERATOR]] = !DISubprogram(name: "operator()", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#]], scopeLine: [[#]], flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
More information about the cfe-commits
mailing list