aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2008-06-09 10:47:41 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2008-06-09 10:47:41 +0000
commit507de85bc1cee904123ef99c58159c97df40a3ae (patch)
treef60bab059f7942e1e5942826f2507513c7b94d33 /lib/CodeGen
parent4caf055b9f08416d956590358796a1ed464b73f7 (diff)
Generate debug descriptors for array types while generating the debug info.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52140 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp62
-rw-r--r--lib/CodeGen/CGDebugInfo.h4
2 files changed, 63 insertions, 3 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 70a6f6607e..813efd20d8 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -48,6 +48,7 @@ CGDebugInfo::CGDebugInfo(CodeGenModule *m)
, VariableDescList()
, GlobalVarDescList()
, EnumDescList()
+, SubrangeDescList()
, Subprogram(NULL)
{
SR = new llvm::DISerializer();
@@ -96,6 +97,12 @@ CGDebugInfo::~CGDebugInfo()
delete *I;
}
+ // Free subrange descriptors.
+ for (std::vector<llvm::SubrangeDesc *>::iterator I
+ = SubrangeDescList.begin(); I != SubrangeDescList.end(); ++I) {
+ delete *I;
+ }
+
delete CompileUnitAnchor;
delete SubprogramAnchor;
delete GlobalVariableAnchor;
@@ -457,6 +464,52 @@ CGDebugInfo::getOrCreateEnumType(QualType type, llvm::CompileUnitDesc *Unit)
return EnumTy;
}
+/// getOrCreateArrayType - get or create array types.
+llvm::TypeDesc *
+CGDebugInfo::getOrCreateArrayType(QualType type, llvm::CompileUnitDesc *Unit)
+{
+ llvm::CompositeTypeDesc *ArrayTy
+ = new llvm::CompositeTypeDesc(llvm::dwarf::DW_TAG_array_type);
+
+ // Size, align and offset of the type.
+ uint64_t Size = M->getContext().getTypeSize(type);
+ uint64_t Align = M->getContext().getTypeAlign(type);
+
+ SourceManager &SM = M->getContext().getSourceManager();
+ uint64_t Line = SM.getLogicalLineNumber(CurLoc);
+
+ // Add the dimensions of the array.
+ std::vector<llvm::DebugInfoDesc *> &Elements = ArrayTy->getElements();
+ do {
+ llvm::SubrangeDesc *Subrange = new llvm::SubrangeDesc();
+
+ // push it back on the subrange desc list so that we can free it later.
+ SubrangeDescList.push_back(Subrange);
+
+ uint64_t Upper = 0;
+ if (type->getTypeClass() == Type::ConstantArray) {
+ const ConstantArrayType *ConstArrTy = type->getAsConstantArrayType();
+ Upper = ConstArrTy->getSize().getZExtValue() - 1;
+ }
+ Subrange->setLo(0);
+ Subrange->setHi(Upper);
+ Elements.push_back(Subrange);
+ type = type->getAsArrayType()->getElementType();
+ } while (type->isArrayType());
+
+ ArrayTy->setFromType(getOrCreateType(type, Unit));
+
+ if (ArrayTy) {
+ ArrayTy->setContext(Unit);
+ ArrayTy->setSize(Size);
+ ArrayTy->setAlign(Align);
+ ArrayTy->setOffset(0);
+ ArrayTy->setFile(getOrCreateCompileUnit(CurLoc));
+ ArrayTy->setLine(Line);
+ }
+ return ArrayTy;
+}
+
/// getOrCreateTaggedType - get or create structure/union/Enum type.
llvm::TypeDesc *
@@ -492,9 +545,6 @@ CGDebugInfo::getOrCreateType(QualType type, llvm::CompileUnitDesc *Unit)
switch(type->getTypeClass()) {
case Type::Complex:
case Type::Reference:
- case Type::ConstantArray:
- case Type::VariableArray:
- case Type::IncompleteArray:
case Type::Vector:
case Type::ExtVector:
case Type::ASQual:
@@ -528,6 +578,12 @@ CGDebugInfo::getOrCreateType(QualType type, llvm::CompileUnitDesc *Unit)
case Type::Tagged:
Slot = getOrCreateTaggedType(type, Unit);
break;
+
+ case Type::ConstantArray:
+ case Type::VariableArray:
+ case Type::IncompleteArray:
+ Slot = getOrCreateArrayType(type, Unit);
+ break;
}
return Slot;
diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h
index 129ba9419c..61664a6962 100644
--- a/lib/CodeGen/CGDebugInfo.h
+++ b/lib/CodeGen/CGDebugInfo.h
@@ -35,6 +35,7 @@ namespace llvm {
class GlobalVariable;
class GlobalVariableDesc;
class EnumeratorDesc;
+ class SubrangeDesc;
}
namespace clang {
@@ -71,6 +72,7 @@ private:
std::vector<llvm::VariableDesc *> VariableDescList;
std::vector<llvm::GlobalVariableDesc *> GlobalVarDescList;
std::vector<llvm::EnumeratorDesc *> EnumDescList;
+ std::vector<llvm::SubrangeDesc *> SubrangeDescList;
llvm::SubprogramDesc *Subprogram;
/// Helper functions for getOrCreateType.
@@ -90,6 +92,8 @@ private:
llvm::CompileUnitDesc *unit);
llvm::TypeDesc *getOrCreateTaggedType(QualType type,
llvm::CompileUnitDesc *unit);
+ llvm::TypeDesc *getOrCreateArrayType(QualType type,
+ llvm::CompileUnitDesc *unit);
public:
CGDebugInfo(CodeGenModule *m);