LCOV - code coverage report
Current view: top level - include/llvm/Support - raw_sha1_ostream.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 8 9 88.9 %
Date: 2018-10-20 13:21:21 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //==- raw_sha1_ostream.h - raw_ostream that compute SHA1        --*- 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             : //  This file defines the raw_sha1_ostream class.
      11             : //
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #ifndef LLVM_SUPPORT_RAW_SHA1_OSTREAM_H
      15             : #define LLVM_SUPPORT_RAW_SHA1_OSTREAM_H
      16             : 
      17             : #include "llvm/ADT/ArrayRef.h"
      18             : #include "llvm/Support/SHA1.h"
      19             : #include "llvm/Support/raw_ostream.h"
      20             : 
      21             : namespace llvm {
      22             : 
      23             : /// A raw_ostream that hash the content using the sha1 algorithm.
      24           8 : class raw_sha1_ostream : public raw_ostream {
      25             :   SHA1 State;
      26             : 
      27             :   /// See raw_ostream::write_impl.
      28           6 :   void write_impl(const char *Ptr, size_t Size) override {
      29          12 :     State.update(ArrayRef<uint8_t>((const uint8_t *)Ptr, Size));
      30           6 :   }
      31             : 
      32             : public:
      33             :   /// Return the current SHA1 hash for the content of the stream
      34           6 :   StringRef sha1() {
      35           6 :     flush();
      36           6 :     return State.result();
      37             :   }
      38             : 
      39             :   /// Reset the internal state to start over from scratch.
      40           1 :   void resetHash() { State.init(); }
      41             : 
      42           0 :   uint64_t current_pos() const override { return 0; }
      43             : };
      44             : 
      45             : } // end llvm namespace
      46             : 
      47             : #endif

Generated by: LCOV version 1.13