LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/expr - attribute.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 22 60 36.7 %
Date: 2026-02-17 11:42:56 Functions: 4 6 66.7 %
Branches: 2 18 11.1 %

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Tim King, Dejan Jovanovic, Morgan Deters
       4                 :            :  *
       5                 :            :  * This file is part of the cvc5 project.
       6                 :            :  *
       7                 :            :  * Copyright (c) 2009-2025 by the authors listed in the file AUTHORS
       8                 :            :  * in the top-level source directory and their institutional affiliations.
       9                 :            :  * All rights reserved.  See the file COPYING in the top-level source
      10                 :            :  * directory for licensing information.
      11                 :            :  * ****************************************************************************
      12                 :            :  *
      13                 :            :  * AttributeManager implementation.
      14                 :            :  */
      15                 :            : #include "expr/attribute.h"
      16                 :            : 
      17                 :            : #include <utility>
      18                 :            : 
      19                 :            : #include "base/output.h"
      20                 :            : #include "expr/node_value.h"
      21                 :            : 
      22                 :            : using namespace std;
      23                 :            : 
      24                 :            : namespace cvc5::internal {
      25                 :            : namespace expr {
      26                 :            : namespace attr {
      27                 :            : 
      28                 :      77791 : AttributeManager::AttributeManager() :
      29                 :      77791 :   d_inGarbageCollection(false)
      30                 :      77791 : {}
      31                 :            : 
      32                 :  276160000 : bool AttributeManager::inGarbageCollection() const {
      33                 :  276160000 :   return d_inGarbageCollection;
      34                 :            : }
      35                 :            : 
      36                 :          0 : void AttributeManager::debugHook(CVC5_UNUSED int debugFlag)
      37                 :            : {
      38                 :            :   /* DO NOT CHECK IN ANY CODE INTO THE DEBUG HOOKS!
      39                 :            :    * debugHook() is an empty function for the purpose of debugging
      40                 :            :    * the AttributeManager without recompiling all of cvc5.
      41                 :            :    * Formally this is a nop.
      42                 :            :    */
      43                 :          0 : }
      44                 :            : 
      45                 :  159413000 : void AttributeManager::deleteAllAttributes(NodeValue* nv) {
      46 [ -  + ][ -  + ]:  159413000 :   Assert(!inGarbageCollection());
                 [ -  - ]
      47                 :  159413000 :   d_bools.erase(nv);
      48                 :  159413000 :   deleteFromTable(d_ints, nv);
      49                 :  159413000 :   deleteFromTable(d_tnodes, nv);
      50                 :  159413000 :   deleteFromTable(d_nodes, nv);
      51                 :  159413000 :   deleteFromTable(d_types, nv);
      52                 :  159413000 :   deleteFromTable(d_strings, nv);
      53                 :  159413000 : }
      54                 :            : 
      55                 :      72387 : void AttributeManager::deleteAllAttributes() {
      56                 :      72387 :   d_bools.clear();
      57                 :      72387 :   deleteAllFromTable(d_ints);
      58                 :      72387 :   deleteAllFromTable(d_tnodes);
      59                 :      72387 :   deleteAllFromTable(d_nodes);
      60                 :      72387 :   deleteAllFromTable(d_types);
      61                 :      72387 :   deleteAllFromTable(d_strings);
      62                 :      72387 : }
      63                 :            : 
      64                 :          0 : void AttributeManager::deleteAttributes(const AttrIdVec& atids) {
      65                 :            :   typedef std::map<uint64_t, std::vector< uint64_t> > AttrToVecMap;
      66                 :          0 :   AttrToVecMap perTableIds;
      67                 :            : 
      68         [ -  - ]:          0 :   for(AttrIdVec::const_iterator it = atids.begin(), it_end = atids.end(); it != it_end; ++it) {
      69                 :          0 :     const AttributeUniqueId& pair = *(*it);
      70                 :          0 :     std::vector< uint64_t>& inTable = perTableIds[pair.getTableId()];
      71                 :          0 :     inTable.push_back(pair.getWithinTypeId());
      72                 :            :   }
      73                 :          0 :   AttrToVecMap::iterator it = perTableIds.begin(), it_end = perTableIds.end();
      74         [ -  - ]:          0 :   for(; it != it_end; ++it) {
      75                 :          0 :     Assert(((*it).first) <= LastAttrTable);
      76                 :          0 :     AttrTableId tableId = (AttrTableId) ((*it).first);
      77                 :          0 :     std::vector< uint64_t>& ids = (*it).second;
      78                 :          0 :     std::sort(ids.begin(), ids.end());
      79                 :            : 
      80 [ -  - ][ -  - ]:          0 :     switch(tableId) {
         [ -  - ][ -  - ]
      81                 :          0 :     case AttrTableBool:
      82                 :          0 :       Unimplemented() << "delete attributes is unimplemented for bools";
      83                 :            :       break;
      84                 :          0 :     case AttrTableUInt64:
      85                 :          0 :       deleteAttributesFromTable(d_ints, ids);
      86                 :          0 :       break;
      87                 :          0 :     case AttrTableTNode:
      88                 :          0 :       deleteAttributesFromTable(d_tnodes, ids);
      89                 :          0 :       break;
      90                 :          0 :     case AttrTableNode:
      91                 :          0 :       deleteAttributesFromTable(d_nodes, ids);
      92                 :          0 :       break;
      93                 :          0 :     case AttrTableTypeNode:
      94                 :          0 :       deleteAttributesFromTable(d_types, ids);
      95                 :          0 :       break;
      96                 :          0 :     case AttrTableString:
      97                 :          0 :       deleteAttributesFromTable(d_strings, ids);
      98                 :          0 :       break;
      99                 :            : 
     100                 :          0 :     case AttrTableCDBool:
     101                 :            :     case AttrTableCDUInt64:
     102                 :            :     case AttrTableCDTNode:
     103                 :            :     case AttrTableCDNode:
     104                 :            :     case AttrTableCDString:
     105                 :            :     case AttrTableCDPointer:
     106                 :          0 :       Unimplemented() << "CDAttributes cannot be deleted. Contact Tim/Morgan "
     107                 :          0 :                          "if this behavior is desired.";
     108                 :            :       break;
     109                 :            : 
     110                 :          0 :     case LastAttrTable:
     111                 :            :     default:
     112                 :          0 :       Unreachable();
     113                 :            :     }
     114                 :            :   }
     115                 :          0 : }
     116                 :            : 
     117                 :            : }  // namespace attr
     118                 :            : }  // namespace expr
     119                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14