LCOV - code coverage report
Current view: top level - gcc - diagnostic-spec.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 8 8
Test Date: 2024-04-20 14:03:02 Functions: - 0 0
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Language-independent APIs to enable/disable per-location warnings.
       2                 :             : 
       3                 :             :    Copyright (C) 2021-2024 Free Software Foundation, Inc.
       4                 :             :    Contributed by Martin Sebor <msebor@redhat.com>
       5                 :             : 
       6                 :             :    This file is part of GCC.
       7                 :             : 
       8                 :             :    GCC is free software; you can redistribute it and/or modify it under
       9                 :             :    the terms of the GNU General Public License as published by the Free
      10                 :             :    Software Foundation; either version 3, or (at your option) any later
      11                 :             :    version.
      12                 :             : 
      13                 :             :    GCC is distributed in the hope that it will be useful, but WITHOUT ANY
      14                 :             :    WARRANTY; without even the implied warranty of MERCHANTABILITY or
      15                 :             :    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      16                 :             :    for more details.
      17                 :             : 
      18                 :             :    You should have received a copy of the GNU General Public License
      19                 :             :    along with GCC; see the file COPYING3.  If not see
      20                 :             :    <http://www.gnu.org/licenses/>.  */
      21                 :             : 
      22                 :             : #ifndef DIAGNOSTIC_SPEC_H_INCLUDED
      23                 :             : #define DIAGNOSTIC_SPEC_H_INCLUDED
      24                 :             : 
      25                 :             : #include "hash-map.h"
      26                 :             : 
      27                 :             : /* A "bitset" of warning groups.  */
      28                 :             : 
      29                 :             : class nowarn_spec_t
      30                 :             : {
      31                 :             : public:
      32                 :             :   enum
      33                 :             :     {
      34                 :             :      /* Middle end warnings about invalid accesses.  */
      35                 :             :      NW_ACCESS = 1 << 0,
      36                 :             :      /* Front end/lexical warnings.  */
      37                 :             :      NW_LEXICAL = 1 << 1,
      38                 :             :      /* Warnings about null pointers.  */
      39                 :             :      NW_NONNULL = 1 << 2,
      40                 :             :      /* Warnings about uninitialized reads.  */
      41                 :             :      NW_UNINIT = 1 << 3,
      42                 :             :      /* Warnings about arithmetic overflow.  */
      43                 :             :      NW_VFLOW = 1 << 4,
      44                 :             :      /* Warnings about dangling pointers.  */
      45                 :             :      NW_DANGLING = 1 << 5,
      46                 :             :      /* All other unclassified warnings.  */
      47                 :             :      NW_OTHER = 1 << 6,
      48                 :             :      /* Warnings about redundant calls.  */
      49                 :             :      NW_REDUNDANT = 1 << 7,
      50                 :             :      /* All groups of warnings.  */
      51                 :             :      NW_ALL = (NW_ACCESS | NW_LEXICAL | NW_NONNULL
      52                 :             :                | NW_UNINIT | NW_VFLOW | NW_DANGLING | NW_REDUNDANT | NW_OTHER)
      53                 :             :    };
      54                 :             : 
      55                 :             :   nowarn_spec_t (): m_bits () { }
      56                 :             : 
      57                 :             :   nowarn_spec_t (opt_code);
      58                 :             : 
      59                 :             :   /* Return the raw bitset.  */
      60                 :             :   operator unsigned() const
      61                 :             :   {
      62                 :             :     return m_bits;
      63                 :             :   }
      64                 :             : 
      65                 :             :   /* Return true if the bitset is clear.  */
      66                 :             :   bool operator!() const
      67                 :             :   {
      68                 :             :     return !m_bits;
      69                 :             :   }
      70                 :             : 
      71                 :             :   /* Return the inverse of the bitset.  */
      72                 :             :   nowarn_spec_t operator~() const
      73                 :             :   {
      74                 :             :     nowarn_spec_t res (*this);
      75                 :             :     res.m_bits &= ~NW_ALL;
      76                 :             :     return res;
      77                 :             :   }
      78                 :             : 
      79                 :             :   /* Set *THIS to the bitwise OR of *THIS and RHS.  */
      80                 :    68030894 :   nowarn_spec_t& operator|= (const nowarn_spec_t &rhs)
      81                 :             :   {
      82                 :    68030894 :     m_bits |= rhs.m_bits;
      83                 :    68030894 :     return *this;
      84                 :             :   }
      85                 :             : 
      86                 :             :   /* Set *THIS to the bitwise AND of *THIS and RHS.  */
      87                 :   110997600 :   nowarn_spec_t& operator&= (const nowarn_spec_t &rhs)
      88                 :             :   {
      89                 :   110997600 :     m_bits &= rhs.m_bits;
      90                 :   110997600 :     return *this;
      91                 :             :   }
      92                 :             : 
      93                 :             :   /* Set *THIS to the bitwise exclusive OR of *THIS and RHS.  */
      94                 :             :   nowarn_spec_t& operator^= (const nowarn_spec_t &rhs)
      95                 :             :   {
      96                 :             :     m_bits ^= rhs.m_bits;
      97                 :             :     return *this;
      98                 :             :   }
      99                 :             : 
     100                 :             : private:
     101                 :             :   /* Bitset of warning groups.  */
     102                 :             :   unsigned m_bits;
     103                 :             : };
     104                 :             : 
     105                 :             : /* Return the bitwise OR of LHS and RHS.  */
     106                 :             : 
     107                 :             : inline nowarn_spec_t
     108                 :             : operator| (const nowarn_spec_t &lhs, const nowarn_spec_t &rhs)
     109                 :             : {
     110                 :             :   return nowarn_spec_t (lhs) |= rhs;
     111                 :             : }
     112                 :             : 
     113                 :             : /* Return the bitwise AND of LHS and RHS.  */
     114                 :             : 
     115                 :             : inline nowarn_spec_t
     116                 :   110994596 : operator& (const nowarn_spec_t &lhs, const nowarn_spec_t &rhs)
     117                 :             : {
     118                 :   110994596 :   return nowarn_spec_t (lhs) &= rhs;
     119                 :             : }
     120                 :             : 
     121                 :             : /* Return true if LHS is equal RHS.  */
     122                 :             : 
     123                 :             : inline bool
     124                 :             : operator== (const nowarn_spec_t &lhs, const nowarn_spec_t &rhs)
     125                 :             : {
     126                 :             :   return static_cast<unsigned>(lhs) == static_cast<unsigned>(rhs);
     127                 :             : }
     128                 :             : 
     129                 :             : /* Return true if LHS is not equal RHS.  */
     130                 :             : 
     131                 :             : inline bool
     132                 :             : operator!= (const nowarn_spec_t &lhs, const nowarn_spec_t &rhs)
     133                 :             : {
     134                 :             :   return !(lhs == rhs);
     135                 :             : }
     136                 :             : 
     137                 :             : typedef hash_map<location_hash, nowarn_spec_t> nowarn_map_t;
     138                 :             : 
     139                 :             : /* A mapping from a 'location_t' to the warning spec set for it.  */
     140                 :             : extern GTY(()) nowarn_map_t *nowarn_map;
     141                 :             : 
     142                 :             : #endif // DIAGNOSTIC_SPEC_H_INCLUDED
        

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.