Changes in directory llvm/lib/CodeGen:
DwarfWriter.cpp updated: 1.28 -> 1.29 MachineDebugInfo.cpp updated: 1.16 -> 1.17 --- Log message: Added basic support for typedefs. --- Diffs of the changes: (+56 -15) DwarfWriter.cpp | 37 ++++++++++++++++++++++++------------- MachineDebugInfo.cpp | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 15 deletions(-) Index: llvm/lib/CodeGen/DwarfWriter.cpp diff -u llvm/lib/CodeGen/DwarfWriter.cpp:1.28 llvm/lib/CodeGen/DwarfWriter.cpp:1.29 --- llvm/lib/CodeGen/DwarfWriter.cpp:1.28 Thu Feb 23 10:58:18 2006 +++ llvm/lib/CodeGen/DwarfWriter.cpp Thu Feb 23 16:37:30 2006 @@ -1244,23 +1244,34 @@ // FIXME - handle larger sizes. unsigned Size = TyDesc->getSize() >> 3; - // Determine how to handle. - if (BasicTypeDesc *BasicTyDesc = dyn_cast<BasicTypeDesc>(TyDesc)) { - unsigned Encoding = BasicTyDesc->getEncoding(); + DIE *Ty = NULL; - DIE *Ty = new DIE(DW_TAG_base_type); - if (!Name.empty()) Ty->AddString(DW_AT_name, DW_FORM_string, Name); - - Ty->AddUInt (DW_AT_byte_size, 0, Size); - Ty->AddUInt (DW_AT_encoding, DW_FORM_data1, Encoding); - - Slot = Ty; - } else { - assert(0 && "Type not supported yet"); + // Determine how to handle. + if (BasicTypeDesc *BasicTy = dyn_cast<BasicTypeDesc>(TyDesc)) { + Slot = Ty = new DIE(DW_TAG_base_type); + unsigned Encoding = BasicTy->getEncoding(); + Ty->AddUInt (DW_AT_encoding, DW_FORM_data1, Encoding); + } else if (TypedefDesc *TypedefTy = dyn_cast<TypedefDesc>(TyDesc)) { + Slot = Ty = new DIE(DW_TAG_typedef); + TypeDesc *FromTy = TypedefTy->getFromType(); + DIE *FromTyDie = NewType(Unit, FromTy); + CompileUnitDesc *File = TypedefTy->getFile(); + unsigned FileID = DebugInfo->RecordSource(File); + int Line = TypedefTy->getLine(); + + Ty->AddDIEntry(DW_AT_type, DW_FORM_ref4, FromTyDie); + Ty->AddUInt (DW_AT_decl_file, 0, FileID); + Ty->AddUInt (DW_AT_decl_line, 0, Line); } + + assert(Ty && "Type not supported yet"); + // Add common information. + if (Size) Ty->AddUInt(DW_AT_byte_size, 0, Size); + if (!Name.empty()) Ty->AddString(DW_AT_name, DW_FORM_string, Name); + // Add to context owner. - Unit->AddChild(Slot); + Unit->AddChild(Ty); return Slot; } Index: llvm/lib/CodeGen/MachineDebugInfo.cpp diff -u llvm/lib/CodeGen/MachineDebugInfo.cpp:1.16 llvm/lib/CodeGen/MachineDebugInfo.cpp:1.17 --- llvm/lib/CodeGen/MachineDebugInfo.cpp:1.16 Thu Feb 23 10:58:18 2006 +++ llvm/lib/CodeGen/MachineDebugInfo.cpp Thu Feb 23 16:37:30 2006 @@ -430,6 +430,7 @@ case DI_TAG_global_variable: return new GlobalVariableDesc(); case DI_TAG_subprogram: return new SubprogramDesc(); case DI_TAG_basictype: return new BasicTypeDesc(); + case DI_TAG_typedef: return new TypedefDesc(); default: break; } return NULL; @@ -561,8 +562,6 @@ //===----------------------------------------------------------------------===// -//===----------------------------------------------------------------------===// - TypeDesc::TypeDesc(unsigned T) : DebugInfoDesc(T) , Context(NULL) @@ -627,6 +626,37 @@ << "Encoding(" << Encoding << ")\n"; } #endif +//===----------------------------------------------------------------------===// + +TypedefDesc::TypedefDesc() +: TypeDesc(DI_TAG_typedef) +, FromType(NULL) +, File(NULL) +, Line(0) +{} + +/// ApplyToFields - Target the visitor to the fields of the TypedefDesc. +/// +void TypedefDesc::ApplyToFields(DIVisitor *Visitor) { + TypeDesc::ApplyToFields(Visitor); + + Visitor->Apply((DebugInfoDesc *&)FromType); + Visitor->Apply((DebugInfoDesc *&)File); + Visitor->Apply(Line); +} + +#ifndef NDEBUG +void TypedefDesc::dump() { + std::cerr << getDescString() << " " + << "Tag(" << getTag() << "), " + << "Context(" << getContext() << "), " + << "Name(\"" << getName() << "\"), " + << "Size(" << getSize() << "), " + << "FromType(" << FromType << "), " + << "File(" << File << "), " + << "Line(" << Line << ")\n"; +} +#endif //===----------------------------------------------------------------------===// _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits