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

             Branch data     Line data    Source code
       1                 :             : /* Iterator routines for manipulating GENERIC tree statement list. -*- C++ -*-
       2                 :             :    Copyright (C) 2003-2024 Free Software Foundation, Inc.
       3                 :             :    Contributed by Andrew MacLeod  <amacleod@redhat.com>
       4                 :             : 
       5                 :             : This file is part of GCC.
       6                 :             : 
       7                 :             : GCC is free software; you can redistribute it and/or modify
       8                 :             : it 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,
      13                 :             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      14                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15                 :             : GNU 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                 :             : 
      22                 :             : /* This file is dependent upon the implementation of tree's. It provides an
      23                 :             :    abstract interface to the tree objects such that if all tree creation and
      24                 :             :    manipulations are done through this interface, we can easily change the
      25                 :             :    implementation of tree's, and not impact other code.  */
      26                 :             : 
      27                 :             : #ifndef GCC_TREE_ITERATOR_H
      28                 :             : #define GCC_TREE_ITERATOR_H 1
      29                 :             : 
      30                 :             : /* Iterator object for GENERIC or GIMPLE TREE statements.  */
      31                 :             : 
      32                 :             : struct tree_stmt_iterator {
      33                 :             :   struct tree_statement_list_node *ptr;
      34                 :             :   tree container;
      35                 :             : 
      36                 :             :   /* No need for user-defined constructors, the implicit definitions (or
      37                 :             :      aggregate initialization) are fine.  */
      38                 :             : 
      39                 :  1053625555 :   bool operator== (tree_stmt_iterator b) const
      40                 :   237710186 :     { return b.ptr == ptr && b.container == container; }
      41                 :  1213998708 :   bool operator!= (tree_stmt_iterator b) const { return !(*this == b); }
      42                 :  1795239015 :   tree_stmt_iterator &operator++ () { ptr = ptr->next; return *this; }
      43                 :        8767 :   tree_stmt_iterator &operator-- () { ptr = ptr->prev; return *this; }
      44                 :         186 :   tree_stmt_iterator operator++ (int)
      45                 :         186 :     { tree_stmt_iterator x = *this; ++*this; return x; }
      46                 :             :   tree_stmt_iterator operator-- (int)
      47                 :             :     { tree_stmt_iterator x = *this; --*this; return x; }
      48                 :   384841910 :   tree &operator* () { return ptr->stmt; }
      49                 :             :   tree operator* () const { return ptr->stmt; }
      50                 :             : };
      51                 :             : 
      52                 :             : inline tree_stmt_iterator
      53                 :  1108350426 : tsi_start (tree t)
      54                 :             : {
      55                 :  1108350426 :   tree_stmt_iterator i;
      56                 :             : 
      57                 :  1108350426 :   i.ptr = STATEMENT_LIST_HEAD (t);
      58                 :  1108350426 :   i.container = t;
      59                 :             : 
      60                 :  1108350426 :   return i;
      61                 :             : }
      62                 :             : 
      63                 :             : inline tree_stmt_iterator
      64                 :  1133900795 : tsi_last (tree t)
      65                 :             : {
      66                 :  1133900795 :   tree_stmt_iterator i;
      67                 :             : 
      68                 :  1133900795 :   i.ptr = STATEMENT_LIST_TAIL (t);
      69                 :  1133900795 :   i.container = t;
      70                 :             : 
      71                 :  1133900795 :   return i;
      72                 :             : }
      73                 :             : 
      74                 :             : inline bool
      75                 :   260863369 : tsi_end_p (tree_stmt_iterator i)
      76                 :             : {
      77                 :   260863369 :   return i.ptr == NULL;
      78                 :             : }
      79                 :             : 
      80                 :             : inline bool
      81                 :   757126114 : tsi_one_before_end_p (tree_stmt_iterator i)
      82                 :             : {
      83                 :   757126114 :   return i.ptr != NULL && i.ptr->next == NULL;
      84                 :             : }
      85                 :             : 
      86                 :             : inline void
      87                 :   962619116 : tsi_next (tree_stmt_iterator *i)
      88                 :             : {
      89                 :   738786022 :   ++(*i);
      90                 :   791091581 : }
      91                 :             : 
      92                 :             : inline void
      93                 :        8766 : tsi_prev (tree_stmt_iterator *i)
      94                 :             : {
      95                 :        8766 :   --(*i);
      96                 :        8766 : }
      97                 :             : 
      98                 :             : inline tree *
      99                 :   545978313 : tsi_stmt_ptr (tree_stmt_iterator i)
     100                 :             : {
     101                 :   547707448 :   return &(*i);
     102                 :             : }
     103                 :             : 
     104                 :             : inline tree
     105                 :  1359792066 : tsi_stmt (tree_stmt_iterator i)
     106                 :             : {
     107                 :  1359792066 :   return *i;
     108                 :             : }
     109                 :             : 
     110                 :             : /* Make tree_stmt_iterator work as a C++ range, e.g.
     111                 :             :    for (tree stmt : tsi_range (stmt_list)) { ... }  */
     112                 :             : class tsi_range
     113                 :             : {
     114                 :             :   tree t;
     115                 :             :  public:
     116                 :   239447373 :   tsi_range (tree t): t(t) { }
     117                 :   239447373 :   tree_stmt_iterator begin() const { return tsi_start (t); }
     118                 :   239447373 :   tree_stmt_iterator end() const { return { nullptr, t }; }
     119                 :             : };
     120                 :             : 
     121                 :             : enum tsi_iterator_update
     122                 :             : {
     123                 :             :   TSI_NEW_STMT,         /* Only valid when single statement is added, move
     124                 :             :                            iterator to it.  */
     125                 :             :   TSI_SAME_STMT,        /* Leave the iterator at the same statement.  */
     126                 :             :   TSI_CHAIN_START,      /* Only valid when chain of statements is added, move
     127                 :             :                            iterator to the first statement in the chain.  */
     128                 :             :   TSI_CHAIN_END,        /* Only valid when chain of statements is added, move
     129                 :             :                            iterator to the last statement in the chain.  */
     130                 :             :   TSI_CONTINUE_LINKING  /* Move iterator to whatever position is suitable for
     131                 :             :                            linking other statements/chains of statements in
     132                 :             :                            the same direction.  */
     133                 :             : };
     134                 :             : 
     135                 :             : extern void tsi_link_before (tree_stmt_iterator *, tree,
     136                 :             :                              enum tsi_iterator_update);
     137                 :             : extern void tsi_link_after (tree_stmt_iterator *, tree,
     138                 :             :                             enum tsi_iterator_update);
     139                 :             : 
     140                 :             : extern void tsi_delink (tree_stmt_iterator *);
     141                 :             : 
     142                 :             : extern tree alloc_stmt_list (void);
     143                 :             : extern void free_stmt_list (tree);
     144                 :             : extern void append_to_statement_list (tree, tree *);
     145                 :             : extern void append_to_statement_list_force (tree, tree *);
     146                 :             : extern tree expr_first (tree);
     147                 :             : extern tree expr_last (tree);
     148                 :             : extern tree expr_single (tree);
     149                 :             : 
     150                 :             : #endif /* GCC_TREE_ITERATOR_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.