LCOV - code coverage report
Current view: top level - gcc/diagnostics - option-classifier.h (source / functions) Coverage Total Hit
Test: gcc.info Lines: 100.0 % 5 5
Test Date: 2025-09-20 13:40:47 Functions: 100.0 % 1 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* Stacks of set of classifications of diagnostics.
       2                 :             :    Copyright (C) 2000-2025 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                 :             : #ifndef GCC_DIAGNOSTICS_OPTION_CLASSIFIER_H
      21                 :             : #define GCC_DIAGNOSTICS_OPTION_CLASSIFIER_H
      22                 :             : 
      23                 :             : #include "diagnostics/option-id.h"
      24                 :             : #include "diagnostics/kinds.h"
      25                 :             : 
      26                 :             : namespace diagnostics {
      27                 :             : 
      28                 :             : /*  Forward declarations.  */
      29                 :             : class context;
      30                 :             : struct diagnostic_info;
      31                 :             : 
      32                 :             : /* A stack of sets of classifications: each entry in the stack is
      33                 :             :    a mapping from option index to diagnostic severity that can be changed
      34                 :             :    via pragmas.  The stack can be pushed and popped.  */
      35                 :             : 
      36                 :             : class option_classifier
      37                 :             : {
      38                 :             : public:
      39                 :             :   void init (int n_opts);
      40                 :             :   void fini ();
      41                 :             : 
      42                 :             :   /* Save all diagnostic classifications in a stack.  */
      43                 :             :   void push ();
      44                 :             : 
      45                 :             :   /* Restore the topmost classification set off the stack.  If the stack
      46                 :             :      is empty, revert to the state based on command line parameters.  */
      47                 :             :   void pop (location_t where);
      48                 :             : 
      49                 :     1075077 :   bool option_unspecified_p (option_id opt_id) const
      50                 :             :   {
      51                 :     1075077 :     return get_current_override (opt_id) == kind::unspecified;
      52                 :             :   }
      53                 :             : 
      54                 :     1083795 :   enum kind get_current_override (option_id opt_id) const
      55                 :             :   {
      56                 :     1083795 :     gcc_assert (opt_id.m_idx < m_n_opts);
      57                 :     1083795 :     return m_classify_diagnostic[opt_id.m_idx];
      58                 :             :   }
      59                 :             : 
      60                 :             :   enum kind
      61                 :             :   classify_diagnostic (const context *context,
      62                 :             :                        option_id opt_id,
      63                 :             :                        enum kind new_kind,
      64                 :             :                        location_t where);
      65                 :             : 
      66                 :             :   enum kind
      67                 :             :   update_effective_level_from_pragmas (diagnostic_info *diagnostic) const;
      68                 :             : 
      69                 :             :   int pch_save (FILE *);
      70                 :             :   int pch_restore (FILE *);
      71                 :             : 
      72                 :             : private:
      73                 :             :   /* Each time a diagnostic's classification is changed with a pragma,
      74                 :             :      we record the change and the location of the change in an array of
      75                 :             :      these structs.  */
      76                 :             :   struct classification_change_t
      77                 :             :   {
      78                 :             :     location_t location;
      79                 :             : 
      80                 :             :     /* For kind::pop, this is the index of the corresponding push (as stored
      81                 :             :        in m_push_list).
      82                 :             :        Otherwise, this is an option index.  */
      83                 :             :     int option;
      84                 :             : 
      85                 :             :     enum kind kind;
      86                 :             :   };
      87                 :             : 
      88                 :             :   int m_n_opts;
      89                 :             : 
      90                 :             :   /* For each option index that can be passed to warning() et al
      91                 :             :      (OPT_* from options.h when using this code with the core GCC
      92                 :             :      options), this array may contain a new kind that the diagnostic
      93                 :             :      should be changed to before reporting, or kind::unspecified to leave
      94                 :             :      it as the reported kind, or kind::ignored to not report it at
      95                 :             :      all.  */
      96                 :             :   enum kind *m_classify_diagnostic;
      97                 :             : 
      98                 :             :   /* History of all changes to the classifications above.  This list
      99                 :             :      is stored in location-order, so we can search it, either
     100                 :             :      binary-wise or end-to-front, to find the most recent
     101                 :             :      classification for a given diagnostic, given the location of the
     102                 :             :      diagnostic.  */
     103                 :             :   vec<classification_change_t> m_classification_history;
     104                 :             : 
     105                 :             :   /* For context::get_classification_history, declared later.  */
     106                 :             :   friend class context;
     107                 :             : 
     108                 :             :   /* For pragma push/pop.  */
     109                 :             :   vec<int> m_push_list;
     110                 :             : };
     111                 :             : 
     112                 :             : } // namespace diagnostics
     113                 :             : 
     114                 :             : #endif /* ! GCC_DIAGNOSTICS_OPTION_CLASSIFIER_H */
        

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.