LCOV - code coverage report
Current view: top level - gcc/m2/gm2-gcc - m2tree.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 72.7 % 33 24
Test Date: 2024-04-13 14:00:49 Functions: 66.7 % 9 6
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : /* m2tree.cc provides a simple interface to GCC tree queries and skips.
       2                 :             : 
       3                 :             : Copyright (C) 2012-2024 Free Software Foundation, Inc.
       4                 :             : Contributed by Gaius Mulley <gaius@glam.ac.uk>.
       5                 :             : 
       6                 :             : This file is part of GNU Modula-2.
       7                 :             : 
       8                 :             : GNU Modula-2 is free software; you can redistribute it and/or modify
       9                 :             : it under the terms of the GNU General Public License as published by
      10                 :             : the Free Software Foundation; either version 3, or (at your option)
      11                 :             : any later version.
      12                 :             : 
      13                 :             : GNU Modula-2 is distributed in the hope that it will be useful, but
      14                 :             : WITHOUT ANY WARRANTY; without even the implied warranty of
      15                 :             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      16                 :             : General Public License for more details.
      17                 :             : 
      18                 :             : You should have received a copy of the GNU General Public License
      19                 :             : along with GNU Modula-2; see the file COPYING3.  If not see
      20                 :             : <http://www.gnu.org/licenses/>.  */
      21                 :             : 
      22                 :             : #include "gcc-consolidation.h"
      23                 :             : 
      24                 :             : #include "../m2-tree.h"
      25                 :             : 
      26                 :             : #define m2tree_c
      27                 :             : #include "m2tree.h"
      28                 :             : 
      29                 :             : bool
      30                 :           0 : m2tree_is_var (tree var)
      31                 :             : {
      32                 :           0 :   return VAR_P (var);
      33                 :             : }
      34                 :             : 
      35                 :             : bool
      36                 :           0 : m2tree_is_array (tree array)
      37                 :             : {
      38                 :           0 :   return TREE_CODE (array) == ARRAY_TYPE;
      39                 :             : }
      40                 :             : 
      41                 :             : bool
      42                 :     1600790 : m2tree_is_type (tree type)
      43                 :             : {
      44                 :     1600790 :   switch (TREE_CODE (type))
      45                 :             :     {
      46                 :             : 
      47                 :             :     case TYPE_DECL:
      48                 :             :     case ARRAY_TYPE:
      49                 :             :     case RECORD_TYPE:
      50                 :             :     case SET_TYPE:
      51                 :             :     case ENUMERAL_TYPE:
      52                 :             :     case POINTER_TYPE:
      53                 :             :     case INTEGER_TYPE:
      54                 :             :     case REAL_TYPE:
      55                 :             :     case UNION_TYPE:
      56                 :             :     case BOOLEAN_TYPE:
      57                 :             :     case COMPLEX_TYPE:
      58                 :             :       return TRUE;
      59                 :           0 :     default:
      60                 :           0 :       return FALSE;
      61                 :             :     }
      62                 :             : }
      63                 :             : 
      64                 :             : tree
      65                 :    60378157 : m2tree_skip_type_decl (tree type)
      66                 :             : {
      67                 :    68101266 :   if (type == error_mark_node)
      68                 :             :     return error_mark_node;
      69                 :             : 
      70                 :    68101224 :   if (type == NULL_TREE)
      71                 :             :     return NULL_TREE;
      72                 :             : 
      73                 :    66922192 :   if (TREE_CODE (type) == TYPE_DECL)
      74                 :     7723109 :     return m2tree_skip_type_decl (TREE_TYPE (type));
      75                 :             :   return type;
      76                 :             : }
      77                 :             : 
      78                 :             : tree
      79                 :         312 : m2tree_skip_const_decl (tree exp)
      80                 :             : {
      81                 :         312 :   if (exp == error_mark_node)
      82                 :             :     return error_mark_node;
      83                 :             : 
      84                 :         312 :   if (exp == NULL_TREE)
      85                 :             :     return NULL_TREE;
      86                 :             : 
      87                 :         312 :   if (TREE_CODE (exp) == CONST_DECL)
      88                 :         108 :     return DECL_INITIAL (exp);
      89                 :             :   return exp;
      90                 :             : }
      91                 :             : 
      92                 :             : /* m2tree_skip_reference_type - skips all POINTER_TYPE and
      93                 :             :    REFERENCE_TYPEs.  Otherwise return exp.  */
      94                 :             : 
      95                 :             : tree
      96                 :      208526 : m2tree_skip_reference_type (tree exp)
      97                 :             : {
      98                 :      209126 :   if (TREE_CODE (exp) == REFERENCE_TYPE)
      99                 :         120 :     return m2tree_skip_reference_type (TREE_TYPE (exp));
     100                 :      209006 :   if (TREE_CODE (exp) == POINTER_TYPE)
     101                 :         480 :     return m2tree_skip_reference_type (TREE_TYPE (exp));
     102                 :             :   return exp;
     103                 :             : }
     104                 :             : 
     105                 :             : /* m2tree_IsOrdinal - return TRUE if code is an INTEGER, BOOLEAN or
     106                 :             :    ENUMERAL type.  */
     107                 :             : 
     108                 :             : bool
     109                 :      730614 : m2tree_IsOrdinal (tree type)
     110                 :             : {
     111                 :      730614 :   enum tree_code code = TREE_CODE (type);
     112                 :             : 
     113                 :      730614 :   return (code == INTEGER_TYPE || (code) == BOOLEAN_TYPE
     114                 :      730614 :           || (code) == ENUMERAL_TYPE);
     115                 :             : }
     116                 :             : 
     117                 :             : /* is_a_constant - returns TRUE if tree, t, is a constant.  */
     118                 :             : 
     119                 :             : bool
     120                 :    16145127 : m2tree_IsAConstant (tree t)
     121                 :             : {
     122                 :    16145127 :   return (TREE_CODE (t) == INTEGER_CST) || (TREE_CODE (t) == REAL_CST)
     123                 :             :     || (TREE_CODE (t) == REAL_CST) || (TREE_CODE (t) == COMPLEX_CST)
     124                 :    16145127 :     || (TREE_CODE (t) == STRING_CST) || (TREE_CODE (t) == CONSTRUCTOR);
     125                 :             : }
     126                 :             : 
     127                 :             : 
     128                 :             : void
     129                 :           0 : m2tree_debug_tree (tree t)
     130                 :             : {
     131                 :           0 :   debug_tree (t);
     132                 :           0 : }
        

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.