From 8b3fad9343111eec5931492fbd812ad578c71089 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 5 Mar 2014 01:44:58 +0000 Subject: [PATCH] Use a bool for whether or not an abbreviation has children rather than using a full uint16_t with the flag value... which happens to be 0 or 1. Update the class for bool values and rename functions slightly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202921 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DIE.cpp | 8 ++++---- lib/CodeGen/AsmPrinter/DIE.h | 20 +++++++++++--------- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 5 ++--- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DIE.cpp b/lib/CodeGen/AsmPrinter/DIE.cpp index c989ce75abf..e8be7ad626d 100644 --- a/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/lib/CodeGen/AsmPrinter/DIE.cpp @@ -49,7 +49,7 @@ void DIEAbbrevData::Profile(FoldingSetNodeID &ID) const { /// void DIEAbbrev::Profile(FoldingSetNodeID &ID) const { ID.AddInteger(unsigned(Tag)); - ID.AddInteger(ChildrenFlag); + ID.AddInteger(unsigned(Children)); // For each attribute description. for (unsigned i = 0, N = Data.size(); i < N; ++i) @@ -63,7 +63,7 @@ void DIEAbbrev::Emit(AsmPrinter *AP) const { AP->EmitULEB128(Tag, dwarf::TagString(Tag)); // Emit whether it has children DIEs. - AP->EmitULEB128(ChildrenFlag, dwarf::ChildrenString(ChildrenFlag)); + AP->EmitULEB128((unsigned)Children, dwarf::ChildrenString(Children)); // For each attribute description. for (unsigned i = 0, N = Data.size(); i < N; ++i) { @@ -90,7 +90,7 @@ void DIEAbbrev::print(raw_ostream &O) { << " " << dwarf::TagString(Tag) << " " - << dwarf::ChildrenString(ChildrenFlag) + << dwarf::ChildrenString(Children) << '\n'; for (unsigned i = 0, N = Data.size(); i < N; ++i) { @@ -161,7 +161,7 @@ void DIE::print(raw_ostream &O, unsigned IndentCount) const { O << Indent << dwarf::TagString(Abbrev.getTag()) << " " - << dwarf::ChildrenString(Abbrev.getChildrenFlag()) << "\n"; + << dwarf::ChildrenString(Abbrev.hasChildren()) << "\n"; } else { O << "Size: " << Size << "\n"; } diff --git a/lib/CodeGen/AsmPrinter/DIE.h b/lib/CodeGen/AsmPrinter/DIE.h index b04adf53deb..c8900095671 100644 --- a/lib/CodeGen/AsmPrinter/DIE.h +++ b/lib/CodeGen/AsmPrinter/DIE.h @@ -56,31 +56,33 @@ public: /// DIEAbbrev - Dwarf abbreviation, describes the organization of a debug /// information object. class DIEAbbrev : public FoldingSetNode { + /// Unique number for node. + /// + unsigned Number; + /// Tag - Dwarf tag code. /// dwarf::Tag Tag; - /// ChildrenFlag - Dwarf children flag. + /// Children - Whether or not this node has children. /// - uint16_t ChildrenFlag; - - /// Unique number for node. - /// - unsigned Number; + // This cheats a bit in all of the uses since the values in the standard + // are 0 and 1 for no children and children respectively. + bool Children; /// Data - Raw data bytes for abbreviation. /// SmallVector Data; public: - DIEAbbrev(dwarf::Tag T, uint16_t C) : Tag(T), ChildrenFlag(C), Data() {} + DIEAbbrev(dwarf::Tag T, bool C) : Tag(T), Children(C), Data() {} // Accessors. dwarf::Tag getTag() const { return Tag; } unsigned getNumber() const { return Number; } - uint16_t getChildrenFlag() const { return ChildrenFlag; } + bool hasChildren() const { return Children; } const SmallVectorImpl &getData() const { return Data; } - void setChildrenFlag(uint16_t CF) { ChildrenFlag = CF; } + void setChildrenFlag(bool hasChild) { Children = hasChild; } void setNumber(unsigned N) { Number = N; } /// AddAttribute - Adds another set of attribute information to the diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 91aa7639ad3..df686581b26 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1892,8 +1892,7 @@ unsigned DwarfFile::computeSizeAndOffset(DIE *Die, unsigned Offset) { // Size the DIE children if any. if (!Children.empty()) { - assert(Abbrev.getChildrenFlag() == dwarf::DW_CHILDREN_yes && - "Children flag not set"); + assert(Abbrev.hasChildren() && "Children flag not set"); for (unsigned j = 0, M = Children.size(); j < M; ++j) Offset = computeSizeAndOffset(Children[j], Offset); @@ -2060,7 +2059,7 @@ void DwarfDebug::emitDIE(DIE *Die) { } // Emit the DIE children if any. - if (Abbrev.getChildrenFlag() == dwarf::DW_CHILDREN_yes) { + if (Abbrev.hasChildren()) { const std::vector &Children = Die->getChildren(); for (unsigned j = 0, M = Children.size(); j < M; ++j)