LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/expr - free_var_cache.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 16 24 66.7 %
Date: 2026-04-21 10:32:34 Functions: 3 5 60.0 %
Branches: 3 6 50.0 %

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * This file is part of the cvc5 project.
       3                 :            :  *
       4                 :            :  * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS
       5                 :            :  * in the top-level source directory and their institutional affiliations.
       6                 :            :  * All rights reserved.  See the file COPYING in the top-level source
       7                 :            :  * directory for licensing information.
       8                 :            :  * ****************************************************************************
       9                 :            :  *
      10                 :            :  * A class for allocating a list of free variables
      11                 :            :  */
      12                 :            : #include "expr/free_var_cache.h"
      13                 :            : 
      14                 :            : #include "expr/node_algorithm.h"
      15                 :            : 
      16                 :            : namespace cvc5::internal {
      17                 :            : 
      18                 :     224637 : TNode FreeVarCache::getFreeVar(const TypeNode& tn, size_t i)
      19                 :            : {
      20         [ +  + ]:     234463 :   while (i >= d_fv[tn].size())
      21                 :            :   {
      22                 :       9826 :     Node v = NodeManager::mkBoundVar(tn);
      23                 :       9826 :     d_allVars.push_back(v);
      24                 :            :     // store its id
      25                 :       9826 :     d_fvId[v] = d_fv[tn].size();
      26         [ +  - ]:      19652 :     Trace("free-var-cache")
      27                 :       9826 :         << "Free variable id " << v << " = " << d_fvId[v] << std::endl;
      28                 :       9826 :     d_fv[tn].push_back(v);
      29                 :       9826 :   }
      30                 :     224637 :   return d_fv[tn][i];
      31                 :            : }
      32                 :            : 
      33                 :     160408 : TNode FreeVarCache::getFreeVarInc(const TypeNode& tn,
      34                 :            :                                   std::map<TypeNode, size_t>& var_count)
      35                 :            : {
      36                 :     160408 :   size_t index = var_count[tn];
      37                 :     160408 :   var_count[tn]++;
      38                 :     160408 :   return getFreeVar(tn, index);
      39                 :            : }
      40                 :            : 
      41                 :      45297 : bool FreeVarCache::isFreeVar(const Node& n) const
      42                 :            : {
      43                 :      45297 :   return d_fvId.find(n) != d_fvId.end();
      44                 :            : }
      45                 :            : 
      46                 :          0 : size_t FreeVarCache::getFreeVarId(const Node& n) const
      47                 :            : {
      48                 :          0 :   std::map<Node, size_t>::const_iterator it = d_fvId.find(n);
      49         [ -  - ]:          0 :   if (it == d_fvId.end())
      50                 :            :   {
      51                 :          0 :     DebugUnhandled() << "FreeVarCache::isFreeVar: " << n
      52                 :          0 :                      << " is not a cached free variable.";
      53                 :            :     return 0;
      54                 :            :   }
      55                 :          0 :   return it->second;
      56                 :            : }
      57                 :            : 
      58                 :          0 : bool FreeVarCache::hasFreeVar(const Node& n) const
      59                 :            : {
      60                 :          0 :   return expr::hasSubterm(n, d_allVars);
      61                 :            : }
      62                 :            : 
      63                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14