LCOV - code coverage report
Current view: top level - include/llvm/DebugInfo/CodeView - ModuleDebugFileChecksumFragment.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 6 6 100.0 %
Date: 2017-05-20 02:07:48 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- ModuleDebugFileChecksumFragment.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_MODULEDEBUGFILECHECKSUMFRAGMENT_H
      11             : #define LLVM_DEBUGINFO_CODEVIEW_MODULEDEBUGFILECHECKSUMFRAGMENT_H
      12             : 
      13             : #include "llvm/ADT/ArrayRef.h"
      14             : #include "llvm/ADT/DenseMap.h"
      15             : #include "llvm/DebugInfo/CodeView/ModuleDebugFragment.h"
      16             : #include "llvm/Support/Allocator.h"
      17             : #include "llvm/Support/BinaryStreamArray.h"
      18             : #include "llvm/Support/BinaryStreamReader.h"
      19             : #include "llvm/Support/Endian.h"
      20             : 
      21             : namespace llvm {
      22             : namespace codeview {
      23             : 
      24             : class StringTable;
      25             : 
      26         928 : struct FileChecksumEntry {
      27             :   uint32_t FileNameOffset;    // Byte offset of filename in global stringtable.
      28             :   FileChecksumKind Kind;      // The type of checksum.
      29             :   ArrayRef<uint8_t> Checksum; // The bytes of the checksum.
      30             : };
      31             : }
      32             : }
      33             : 
      34             : namespace llvm {
      35             : template <> struct VarStreamArrayExtractor<codeview::FileChecksumEntry> {
      36             : public:
      37             :   typedef void ContextType;
      38             : 
      39             :   static Error extract(BinaryStreamRef Stream, uint32_t &Len,
      40             :                        codeview::FileChecksumEntry &Item);
      41             : };
      42             : }
      43             : 
      44             : namespace llvm {
      45             : namespace codeview {
      46         156 : class ModuleDebugFileChecksumFragmentRef final : public ModuleDebugFragmentRef {
      47             :   typedef VarStreamArray<codeview::FileChecksumEntry> FileChecksumArray;
      48             :   typedef FileChecksumArray::Iterator Iterator;
      49             : 
      50             : public:
      51             :   ModuleDebugFileChecksumFragmentRef()
      52         204 :       : ModuleDebugFragmentRef(ModuleDebugFragmentKind::FileChecksums) {}
      53             : 
      54             :   static bool classof(const ModuleDebugFragmentRef *S) {
      55             :     return S->kind() == ModuleDebugFragmentKind::FileChecksums;
      56             :   }
      57             : 
      58             :   Error initialize(BinaryStreamReader Reader);
      59             : 
      60          68 :   Iterator begin() { return Checksums.begin(); }
      61         136 :   Iterator end() { return Checksums.end(); }
      62             : 
      63             :   const FileChecksumArray &getArray() const { return Checksums; }
      64             : 
      65             : private:
      66             :   FileChecksumArray Checksums;
      67             : };
      68             : 
      69           4 : class ModuleDebugFileChecksumFragment final : public ModuleDebugFragment {
      70             : public:
      71             :   explicit ModuleDebugFileChecksumFragment(StringTable &Strings);
      72             : 
      73             :   static bool classof(const ModuleDebugFragment *S) {
      74             :     return S->kind() == ModuleDebugFragmentKind::FileChecksums;
      75             :   }
      76             : 
      77             :   void addChecksum(StringRef FileName, FileChecksumKind Kind,
      78             :                    ArrayRef<uint8_t> Bytes);
      79             : 
      80             :   uint32_t calculateSerializedLength() override;
      81             :   Error commit(BinaryStreamWriter &Writer) override;
      82             :   uint32_t mapChecksumOffset(StringRef FileName) const;
      83             : 
      84             : private:
      85             :   StringTable &Strings;
      86             : 
      87             :   DenseMap<uint32_t, uint32_t> OffsetMap;
      88             :   uint32_t SerializedSize = 0;
      89             :   llvm::BumpPtrAllocator Storage;
      90             :   std::vector<FileChecksumEntry> Checksums;
      91             : };
      92             : }
      93             : }
      94             : 
      95             : #endif

Generated by: LCOV version 1.13