LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/expr - attribute.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 20 50 40.0 %
Date: 2026-04-14 10:42:21 Functions: 4 6 66.7 %
Branches: 2 18 11.1 %

           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                 :            :  * AttributeManager implementation.
      11                 :            :  */
      12                 :            : #include "expr/attribute.h"
      13                 :            : 
      14                 :            : #include <utility>
      15                 :            : 
      16                 :            : #include "base/output.h"
      17                 :            : #include "expr/node_value.h"
      18                 :            : 
      19                 :            : using namespace std;
      20                 :            : 
      21                 :            : namespace cvc5::internal {
      22                 :            : namespace expr {
      23                 :            : namespace attr {
      24                 :            : 
      25                 :      78129 : AttributeManager::AttributeManager() : d_inGarbageCollection(false) {}
      26                 :            : 
      27                 :  286083944 : bool AttributeManager::inGarbageCollection() const
      28                 :            : {
      29                 :  286083944 :   return d_inGarbageCollection;
      30                 :            : }
      31                 :            : 
      32                 :          0 : void AttributeManager::debugHook(CVC5_UNUSED int debugFlag)
      33                 :            : {
      34                 :            :   /* DO NOT CHECK IN ANY CODE INTO THE DEBUG HOOKS!
      35                 :            :    * debugHook() is an empty function for the purpose of debugging
      36                 :            :    * the AttributeManager without recompiling all of cvc5.
      37                 :            :    * Formally this is a nop.
      38                 :            :    */
      39                 :          0 : }
      40                 :            : 
      41                 :  165700343 : void AttributeManager::deleteAllAttributes(NodeValue* nv)
      42                 :            : {
      43 [ -  + ][ -  + ]:  165700343 :   Assert(!inGarbageCollection());
                 [ -  - ]
      44                 :  165700343 :   d_bools.erase(nv);
      45                 :  165700343 :   deleteFromTable(d_ints, nv);
      46                 :  165700343 :   deleteFromTable(d_tnodes, nv);
      47                 :  165700343 :   deleteFromTable(d_nodes, nv);
      48                 :  165700343 :   deleteFromTable(d_types, nv);
      49                 :  165700343 :   deleteFromTable(d_strings, nv);
      50                 :  165700343 : }
      51                 :            : 
      52                 :      72676 : void AttributeManager::deleteAllAttributes()
      53                 :            : {
      54                 :      72676 :   d_bools.clear();
      55                 :      72676 :   deleteAllFromTable(d_ints);
      56                 :      72676 :   deleteAllFromTable(d_tnodes);
      57                 :      72676 :   deleteAllFromTable(d_nodes);
      58                 :      72676 :   deleteAllFromTable(d_types);
      59                 :      72676 :   deleteAllFromTable(d_strings);
      60                 :      72676 : }
      61                 :            : 
      62                 :          0 : void AttributeManager::deleteAttributes(const AttrIdVec& atids)
      63                 :            : {
      64                 :            :   typedef std::map<uint64_t, std::vector<uint64_t> > AttrToVecMap;
      65                 :          0 :   AttrToVecMap perTableIds;
      66                 :            : 
      67                 :          0 :   for (AttrIdVec::const_iterator it = atids.begin(), it_end = atids.end();
      68         [ -  - ]:          0 :        it != it_end;
      69                 :          0 :        ++it)
      70                 :            :   {
      71                 :          0 :     const AttributeUniqueId& pair = *(*it);
      72                 :          0 :     std::vector<uint64_t>& inTable = perTableIds[pair.getTableId()];
      73                 :          0 :     inTable.push_back(pair.getWithinTypeId());
      74                 :            :   }
      75                 :          0 :   AttrToVecMap::iterator it = perTableIds.begin(), it_end = perTableIds.end();
      76         [ -  - ]:          0 :   for (; it != it_end; ++it)
      77                 :            :   {
      78                 :          0 :     Assert(((*it).first) <= LastAttrTable);
      79                 :          0 :     AttrTableId tableId = (AttrTableId)((*it).first);
      80                 :          0 :     std::vector<uint64_t>& ids = (*it).second;
      81                 :          0 :     std::sort(ids.begin(), ids.end());
      82                 :            : 
      83 [ -  - ][ -  - ]:          0 :     switch (tableId)
         [ -  - ][ -  - ]
      84                 :            :     {
      85                 :          0 :       case AttrTableBool:
      86                 :          0 :         Unimplemented() << "delete attributes is unimplemented for bools";
      87                 :            :         break;
      88                 :          0 :       case AttrTableUInt64: deleteAttributesFromTable(d_ints, ids); break;
      89                 :          0 :       case AttrTableTNode: deleteAttributesFromTable(d_tnodes, ids); break;
      90                 :          0 :       case AttrTableNode: deleteAttributesFromTable(d_nodes, ids); break;
      91                 :          0 :       case AttrTableTypeNode: deleteAttributesFromTable(d_types, ids); break;
      92                 :          0 :       case AttrTableString: deleteAttributesFromTable(d_strings, ids); break;
      93                 :            : 
      94                 :          0 :       case AttrTableCDBool:
      95                 :            :       case AttrTableCDUInt64:
      96                 :            :       case AttrTableCDTNode:
      97                 :            :       case AttrTableCDNode:
      98                 :            :       case AttrTableCDString:
      99                 :            :       case AttrTableCDPointer:
     100                 :          0 :         Unimplemented() << "CDAttributes cannot be deleted. Contact Tim/Morgan "
     101                 :          0 :                            "if this behavior is desired.";
     102                 :            :         break;
     103                 :            : 
     104                 :          0 :       case LastAttrTable:
     105                 :          0 :       default: Unreachable();
     106                 :            :     }
     107                 :            :   }
     108                 :          0 : }
     109                 :            : 
     110                 :            : }  // namespace attr
     111                 :            : }  // namespace expr
     112                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14