[pkg-d-commits] [ldc] 25/211: Debuginfo: use inheritance information for base classes instead of listing base class members in derived classes
Matthias Klumpp
mak at moszumanska.debian.org
Sun Apr 23 22:36:06 UTC 2017
This is an automated email from the git hooks/post-receive script.
mak pushed a commit to annotated tag v1.1.0
in repository ldc.
commit daa404d5239addb34d703d7cb9b6b009130c41f9
Author: Rainer Schuetze <r.sagitario at gmx.de>
Date: Sat Sep 17 11:38:06 2016 +0200
Debuginfo: use inheritance information for base classes instead of listing base class members in derived classes
---
gen/dibuilder.cpp | 58 +++++++++++++++++++++++++++++--------------
gen/dibuilder.h | 8 +++---
tests/debuginfo/cvbaseclass.d | 39 +++++++++++++++++++++++++++++
3 files changed, 83 insertions(+), 22 deletions(-)
diff --git a/gen/dibuilder.cpp b/gen/dibuilder.cpp
index 75b1065..80cce33 100644
--- a/gen/dibuilder.cpp
+++ b/gen/dibuilder.cpp
@@ -53,7 +53,16 @@ ldc::DIType getNullDIType() {
return llvm::DIType();
#endif
}
+
+#if LDC_LLVM_VER >= 307
+llvm::DINodeArray getEmptyDINodeArray() {
+ return nullptr;
}
+#else
+llvm::DIArray getEmptyDINodeArray() {
+ return llvm::DIArray();
+}
+#endif
llvm::StringRef uniqueIdent(Type* t) {
#if LDC_LLVM_VER >= 309
@@ -63,6 +72,8 @@ llvm::StringRef uniqueIdent(Type* t) {
return llvm::StringRef();
}
+} // namespace
+
////////////////////////////////////////////////////////////////////////////////
// get the module the symbol is in, or - for template instances - the current
@@ -363,11 +374,8 @@ ldc::DIType ldc::DIBuilder::CreateMemberType(unsigned linnum, Type *type,
);
}
-void ldc::DIBuilder::AddBaseFields(ClassDeclaration *sd, ldc::DIFile file,
- llvm::SmallVector<LLMetadata *, 16> &elems) {
- if (sd->baseClass)
- AddBaseFields(sd->baseClass, file, elems);
-
+void ldc::DIBuilder::AddFields(AggregateDeclaration *sd, ldc::DIFile file,
+ llvm::SmallVector<LLMetadata *, 16> &elems) {
size_t narr = sd->fields.dim;
elems.reserve(narr);
for (auto vd : sd->fields) {
@@ -430,20 +438,34 @@ ldc::DIType ldc::DIBuilder::CreateCompositeType(Type *type) {
if (!sd->isInterfaceDeclaration()) // plain interfaces don't have one
{
- if (t->ty == Tstruct) {
- elems.reserve(sd->fields.dim);
- for (auto vd : sd->fields) {
- ldc::DIType dt =
- CreateMemberType(vd->loc.linnum, vd->type, file, vd->toChars(),
- vd->offset, vd->prot().kind);
- elems.push_back(dt);
- }
- } else {
- ClassDeclaration *classDecl = sd->isClassDeclaration();
- AddBaseFields(classDecl, file, elems);
- if (classDecl->baseClass)
- derivedFrom = CreateCompositeType(classDecl->baseClass->getType());
+ ClassDeclaration *classDecl = sd->isClassDeclaration();
+ if (classDecl && classDecl->baseClass) {
+ derivedFrom = CreateCompositeType(classDecl->baseClass->getType());
+ // needs a forward declaration to add inheritence information to elems
+ ldc::DIType fwd =
+ DBuilder.createClassType(CU, // compile unit where defined
+ name, // name
+ file, // file where defined
+ linnum, // line number where defined
+ getTypeAllocSize(T) * 8, // size in bits
+ getABITypeAlign(T) * 8, // alignment in bits
+ 0, // offset in bits,
+ DIFlags::FlagFwdDecl, // flags
+ derivedFrom, // DerivedFrom
+ getEmptyDINodeArray(),
+ getNullDIType(), // VTableHolder
+ nullptr, // TemplateParms
+ uniqueIdent(t)); // UniqueIdentifier
+ auto dt = DBuilder.createInheritance(fwd, derivedFrom, 0,
+#if LDC_LLVM_VER >= 306
+ DIFlags::FlagPublic
+#else
+ 0
+#endif
+ );
+ elems.push_back(dt);
}
+ AddFields(sd, file, elems);
}
auto elemsArray = DBuilder.getOrCreateArray(elems);
diff --git a/gen/dibuilder.h b/gen/dibuilder.h
index bccf376..cfad426 100644
--- a/gen/dibuilder.h
+++ b/gen/dibuilder.h
@@ -172,13 +172,13 @@ private:
ldc::DIExpression diexpr
#endif
);
- void AddBaseFields(ClassDeclaration *sd, ldc::DIFile file,
+ void AddFields(AggregateDeclaration *sd, ldc::DIFile file,
#if LDC_LLVM_VER >= 306
- llvm::SmallVector<llvm::Metadata *, 16> &elems
+ llvm::SmallVector<llvm::Metadata *, 16> &elems
#else
- llvm::SmallVector<llvm::Value *, 16> &elems
+ llvm::SmallVector<llvm::Value *, 16> &elems
#endif
- );
+ );
DIFile CreateFile(Loc &loc);
DIFile CreateFile();
DIType CreateBasicType(Type *type);
diff --git a/tests/debuginfo/cvbaseclass.d b/tests/debuginfo/cvbaseclass.d
new file mode 100644
index 0000000..790b6ad
--- /dev/null
+++ b/tests/debuginfo/cvbaseclass.d
@@ -0,0 +1,39 @@
+// REQUIRES: atleast_llvm308
+// REQUIRES: Windows
+// REQUIRES: cdb
+// RUN: %ldc -g -of=%t.exe %s
+// RUN: sed -e "/^\\/\\/ CDB:/!d" -e "s,// CDB:,," %s \
+// RUN: | %cdb -snul -lines -y . %t.exe >%t.out
+// RUN: FileCheck %s -check-prefix=CHECK -check-prefix=%arch < %t.out
+
+class BaseClass
+{
+ uint baseMember = 3;
+}
+
+class DerivedClass : BaseClass
+{
+ uint derivedMember = 7;
+}
+
+int main(string[] args)
+{
+ auto dc = new DerivedClass;
+// CDB: ld /f cvbaseclass*
+// enable case sensitive symbol lookup
+// CDB: .symopt-1
+// CDB: bp `cvbaseclass.d:27`
+// CDB: g
+ return 0;
+// CHECK: !D main
+
+// CDB: ?? dc
+// cdb doesn't show base class info, but lists their members
+// CHECK: DerivedClass
+// CHECK: baseMember{{ *: *3}}
+// verify baseMember is not listed twice
+// CHECK-NEXT: derivedMember{{ *: *7}}
+}
+
+// CDB: q
+// CHECK: quit:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git
More information about the pkg-d-commits
mailing list