From 28e3c9982500b6abd9f419f7baa505bebc9065ba Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 19 Sep 2012 21:47:34 +0000 Subject: [PATCH] Handle a captured this for the debug information as well. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164253 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 10 ++++++++++ test/CodeGenCXX/debug-lambda-this.cpp | 15 +++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 test/CodeGenCXX/debug-lambda-this.cpp diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 027c447131..d3391b79af 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -809,6 +809,16 @@ CollectRecordFields(const RecordDecl *record, llvm::DIFile tunit, Field->getAccess(), layout.getFieldOffset(fieldno), VUnit, RecordTy); elements.push_back(fieldType); + } else { + assert(C.capturesThis() && "Field that isn't captured and isn't this?"); + FieldDecl *f = *Field; + llvm::DIFile VUnit = getOrCreateFile(f->getLocation()); + QualType type = f->getType(); + llvm::DIType fieldType + = createFieldType("this", type, 0, f->getLocation(), f->getAccess(), + layout.getFieldOffset(fieldNo), VUnit, RecordTy); + + elements.push_back(fieldType); } } } else { diff --git a/test/CodeGenCXX/debug-lambda-this.cpp b/test/CodeGenCXX/debug-lambda-this.cpp new file mode 100644 index 0000000000..7c37fbe35c --- /dev/null +++ b/test/CodeGenCXX/debug-lambda-this.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -g | FileCheck %s + +struct D { + D(); + D(const D&); + int x; + int d(int x); +}; +int D::d(int x) { + [=] { + return this->x; + }(); +} + +// CHECK: metadata !{i32 {{.*}}, metadata !"this", metadata !6, i32 11, i64 64, i64 64, i64 0, i32 1, metadata !37} ; [ DW_TAG_member ] [this] [line 11, size 64, align 64, offset 0] [private] [from ] -- 2.40.0