[llvm] r202921 - Use a bool for whether or not an abbreviation has children rather than
Eric Christopher
echristo at gmail.com
Tue Mar 4 17:44:59 PST 2014
Author: echristo
Date: Tue Mar 4 19:44:58 2014
New Revision: 202921
URL: http://llvm.org/viewvc/llvm-project?rev=202921&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=202921&r1=202920&r2=202921&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Tue Mar 4 19:44:58 2014
@@ -49,7 +49,7 @@ void DIEAbbrevData::Profile(FoldingSetNo
///
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) con
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
O << Indent
<< dwarf::TagString(Abbrev.getTag())
<< " "
- << dwarf::ChildrenString(Abbrev.getChildrenFlag()) << "\n";
+ << dwarf::ChildrenString(Abbrev.hasChildren()) << "\n";
} else {
O << "Size: " << Size << "\n";
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h?rev=202921&r1=202920&r2=202921&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h Tue Mar 4 19:44:58 2014
@@ -56,31 +56,33 @@ public:
/// DIEAbbrev - Dwarf abbreviation, describes the organization of a debug
/// information object.
class DIEAbbrev : public FoldingSetNode {
- /// Tag - Dwarf tag code.
+ /// Unique number for node.
///
- dwarf::Tag Tag;
+ unsigned Number;
- /// ChildrenFlag - Dwarf children flag.
+ /// Tag - Dwarf tag code.
///
- uint16_t ChildrenFlag;
+ dwarf::Tag Tag;
- /// Unique number for node.
+ /// Children - Whether or not this node has children.
///
- 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<DIEAbbrevData, 12> 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<DIEAbbrevData> &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
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=202921&r1=202920&r2=202921&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Mar 4 19:44:58 2014
@@ -1892,8 +1892,7 @@ unsigned DwarfFile::computeSizeAndOffset
// 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<DIE *> &Children = Die->getChildren();
for (unsigned j = 0, M = Children.size(); j < M; ++j)
More information about the llvm-commits
mailing list