[pkg-d-commits] [ldc] 37/74: DIType for types involving classes were incorrect in some cases.
Matthias Klumpp
mak at moszumanska.debian.org
Thu Jul 13 20:54:17 UTC 2017
This is an automated email from the git hooks/post-receive script.
mak pushed a commit to annotated tag v1.3.0-beta2
in repository ldc.
commit 3338bbf9c0e6f05ee23944ea0127d1c7ce294a24
Author: Elie Morisse <syniurge at gmail.com>
Date: Sun May 21 20:11:59 2017 -0300
DIType for types involving classes were incorrect in some cases.
Static arrays of classes, pointers to class (and perhaps global class variables) ended up with a wrong DIType because of wrong CreateTypeDescription() calls for class types.
Ex.: Array!FuncDeclaration caused an infinite recursion crash in GDB, because for its « FuncDeclaration[SMALLARRAYCAP] smallarray » field DIBuilder::CreateSArrayType() had DIBuilder return a value type instead of a reference type for FuncDeclaration.
---
gen/dibuilder.cpp | 37 +++++++++++++++++++++----------------
gen/dibuilder.h | 2 +-
2 files changed, 22 insertions(+), 17 deletions(-)
diff --git a/gen/dibuilder.cpp b/gen/dibuilder.cpp
index 79267b8..bad8697 100644
--- a/gen/dibuilder.cpp
+++ b/gen/dibuilder.cpp
@@ -276,7 +276,7 @@ ldc::DIType ldc::DIBuilder::CreateEnumType(Type *type) {
getTypeAllocSize(T) * 8, // size (bits)
getABITypeAlign(T) * 8, // align (bits)
DBuilder.getOrCreateArray(subscripts), // subscripts
- CreateTypeDescription(te->sym->memtype, false));
+ CreateTypeDescription(te->sym->memtype));
}
ldc::DIType ldc::DIBuilder::CreatePointerType(Type *type) {
@@ -296,7 +296,7 @@ ldc::DIType ldc::DIBuilder::CreatePointerType(Type *type) {
const llvm::Optional<unsigned> DWARFAddressSpace = llvm::None;
#endif
- return DBuilder.createPointerType(CreateTypeDescription(nt, false),
+ return DBuilder.createPointerType(CreateTypeDescription(nt),
getTypeAllocSize(T) * 8, // size (bits)
getABITypeAlign(T) * 8, // align (bits)
#if LDC_LLVM_VER >= 500
@@ -323,7 +323,7 @@ ldc::DIType ldc::DIBuilder::CreateVectorType(Type *type) {
return DBuilder.createVectorType(
getTypeAllocSize(T) * 8, // size (bits)
getABITypeAlign(T) * 8, // align (bits)
- CreateTypeDescription(te, false), // element type
+ CreateTypeDescription(te), // element type
DBuilder.getOrCreateArray(subscripts) // subscripts
);
}
@@ -381,7 +381,7 @@ ldc::DIType ldc::DIBuilder::CreateMemberType(unsigned linnum, Type *type,
llvm::Type *T = DtoType(t);
// find base type
- ldc::DIType basetype = CreateTypeDescription(t, true);
+ ldc::DIType basetype = CreateTypeDescription(t);
auto Flags = DIFlagZero;
switch (prot) {
@@ -600,7 +600,7 @@ ldc::DIType ldc::DIBuilder::CreateSArrayType(Type *type) {
return DBuilder.createArrayType(
getTypeAllocSize(T) * 8, // size (bits)
getABITypeAlign(T) * 8, // align (bits)
- CreateTypeDescription(t, false), // element type
+ CreateTypeDescription(t), // element type
DBuilder.getOrCreateArray(subscripts) // subscripts
);
}
@@ -618,7 +618,7 @@ ldc::DISubroutineType ldc::DIBuilder::CreateFunctionType(Type *type) {
Type *retType = t->next;
// Create "dummy" subroutine type for the return type
- LLMetadata *params = {CreateTypeDescription(retType, true)};
+ LLMetadata *params = {CreateTypeDescription(retType)};
#if LDC_LLVM_VER == 305
auto paramsArray = DBuilder.getOrCreateArray(params);
#else
@@ -683,16 +683,12 @@ bool isOpaqueEnumType(Type *type) {
return !te->sym->memtype;
}
-ldc::DIType ldc::DIBuilder::CreateTypeDescription(Type *type, bool derefclass) {
+ldc::DIType ldc::DIBuilder::CreateTypeDescription(Type *type) {
// Check for opaque enum first, Bugzilla 13792
if (isOpaqueEnumType(type))
return DBuilder.createUnspecifiedType(type->toChars());
Type *t = type->toBasetype();
- if (derefclass && t->ty == Tclass) {
- type = type->pointerTo();
- t = type->toBasetype();
- }
if (t->ty == Tvoid)
#if LDC_LLVM_VER >= 309
@@ -701,7 +697,7 @@ ldc::DIType ldc::DIBuilder::CreateTypeDescription(Type *type, bool derefclass) {
return DBuilder.createUnspecifiedType(t->toChars());
#endif
if (t->ty == Tnull) // display null as void*
- return DBuilder.createPointerType(CreateTypeDescription(Type::tvoid, false),
+ return DBuilder.createPointerType(CreateTypeDescription(Type::tvoid),
8, 8,
#if LDC_LLVM_VER >= 500
/* DWARFAddressSpace */ llvm::None,
@@ -723,8 +719,17 @@ ldc::DIType ldc::DIBuilder::CreateTypeDescription(Type *type, bool derefclass) {
return CreateSArrayType(type);
if (t->ty == Taarray)
return CreateAArrayType(type);
- if (t->ty == Tstruct || t->ty == Tclass)
+ if (t->ty == Tstruct)
return CreateCompositeType(type);
+ if (t->ty == Tclass) {
+ LLType* T = DtoType(t);
+ return DBuilder.createPointerType(CreateCompositeType(type),
+ getTypeAllocSize(T) * 8, getABITypeAlign(T) * 8,
+#if LDC_LLVM_VER >= 500
+ llvm::None,
+#endif
+ t->toChars());
+ }
if (t->ty == Tfunction)
return CreateFunctionType(type);
if (t->ty == Tdelegate)
@@ -932,7 +937,7 @@ ldc::DISubprogram ldc::DIBuilder::EmitModuleCTor(llvm::Function *Fn,
ldc::DIFile file = CreateFile();
// Create "dummy" subroutine type for the return type
- LLMetadata *params = {CreateTypeDescription(Type::tvoid, true)};
+ LLMetadata *params = {CreateTypeDescription(Type::tvoid)};
#if LDC_LLVM_VER >= 306
auto paramsArray = DBuilder.getOrCreateTypeArray(params);
#else
@@ -1100,7 +1105,7 @@ void ldc::DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
// get type description
if (!type)
type = vd->type;
- ldc::DIType TD = CreateTypeDescription(type, true);
+ ldc::DIType TD = CreateTypeDescription(type);
if (static_cast<llvm::MDNode *>(TD) == nullptr)
return; // unsupported
@@ -1244,7 +1249,7 @@ void ldc::DIBuilder::EmitGlobalVariable(llvm::GlobalVariable *llVar,
mangleBuf.peekString(), // linkage name
CreateFile(vd), // file
vd->loc.linnum, // line num
- CreateTypeDescription(vd->type, false), // type
+ CreateTypeDescription(vd->type), // type
vd->protection.kind == PROTprivate, // is local to unit
#if LDC_LLVM_VER >= 400
nullptr // relative location of field
diff --git a/gen/dibuilder.h b/gen/dibuilder.h
index 200c632..5764ff7 100644
--- a/gen/dibuilder.h
+++ b/gen/dibuilder.h
@@ -198,7 +198,7 @@ private:
DISubroutineType CreateFunctionType(Type *type);
DISubroutineType CreateEmptyFunctionType();
DIType CreateDelegateType(Type *type);
- DIType CreateTypeDescription(Type *type, bool derefclass = false);
+ DIType CreateTypeDescription(Type *type);
bool mustEmitFullDebugInfo();
bool mustEmitLocationsDebugInfo();
--
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