From 905da30ce17f757e4c75ff6cba3bc31cf39a9c37 Mon Sep 17 00:00:00 2001 From: kai Date: Wed, 5 Jun 2013 07:19:55 +0200 Subject: [PATCH] Implement debug info for static arrays. This fixes issue #356. --- gen/todebug.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gen/todebug.cpp b/gen/todebug.cpp index 964f6fb1..06483bc6 100644 --- a/gen/todebug.cpp +++ b/gen/todebug.cpp @@ -407,6 +407,33 @@ static llvm::DIType dwarfArrayType(Type* type) { ////////////////////////////////////////////////////////////////////////////////////////////////// +static llvm::DIType dwarfSArrayType(Type *type) +{ + llvm::Type *T = DtoType(type); + Type *t = type->toBasetype(); + + // find base type + llvm::SmallVector subscripts; + while (t->ty == Tsarray) + { + TypeSArray *tsa = static_cast(t); + int64_t Count = tsa->dim->toInteger(); + llvm::Value *subscript = gIR->dibuilder.getOrCreateSubrange(0, Count-1); + subscripts.push_back(subscript); + t = t->nextOf(); + } + llvm::DIType basetype = dwarfTypeDescription_impl(t, NULL); + + return gIR->dibuilder.createArrayType( + getTypeBitSize(T), // size (bits) + getABITypeAlign(T)*8, // align (bits) + basetype, // element type + gIR->dibuilder.getOrCreateArray(subscripts) // subscripts + ); +} + +////////////////////////////////////////////////////////////////////////////////////////////////// + static llvm::DIType dwarfTypeDescription_impl(Type* type, const char* c_name) { Type* t = type->toBasetype(); @@ -420,6 +447,8 @@ static llvm::DIType dwarfTypeDescription_impl(Type* type, const char* c_name) return dwarfPointerType(type); else if (t->ty == Tarray) return dwarfArrayType(type); + else if (t->ty == Tsarray) + return dwarfSArrayType(type); else if (t->ty == Tstruct || t->ty == Tclass) return dwarfCompositeType(type);