LCOV - code coverage report
Current view: top level - src/visitors/validateTree - validatePointers.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 42 0
Test Date: 2025-04-18 15:53:49 Functions: 0.0 % 3 0

            Line data    Source code
       1              : #include "../../../inc/visitors/validateTree/validateTree.h"
       2              : #include "../../../inc/parsingAnalysis/ast/pointer/ast_delete.h"
       3              : #include "../../../inc/parsingAnalysis/ast/pointer/ast_deref.h"
       4              : #include "../../../inc/parsingAnalysis/ast/pointer/ast_new.h"
       5              : #include "../../../inc/parsingAnalysis/checkPosition.h"
       6              : 
       7              : namespace nicole {
       8              : 
       9              : // statemetn / body / not null
      10              : std::expected<bool, Error>
      11            0 : ValidateTree::visit(const AST_DELETE *node) const noexcept {
      12            0 :   if (!node) {
      13            0 :     return createError(ERROR_TYPE::NULL_NODE, "invalid AST_DELETE");
      14            0 :   }
      15            0 :   if (!CheckPosition::itsBodyAncestorHasParent(node)) {
      16            0 :     return createError(ERROR_TYPE::VALIDATE_TREE,
      17            0 :                        "a delete statement must appear in scope");
      18            0 :   }
      19            0 :   const auto result{node->value()->accept(*this)};
      20            0 :   if (!result) {
      21            0 :     return createError(result.error());
      22            0 :   }
      23            0 :   return true;
      24            0 : }
      25              : 
      26              : std::expected<bool, Error>
      27            0 : ValidateTree::visit(const AST_NEW *node) const noexcept {
      28            0 :   if (!node) {
      29            0 :     return createError(ERROR_TYPE::NULL_NODE, "invalid AST_NEW");
      30            0 :   }
      31            0 :   if (CheckPosition::hasEveryAncestorInOrder(
      32            0 :           node, {AST_TYPE::STATEMENT, AST_TYPE::BODY})) {
      33            0 :     return createError(ERROR_TYPE::VALIDATE_TREE, "dangling new operator");
      34            0 :   }
      35            0 :   const auto result{node->value()->accept(*this)};
      36            0 :   if (!result) {
      37            0 :     return createError(result.error());
      38            0 :   }
      39            0 :   return true;
      40            0 : }
      41              : 
      42              : std::expected<bool, Error>
      43            0 : ValidateTree::visit(const AST_DEREF *node) const noexcept {
      44            0 :   if (!node) {
      45            0 :     return createError(ERROR_TYPE::NULL_NODE, "invalid AST_DEREF");
      46            0 :   }
      47            0 :   if (CheckPosition::isOutOfScope(node)) {
      48            0 :     return createError(ERROR_TYPE::VALIDATE_TREE,
      49            0 :                        "a deref operation cannot appear outside of a scope");
      50            0 :   }
      51            0 :   const auto result{node->value()->accept(*this)};
      52            0 :   if (!result) {
      53            0 :     return createError(result.error());
      54            0 :   }
      55            0 :   return true;
      56            0 : }
      57              : 
      58              : }
        

Generated by: LCOV version 2.0-1