Use a bool for whether or not an abbreviation has children rather than
authorEric Christopher <echristo@gmail.com>
Wed, 5 Mar 2014 01:44:58 +0000 (01:44 +0000)
committerEric Christopher <echristo@gmail.com>
Wed, 5 Mar 2014 01:44:58 +0000 (01:44 +0000)
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
lib/CodeGen/AsmPrinter/DIE.h
lib/CodeGen/AsmPrinter/DwarfDebug.cpp

index c989ce75abf1bd33fc552564c8ff963f97917f4d..e8be7ad626d6939f0b09b66eaf44d997c72cd97b 100644 (file)
@@ -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";
   }
index b04adf53deb8e2359182f8fb2d86798ff1c68642..c89000956715317ab6e033a2ff4daa6d07770395 100644 (file)
@@ -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
index 91aa7639ad3993c54a412ec065661fce3d540197..df686581b26f104e63199038cd4bd6cfee5cd349 100644 (file)
@@ -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<DIE *> &Children = Die->getChildren();
 
     for (unsigned j = 0, M = Children.size(); j < M; ++j)