[Lldb-commits] [lldb] r369827 - [NFC] Fix comments and formatting.

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 23 16:56:19 PDT 2019


Author: jdevlieghere
Date: Fri Aug 23 16:56:19 2019
New Revision: 369827

URL: http://llvm.org/viewvc/llvm-project?rev=369827&view=rev
Log:
[NFC] Fix comments and formatting.

Modified:
    lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp?rev=369827&r1=369826&r2=369827&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp Fri Aug 23 16:56:19 2019
@@ -125,7 +125,7 @@ DWARFMappedHash::Prologue::Prologue(dw_o
     : die_base_offset(_die_base_offset), atoms(), atom_mask(0),
       min_hash_data_byte_size(0), hash_data_has_fixed_byte_size(true) {
   // Define an array of DIE offsets by first defining an array, and then define
-  // the atom type for the array, in this case we have an array of DIE offsets
+  // the atom type for the array, in this case we have an array of DIE offsets.
   AppendAtom(eAtomTypeDIEOffset, DW_FORM_data4);
 }
 
@@ -208,9 +208,10 @@ DWARFMappedHash::Prologue::Read(const ll
 
   const uint32_t atom_count = data.GetU32(&offset);
   if (atom_count == 0x00060003u) {
-    // Old format, deal with contents of old pre-release format
-    while (data.GetU32(&offset))
+    // Old format, deal with contents of old pre-release format.
+    while (data.GetU32(&offset)) {
       /* do nothing */;
+    }
 
     // Hardcode to the only known value for now.
     AppendAtom(eAtomTypeDIEOffset, DW_FORM_data4);
@@ -226,7 +227,7 @@ DWARFMappedHash::Prologue::Read(const ll
 
 size_t DWARFMappedHash::Prologue::GetByteSize() const {
   // Add an extra count to the atoms size for the zero termination Atom that
-  // gets written to disk
+  // gets written to disk.
   return sizeof(die_base_offset) + sizeof(uint32_t) +
          atoms.size() * sizeof(Atom);
 }
@@ -286,7 +287,7 @@ bool DWARFMappedHash::Header::Read(const
       break;
 
     default:
-      // We can always skip atoms we don't know about
+      // We can always skip atoms we don't know about.
       break;
     }
   }
@@ -308,8 +309,8 @@ DWARFMappedHash::MemoryTable::GetStringF
 bool DWARFMappedHash::MemoryTable::ReadHashData(uint32_t hash_data_offset,
                                                 HashData &hash_data) const {
   lldb::offset_t offset = hash_data_offset;
-  offset += 4; // Skip string table offset that contains offset of hash name in
-               // .debug_str
+  // Skip string table offset that contains offset of hash name in .debug_str.
+  offset += 4;
   const uint32_t count = m_data.GetU32(&offset);
   if (count > 0) {
     hash_data.resize(count);
@@ -335,7 +336,7 @@ DWARFMappedHash::MemoryTable::GetHashDat
     return eResultEndOfHashData;
 
   // There definitely should be a string for this string offset, if there
-  // isn't, there is something wrong, return and error
+  // isn't, there is something wrong, return and error.
   const char *strp_cstr = m_string_table.PeekCStr(pair.key);
   if (strp_cstr == nullptr) {
     *hash_data_offset_ptr = UINT32_MAX;
@@ -345,9 +346,8 @@ DWARFMappedHash::MemoryTable::GetHashDat
   const uint32_t count = m_data.GetU32(hash_data_offset_ptr);
   const size_t min_total_hash_data_size =
       count * m_header.header_data.GetMinimumHashDataByteSize();
-  if (count > 0 &&
-      m_data.ValidOffsetForDataOfSize(*hash_data_offset_ptr,
-                                      min_total_hash_data_size)) {
+  if (count > 0 && m_data.ValidOffsetForDataOfSize(*hash_data_offset_ptr,
+                                                   min_total_hash_data_size)) {
     // We have at least one HashData entry, and we have enough data to parse at
     // least "count" HashData entries.
 
@@ -370,21 +370,22 @@ DWARFMappedHash::MemoryTable::GetHashDat
           if (match)
             pair.value.push_back(die_info);
         } else {
-          // Something went wrong while reading the data
+          // Something went wrong while reading the data.
           *hash_data_offset_ptr = UINT32_MAX;
           return eResultError;
         }
       }
     }
     // Return the correct response depending on if the string matched or not...
-    if (match)
-      return eResultKeyMatch; // The key (cstring) matches and we have lookup
-                              // results!
-    else
-      return eResultKeyMismatch; // The key doesn't match, this function will
-                                 // get called
-    // again for the next key/value or the key terminator which in our case is
-    // a zero .debug_str offset.
+    if (match) {
+      // The key (cstring) matches and we have lookup results!
+      return eResultKeyMatch;
+    } else {
+      // The key doesn't match, this function will get called again for the
+      // next key/value or the key terminator which in our case is a zero
+      // .debug_str offset.
+      return eResultKeyMismatch;
+    }
   } else {
     *hash_data_offset_ptr = UINT32_MAX;
     return eResultError;
@@ -402,7 +403,7 @@ DWARFMappedHash::MemoryTable::AppendHash
     return eResultEndOfHashData;
 
   // There definitely should be a string for this string offset, if there
-  // isn't, there is something wrong, return and error
+  // isn't, there is something wrong, return and error.
   const char *strp_cstr = m_string_table.PeekCStr(pair.key);
   if (strp_cstr == nullptr)
     return eResultError;
@@ -410,9 +411,8 @@ DWARFMappedHash::MemoryTable::AppendHash
   const uint32_t count = m_data.GetU32(hash_data_offset_ptr);
   const size_t min_total_hash_data_size =
       count * m_header.header_data.GetMinimumHashDataByteSize();
-  if (count > 0 &&
-      m_data.ValidOffsetForDataOfSize(*hash_data_offset_ptr,
-                                      min_total_hash_data_size)) {
+  if (count > 0 && m_data.ValidOffsetForDataOfSize(*hash_data_offset_ptr,
+                                                   min_total_hash_data_size)) {
     const bool match = regex.Execute(llvm::StringRef(strp_cstr));
 
     if (!match && m_header.header_data.HashDataHasFixedByteSize()) {
@@ -438,14 +438,15 @@ DWARFMappedHash::MemoryTable::AppendHash
       }
     }
     // Return the correct response depending on if the string matched or not...
-    if (match)
-      return eResultKeyMatch; // The key (cstring) matches and we have lookup
-                              // results!
-    else
-      return eResultKeyMismatch; // The key doesn't match, this function will
-                                 // get called
-    // again for the next key/value or the key terminator which in our case is
-    // a zero .debug_str offset.
+    if (match) {
+      // The key (cstring) matches and we have lookup results!
+      return eResultKeyMatch;
+    } else {
+      // The key doesn't match, this function will get called again for the
+      // next key/value or the key terminator which in our case is a zero
+      // .debug_str offset.
+      return eResultKeyMismatch;
+    }
   } else {
     *hash_data_offset_ptr = UINT32_MAX;
     return eResultError;
@@ -466,7 +467,7 @@ size_t DWARFMappedHash::MemoryTable::App
       if (prev_hash_data_offset == hash_data_offset)
         break;
 
-      // Check the result of getting our hash data
+      // Check the result of getting our hash data.
       switch (hash_result) {
       case eResultKeyMatch:
       case eResultKeyMismatch:

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h?rev=369827&r1=369826&r2=369827&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h Fri Aug 23 16:56:19 2019
@@ -24,26 +24,30 @@ class DWARFMappedHash {
 public:
   enum AtomType : uint16_t {
     eAtomTypeNULL = 0u,
-    eAtomTypeDIEOffset = 1u, // DIE offset, check form for encoding
-    eAtomTypeCUOffset = 2u,  // DIE offset of the compiler unit header that
-                             // contains the item in question
-    eAtomTypeTag = 3u, // DW_TAG_xxx value, should be encoded as DW_FORM_data1
-                       // (if no tags exceed 255) or DW_FORM_data2
-    eAtomTypeNameFlags = 4u,   // Flags from enum NameFlags
-    eAtomTypeTypeFlags = 5u,   // Flags from enum TypeFlags,
-    eAtomTypeQualNameHash = 6u // A 32 bit hash of the full qualified name
-                               // (since all hash entries are basename only)
-    // For example a type like "std::vector<int>::iterator" would have a name of
-    // "iterator"
-    // and a 32 bit hash for "std::vector<int>::iterator" to allow us to not
-    // have to pull
-    // in debug info for a type when we know the fully qualified name.
+    /// DIE offset, check form for encoding.
+    eAtomTypeDIEOffset = 1u,
+    /// DIE offset of the compiler unit header that contains the item in
+    /// question.
+    eAtomTypeCUOffset = 2u,
+    /// DW_TAG_xxx value, should be encoded as DW_FORM_data1 (if no tags exceed
+    /// 255) or DW_FORM_data2.
+    eAtomTypeTag = 3u,
+    // Flags from enum NameFlags.
+    eAtomTypeNameFlags = 4u,
+    // Flags from enum TypeFlags.
+    eAtomTypeTypeFlags = 5u,
+    /// A 32 bit hash of the full qualified name (since all hash entries are
+    /// basename only) For example a type like "std::vector<int>::iterator"
+    /// would have a name of "iterator" and a 32 bit hash for
+    /// "std::vector<int>::iterator" to allow us to not have to pull in debug
+    /// info for a type when we know the fully qualified name.
+    eAtomTypeQualNameHash = 6u
   };
 
-  // Bit definitions for the eAtomTypeTypeFlags flags
+  /// Bit definitions for the eAtomTypeTypeFlags flags.
   enum TypeFlags {
-    // Always set for C++, only set for ObjC if this is the
-    // @implementation for class
+    /// Always set for C++, only set for ObjC if this is the
+    /// @implementation for class.
     eTypeFlagClassIsImplementation = (1u << 1)
   };
 
@@ -51,10 +55,10 @@ public:
     dw_offset_t die_offset = DW_INVALID_OFFSET;
     dw_tag_t tag = 0;
 
-    /// Any flags for this DIEInfo
+    /// Any flags for this DIEInfo.
     uint32_t type_flags = 0;
 
-    /// A 32 bit hash of the fully qualified name
+    /// A 32 bit hash of the fully qualified name.
     uint32_t qualified_name_hash = 0;
 
     DIEInfo() = default;
@@ -94,7 +98,7 @@ public:
 
     bool HashDataHasFixedByteSize() const;
 
-    // DIE offset base so die offsets in hash_data can be CU relative
+    /// DIE offset base so die offsets in hash_data can be CU relative.
     dw_offset_t die_base_offset;
     AtomArray atoms;
     uint32_t atom_mask;
@@ -113,8 +117,8 @@ public:
               lldb::offset_t *offset_ptr, DIEInfo &hash_data) const;
   };
 
-  // A class for reading and using a saved hash table from a block of data
-  // in memory
+  /// A class for reading and using a saved hash table from a block of data in
+  /// memory.
   class MemoryTable
       : public MappedHash::MemoryTable<uint32_t, DWARFMappedHash::Header,
                                        DIEInfoArray> {




More information about the lldb-commits mailing list