LCOV - code coverage report
Current view: top level - gcc/m2/gm2-gcc - m2tree.cc (source / functions) Coverage Total Hit
Test: gcc.info Lines: 63.6 % 33 21
Test Date: 2026-02-28 14:20:25 Functions: 66.7 % 9 6
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /* m2tree.cc provides a simple interface to GCC tree queries and skips.
       2              : 
       3              : Copyright (C) 2012-2026 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      1895886 : m2tree_is_type (tree type)
      43              : {
      44      1895886 :   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     89721642 : m2tree_skip_type_decl (tree type)
      66              : {
      67    102087882 :   if (type == error_mark_node)
      68              :     return error_mark_node;
      69              : 
      70    102087840 :   if (type == NULL_TREE)
      71              :     return NULL_TREE;
      72              : 
      73    100480633 :   if (TREE_CODE (type) == TYPE_DECL)
      74     12366240 :     return m2tree_skip_type_decl (TREE_TYPE (type));
      75              :   return type;
      76              : }
      77              : 
      78              : tree
      79           33 : m2tree_skip_const_decl (tree exp)
      80              : {
      81           33 :   if (exp == error_mark_node)
      82              :     return error_mark_node;
      83              : 
      84           33 :   if (exp == NULL_TREE)
      85              :     return NULL_TREE;
      86              : 
      87           33 :   if (TREE_CODE (exp) == CONST_DECL)
      88            0 :     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       185830 : m2tree_skip_reference_type (tree exp)
      97              : {
      98       185830 :   if (TREE_CODE (exp) == REFERENCE_TYPE)
      99            0 :     return m2tree_skip_reference_type (TREE_TYPE (exp));
     100       185830 :   if (TREE_CODE (exp) == POINTER_TYPE)
     101            0 :     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       868990 : m2tree_IsOrdinal (tree type)
     110              : {
     111       868990 :   enum tree_code code = TREE_CODE (type);
     112              : 
     113       868990 :   return (code == INTEGER_TYPE || (code) == BOOLEAN_TYPE
     114       868990 :           || (code) == ENUMERAL_TYPE);
     115              : }
     116              : 
     117              : /* is_a_constant - returns TRUE if tree, t, is a constant.  */
     118              : 
     119              : bool
     120     24853842 : m2tree_IsAConstant (tree t)
     121              : {
     122     24853842 :   return (TREE_CODE (t) == INTEGER_CST) || (TREE_CODE (t) == REAL_CST)
     123              :     || (TREE_CODE (t) == REAL_CST) || (TREE_CODE (t) == COMPLEX_CST)
     124     24853842 :     || (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.4-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.