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

             Branch data     Line data    Source code
       1                 :             : /* Integration of the analyzer with GCC's pass manager.
       2                 :             :    Copyright (C) 2019-2024 Free Software Foundation, Inc.
       3                 :             :    Contributed by David Malcolm <dmalcolm@redhat.com>.
       4                 :             : 
       5                 :             : This file is part of GCC.
       6                 :             : 
       7                 :             : GCC is free software; you can redistribute it and/or modify it
       8                 :             : under the terms of the GNU General Public License as published by
       9                 :             : the Free Software Foundation; either version 3, or (at your option)
      10                 :             : any later version.
      11                 :             : 
      12                 :             : GCC is distributed in the hope that it will be useful, but
      13                 :             : WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15                 :             : General Public License for more details.
      16                 :             : 
      17                 :             : You should have received a copy of the GNU General Public License
      18                 :             : along with GCC; see the file COPYING3.  If not see
      19                 :             : <http://www.gnu.org/licenses/>.  */
      20                 :             : 
      21                 :             : #include "config.h"
      22                 :             : #include "system.h"
      23                 :             : #include "coretypes.h"
      24                 :             : #include "context.h"
      25                 :             : #include "tree-pass.h"
      26                 :             : #include "diagnostic.h"
      27                 :             : #include "options.h"
      28                 :             : #include "tree.h"
      29                 :             : #include "analyzer/analyzer.h"
      30                 :             : #include "analyzer/engine.h"
      31                 :             : 
      32                 :             : namespace {
      33                 :             : 
      34                 :             : /* Data for the analyzer pass.  */
      35                 :             : 
      36                 :             : const pass_data pass_data_analyzer =
      37                 :             : {
      38                 :             :   IPA_PASS, /* type */
      39                 :             :   "analyzer", /* name */
      40                 :             :   OPTGROUP_NONE, /* optinfo_flags */
      41                 :             :   TV_ANALYZER, /* tv_id */
      42                 :             :   PROP_ssa, /* properties_required */
      43                 :             :   0, /* properties_provided */
      44                 :             :   0, /* properties_destroyed */
      45                 :             :   0, /* todo_flags_start */
      46                 :             :   0, /* todo_flags_finish */
      47                 :             : };
      48                 :             : 
      49                 :             : /* The analyzer pass.  */
      50                 :             : 
      51                 :             : class pass_analyzer : public ipa_opt_pass_d
      52                 :             : {
      53                 :             : public:
      54                 :      280114 :    pass_analyzer(gcc::context *ctxt)
      55                 :             :    : ipa_opt_pass_d (pass_data_analyzer, ctxt,
      56                 :             :                      NULL, /* generate_summary */
      57                 :             :                      NULL, /* write_summary */
      58                 :             :                      NULL, /* read_summary */
      59                 :             :                      NULL, /* write_optimization_summary */
      60                 :             :                      NULL, /* read_optimization_summary */
      61                 :             :                      NULL, /* stmt_fixup */
      62                 :             :                      0, /* function_transform_todo_flags_start */
      63                 :             :                      NULL, /* function_transform */
      64                 :      280114 :                      NULL) /* variable_transform */
      65                 :      280114 :   {}
      66                 :             : 
      67                 :             :   /* opt_pass methods: */
      68                 :             :   bool gate (function *) final override;
      69                 :             :   unsigned int execute (function *) final override;
      70                 :             : }; // class pass_analyzer
      71                 :             : 
      72                 :             : /* Only run the analyzer if -fanalyzer.  */
      73                 :             : 
      74                 :             : bool
      75                 :      553805 : pass_analyzer::gate (function *)
      76                 :             : {
      77                 :      553805 :   return flag_analyzer != 0;
      78                 :             : }
      79                 :             : 
      80                 :             : /* Entrypoint for the analyzer pass.  */
      81                 :             : 
      82                 :             : unsigned int
      83                 :        3199 : pass_analyzer::execute (function *)
      84                 :             : {
      85                 :             : #if ENABLE_ANALYZER
      86                 :        3199 :   ana::run_checkers ();
      87                 :             : #else
      88                 :             :   sorry_no_analyzer ();
      89                 :             : #endif
      90                 :             : 
      91                 :        3199 :   return 0;
      92                 :             : }
      93                 :             : 
      94                 :             : } // anon namespace
      95                 :             : 
      96                 :             : /* Make an instance of the analyzer pass.  */
      97                 :             : 
      98                 :             : ipa_opt_pass_d *
      99                 :      280114 : make_pass_analyzer (gcc::context *ctxt)
     100                 :             : {
     101                 :      280114 :   return new pass_analyzer (ctxt);
     102                 :             : }
     103                 :             : 
     104                 :             : #if !ENABLE_ANALYZER
     105                 :             : 
     106                 :             : /* Issue a "sorry" diagnostic that the analyzer was not enabled.  */
     107                 :             : 
     108                 :             : void
     109                 :             : sorry_no_analyzer ()
     110                 :             : {
     111                 :             :   sorry ("%qs was not enabled in this build of GCC"
     112                 :             :          " (missing configure-time option %qs)",
     113                 :             :          "-fanalyzer", "--enable-analyzer");
     114                 :             : }
     115                 :             : 
     116                 :             : #endif /* #if !ENABLE_ANALYZER */
        

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.