LCOV - code coverage report
Current view: top level - include/llvm/DebugInfo/CodeView - DebugStringTableSubsection.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 3 3 100.0 %
Date: 2018-10-20 13:21:21 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- DebugStringTableSubsection.h - CodeView String Table -----*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #ifndef LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H
      11             : #define LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H
      12             : 
      13             : #include "llvm/ADT/DenseMap.h"
      14             : #include "llvm/ADT/StringMap.h"
      15             : #include "llvm/ADT/StringRef.h"
      16             : #include "llvm/DebugInfo/CodeView/CodeView.h"
      17             : #include "llvm/DebugInfo/CodeView/DebugSubsection.h"
      18             : #include "llvm/Support/BinaryStreamRef.h"
      19             : #include "llvm/Support/Error.h"
      20             : #include <cstdint>
      21             : 
      22             : namespace llvm {
      23             : 
      24             : class BinaryStreamReader;
      25             : 
      26             : namespace codeview {
      27             : 
      28             : /// Represents a read-only view of a CodeView string table.  This is a very
      29             : /// simple flat buffer consisting of null-terminated strings, where strings
      30             : /// are retrieved by their offset in the buffer.  DebugStringTableSubsectionRef
      31             : /// does not own the underlying storage for the buffer.
      32          33 : class DebugStringTableSubsectionRef : public DebugSubsectionRef {
      33             : public:
      34             :   DebugStringTableSubsectionRef();
      35             : 
      36             :   static bool classof(const DebugSubsectionRef *S) {
      37             :     return S->kind() == DebugSubsectionKind::StringTable;
      38             :   }
      39             : 
      40             :   Error initialize(BinaryStreamRef Contents);
      41             :   Error initialize(BinaryStreamReader &Reader);
      42             : 
      43             :   Expected<StringRef> getString(uint32_t Offset) const;
      44             : 
      45         582 :   bool valid() const { return Stream.valid(); }
      46             : 
      47             :   BinaryStreamRef getBuffer() const { return Stream; }
      48             : 
      49             : private:
      50             :   BinaryStreamRef Stream;
      51             : };
      52             : 
      53             : /// Represents a read-write view of a CodeView string table.
      54             : /// DebugStringTableSubsection owns the underlying storage for the table, and is
      55             : /// capable of serializing the string table into a format understood by
      56             : /// DebugStringTableSubsectionRef.
      57             : class DebugStringTableSubsection : public DebugSubsection {
      58             : public:
      59             :   DebugStringTableSubsection();
      60             : 
      61             :   static bool classof(const DebugSubsection *S) {
      62             :     return S->kind() == DebugSubsectionKind::StringTable;
      63             :   }
      64             : 
      65             :   // If string S does not exist in the string table, insert it.
      66             :   // Returns the ID for S.
      67             :   uint32_t insert(StringRef S);
      68             : 
      69             :   // Return the ID for string S.  Assumes S exists in the table.
      70             :   uint32_t getIdForString(StringRef S) const;
      71             : 
      72             :   StringRef getStringForId(uint32_t Id) const;
      73             : 
      74             :   uint32_t calculateSerializedSize() const override;
      75             :   Error commit(BinaryStreamWriter &Writer) const override;
      76             : 
      77             :   uint32_t size() const;
      78             : 
      79             :   StringMap<uint32_t>::const_iterator begin() const {
      80         220 :     return StringToId.begin();
      81             :   }
      82             : 
      83             :   StringMap<uint32_t>::const_iterator end() const { return StringToId.end(); }
      84             : 
      85             :   std::vector<uint32_t> sortedIds() const;
      86             : 
      87             : private:
      88             :   DenseMap<uint32_t, StringRef> IdToString;
      89             :   StringMap<uint32_t> StringToId;
      90             :   uint32_t StringSize = 1;
      91             : };
      92             : 
      93             : } // end namespace codeview
      94             : 
      95             : } // end namespace llvm
      96             : 
      97             : #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGSTRINGTABLESUBSECTION_H

Generated by: LCOV version 1.13