[cfe-commits] r52140 - in /cfe/trunk/lib/CodeGen: CGDebugInfo.cpp CGDebugInfo.h
Sanjiv Gupta
sanjiv.gupta at microchip.com
Mon Jun 9 03:47:55 PDT 2008
Author: sgupta
Date: Mon Jun 9 05:47:41 2008
New Revision: 52140
URL: http://llvm.org/viewvc/llvm-project?rev=52140&view=rev
Log:
Generate debug descriptors for array types while generating the debug info.
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=52140&r1=52139&r2=52140&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jun 9 05:47:41 2008
@@ -48,6 +48,7 @@
, VariableDescList()
, GlobalVarDescList()
, EnumDescList()
+, SubrangeDescList()
, Subprogram(NULL)
{
SR = new llvm::DISerializer();
@@ -96,6 +97,12 @@
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 @@
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 @@
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 @@
case Type::Tagged:
Slot = getOrCreateTaggedType(type, Unit);
break;
+
+ case Type::ConstantArray:
+ case Type::VariableArray:
+ case Type::IncompleteArray:
+ Slot = getOrCreateArrayType(type, Unit);
+ break;
}
return Slot;
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=52140&r1=52139&r2=52140&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Mon Jun 9 05:47:41 2008
@@ -35,6 +35,7 @@
class GlobalVariable;
class GlobalVariableDesc;
class EnumeratorDesc;
+ class SubrangeDesc;
}
namespace clang {
@@ -71,6 +72,7 @@
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 @@
llvm::CompileUnitDesc *unit);
llvm::TypeDesc *getOrCreateTaggedType(QualType type,
llvm::CompileUnitDesc *unit);
+ llvm::TypeDesc *getOrCreateArrayType(QualType type,
+ llvm::CompileUnitDesc *unit);
public:
CGDebugInfo(CodeGenModule *m);
More information about the cfe-commits
mailing list