LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/theory - rewriter_attributes.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 30 30 100.0 %
Date: 2026-01-27 12:22:57 Functions: 56 56 100.0 %
Branches: 18 28 64.3 %

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * Top contributors (to current version):
       3                 :            :  *   Dejan Jovanovic, Tim King, 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                 :            :  * Rewriter attributes.
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "cvc5_private.h"
      17                 :            : 
      18                 :            : #pragma once
      19                 :            : 
      20                 :            : #include "expr/attribute.h"
      21                 :            : 
      22                 :            : namespace cvc5::internal {
      23                 :            : namespace theory {
      24                 :            : 
      25                 :            : template <bool pre, theory::TheoryId theoryId>
      26                 :            : struct RewriteCacheTag {};
      27                 :            : 
      28                 :            : template <theory::TheoryId theoryId>
      29                 :            : struct RewriteAttibute {
      30                 :            : 
      31                 :            :   typedef expr::Attribute< RewriteCacheTag<true, theoryId>, Node> pre_rewrite;
      32                 :            :   typedef expr::Attribute< RewriteCacheTag<false, theoryId>, Node> post_rewrite;
      33                 :            : 
      34                 :            :   /**
      35                 :            :    * Get the value of the pre-rewrite cache.
      36                 :            :    */
      37                 :   57091456 :   static Node getPreRewriteCache(TNode node)
      38                 :            :   {
      39                 :  114182922 :     Node cache;
      40         [ +  + ]:   57091456 :     if (node.hasAttribute(pre_rewrite())) {
      41                 :   37773202 :       node.getAttribute(pre_rewrite(), cache);
      42                 :            :     } else {
      43                 :   19318283 :       return Node::null();
      44                 :            :     }
      45         [ +  + ]:   37773202 :     if (cache.isNull()) {
      46                 :   29924119 :       return node;
      47                 :            :     } else {
      48                 :    7849117 :       return cache;
      49                 :            :     }
      50                 :            :   }
      51                 :            : 
      52                 :            :   /**
      53                 :            :    * Set the value of the pre-rewrite cache.
      54                 :            :    */
      55                 :   21170913 :   static void setPreRewriteCache(TNode node, TNode cache)
      56                 :            :   {
      57         [ +  - ]:   21170913 :     Trace("rewriter") << "setting pre-rewrite of " << node << " to " << cache << std::endl;
      58 [ -  + ][ -  + ]:   21170913 :     Assert(!cache.isNull());
                 [ -  - ]
      59         [ +  + ]:   21170913 :     if (node == cache) {
      60                 :   16687234 :       node.setAttribute(pre_rewrite(), Node::null());
      61                 :            :     } else {
      62                 :    4483688 :       node.setAttribute(pre_rewrite(), cache);
      63                 :            :     }
      64                 :   21170913 :   }
      65                 :            : 
      66                 :            :   /**
      67                 :            :    * Get the value of the post-rewrite cache.
      68                 :            :    * none).
      69                 :            :    */
      70                 :  187995345 :   static Node getPostRewriteCache(TNode node)
      71                 :            :   {
      72                 :  375991044 :     Node cache;
      73         [ +  + ]:  187995345 :     if (node.hasAttribute(post_rewrite())) {
      74                 :  116427981 :       node.getAttribute(post_rewrite(), cache);
      75                 :            :     } else {
      76                 :   71567422 :       return Node::null();
      77                 :            :     }
      78         [ +  + ]:  116427981 :     if (cache.isNull()) {
      79                 :   87888891 :       return node;
      80                 :            :     } else {
      81                 :   28539119 :       return cache;
      82                 :            :     }
      83                 :            :   }
      84                 :            : 
      85                 :            :   /**
      86                 :            :    * Set the value of the post-rewrite cache.  v cannot be a null Node.
      87                 :            :    */
      88                 :   19249970 :   static void setPostRewriteCache(TNode node, TNode cache)
      89                 :            :   {
      90 [ -  + ][ -  + ]:   19249970 :     Assert(!cache.isNull());
                 [ -  - ]
      91         [ +  - ]:   19249970 :     Trace("rewriter") << "setting rewrite of " << node << " to " << cache << std::endl;
      92         [ +  + ]:   19249970 :     if (node == cache) {
      93                 :    9256210 :       node.setAttribute(post_rewrite(), Node::null());
      94                 :            :     } else {
      95                 :    9993772 :       node.setAttribute(post_rewrite(), cache);
      96                 :            :     }
      97                 :   19249970 :   }
      98                 :            : };/* struct RewriteAttribute */
      99                 :            : 
     100                 :            : }  // namespace theory
     101                 :            : }  // namespace cvc5::internal

Generated by: LCOV version 1.14