LCOV - code coverage report
Current view: top level - gcc/go - go-sha1.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 13 13
Test Date: 2024-12-21 13:15:12 Functions: 100.0 % 6 6
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* go-sha1.cc -- Go frontend interface to gcc backend.
       2                 :             :    Copyright (C) 2016-2024 Free Software Foundation, Inc.
       3                 :             : 
       4                 :             : This file is part of GCC.
       5                 :             : 
       6                 :             : GCC is free software; you can redistribute it and/or modify it under
       7                 :             : the terms of the GNU General Public License as published by the Free
       8                 :             : Software Foundation; either version 3, or (at your option) any later
       9                 :             : version.
      10                 :             : 
      11                 :             : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      12                 :             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13                 :             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14                 :             : for more details.
      15                 :             : 
      16                 :             : You should have received a copy of the GNU General Public License
      17                 :             : along with GCC; see the file COPYING3.  If not see
      18                 :             : <http://www.gnu.org/licenses/>.  */
      19                 :             : 
      20                 :             : #include "go-sha1.h"
      21                 :             : #include "sha1.h"
      22                 :             : 
      23                 :             : class Gcc_sha1_helper : public Go_sha1_helper
      24                 :             : {
      25                 :             :  public:
      26                 :             : 
      27                 :        8580 :   Gcc_sha1_helper() : ctx_(new sha1_ctx) { sha1_init_ctx(this->ctx_); }
      28                 :             : 
      29                 :             :   ~Gcc_sha1_helper();
      30                 :             : 
      31                 :             :   // Incorporate 'len' bytes from 'buffer' into checksum.
      32                 :             :   void
      33                 :             :   process_bytes(const void* buffer, size_t len);
      34                 :             : 
      35                 :             :   // Finalize checksum and return in the form of a string.
      36                 :             :   std::string
      37                 :             :   finish();
      38                 :             : 
      39                 :             :  private:
      40                 :             :   sha1_ctx *ctx_;
      41                 :             : };
      42                 :             : 
      43                 :        8656 : Gcc_sha1_helper::~Gcc_sha1_helper()
      44                 :             : {
      45                 :        4328 :   delete ctx_;
      46                 :        8656 : }
      47                 :             : 
      48                 :             : void
      49                 :    16236922 : Gcc_sha1_helper::process_bytes(const void* buffer, size_t len)
      50                 :             : {
      51                 :    16236922 :   sha1_process_bytes(buffer, len, this->ctx_);
      52                 :    16236922 : }
      53                 :             : 
      54                 :             : std::string
      55                 :        4328 : Gcc_sha1_helper::finish()
      56                 :             : {
      57                 :             :   // Use a union to provide the required alignment.
      58                 :        4328 :   union
      59                 :             :   {
      60                 :             :     char checksum[checksum_len];
      61                 :             :     long align;
      62                 :             :   } u;
      63                 :        4328 :   sha1_finish_ctx(this->ctx_, u.checksum);
      64                 :        4328 :   return std::string(u.checksum, checksum_len);
      65                 :             : }
      66                 :             : 
      67                 :             : Go_sha1_helper*
      68                 :        8580 : go_create_sha1_helper()
      69                 :             : {
      70                 :        8580 :   return new Gcc_sha1_helper();
      71                 :             : }
        

Generated by: LCOV version 2.1-beta

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto,rust,m2 --enable-host-shared. GCC test suite is run with the built compiler.