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

          Line data    Source code
       1             : //===- DebugChecksumsSubsection.h -------------------------------*- 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_DEBUGCHECKSUMSSUBSECTION_H
      11             : #define LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H
      12             : 
      13             : #include "llvm/ADT/ArrayRef.h"
      14             : #include "llvm/ADT/DenseMap.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/Allocator.h"
      19             : #include "llvm/Support/BinaryStreamArray.h"
      20             : #include "llvm/Support/BinaryStreamReader.h"
      21             : #include "llvm/Support/BinaryStreamRef.h"
      22             : #include "llvm/Support/Error.h"
      23             : #include <cstdint>
      24             : #include <vector>
      25             : 
      26             : namespace llvm {
      27             : 
      28             : namespace codeview {
      29             : 
      30             : class DebugStringTableSubsection;
      31             : 
      32             : struct FileChecksumEntry {
      33             :   uint32_t FileNameOffset;    // Byte offset of filename in global stringtable.
      34             :   FileChecksumKind Kind;      // The type of checksum.
      35             :   ArrayRef<uint8_t> Checksum; // The bytes of the checksum.
      36             : };
      37             : 
      38             : } // end namespace codeview
      39             : 
      40             : template <> struct VarStreamArrayExtractor<codeview::FileChecksumEntry> {
      41             : public:
      42             :   using ContextType = void;
      43             : 
      44             :   Error operator()(BinaryStreamRef Stream, uint32_t &Len,
      45             :                    codeview::FileChecksumEntry &Item);
      46             : };
      47             : 
      48             : namespace codeview {
      49             : 
      50          10 : class DebugChecksumsSubsectionRef final : public DebugSubsectionRef {
      51             :   using FileChecksumArray = VarStreamArray<codeview::FileChecksumEntry>;
      52             :   using Iterator = FileChecksumArray::Iterator;
      53             : 
      54             : public:
      55             :   DebugChecksumsSubsectionRef()
      56        1856 :       : DebugSubsectionRef(DebugSubsectionKind::FileChecksums) {}
      57             : 
      58             :   static bool classof(const DebugSubsectionRef *S) {
      59             :     return S->kind() == DebugSubsectionKind::FileChecksums;
      60             :   }
      61             : 
      62             :   bool valid() const { return Checksums.valid(); }
      63             : 
      64             :   Error initialize(BinaryStreamReader Reader);
      65             :   Error initialize(BinaryStreamRef Stream);
      66             : 
      67         239 :   Iterator begin() const { return Checksums.begin(); }
      68           0 :   Iterator end() const { return Checksums.end(); }
      69             : 
      70         249 :   const FileChecksumArray &getArray() const { return Checksums; }
      71             : 
      72             : private:
      73             :   FileChecksumArray Checksums;
      74             : };
      75             : 
      76          58 : class DebugChecksumsSubsection final : public DebugSubsection {
      77             : public:
      78             :   explicit DebugChecksumsSubsection(DebugStringTableSubsection &Strings);
      79             : 
      80             :   static bool classof(const DebugSubsection *S) {
      81             :     return S->kind() == DebugSubsectionKind::FileChecksums;
      82             :   }
      83             : 
      84             :   void addChecksum(StringRef FileName, FileChecksumKind Kind,
      85             :                    ArrayRef<uint8_t> Bytes);
      86             : 
      87             :   uint32_t calculateSerializedSize() const override;
      88             :   Error commit(BinaryStreamWriter &Writer) const override;
      89             :   uint32_t mapChecksumOffset(StringRef FileName) const;
      90             : 
      91             : private:
      92             :   DebugStringTableSubsection &Strings;
      93             : 
      94             :   DenseMap<uint32_t, uint32_t> OffsetMap;
      95             :   uint32_t SerializedSize = 0;
      96             :   BumpPtrAllocator Storage;
      97             :   std::vector<FileChecksumEntry> Checksums;
      98             : };
      99             : 
     100             : } // end namespace codeview
     101             : 
     102             : } // end namespace llvm
     103             : 
     104             : #endif // LLVM_DEBUGINFO_CODEVIEW_DEBUGCHECKSUMSSUBSECTION_H

Generated by: LCOV version 1.13