Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Constant DC verification #510

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

xJoskiy
Copy link
Contributor

@xJoskiy xJoskiy commented Jan 6, 2025

Add DC verification with constant predicactes, add violations highlights and minimization algorithm

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

ColumnOperand operand = predicates_.front().GetVariableOperand();
bool is_first_tuple = operand.IsFirstTuple();

auto check = [this, is_first_tuple](Predicate const& pred) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: lambda capture 'this' is not used [clang-diagnostic-unused-lambda-capture]

Suggested change
auto check = [this, is_first_tuple](Predicate const& pred) {
auto check = [ is_first_tuple](Predicate const& pred) {

}

bool DC::CheckTwoTuples() const {
auto check = [this](Predicate const& pred) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: lambda capture 'this' is not used [clang-diagnostic-unused-lambda-capture]

Suggested change
auto check = [this](Predicate const& pred) {
auto check = [](Predicate const& pred) {

right_op = GetOperand(left_op, str_right_op);
}

return {std::move(*left_op), std::move(*right_op)};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Potential leak of memory pointed to by 'left_op' [clang-analyzer-cplusplus.NewDeleteLeaks]

    return {std::move(*left_op), std::move(*right_op)};
    ^
Additional context

src/core/algorithms/dc/parser/dc_parser.cpp:47: Assuming the condition is false

    if (dc_string_.front() != '!') throw std::invalid_argument("Missing logic negation sign");
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:47: Taking false branch

    if (dc_string_.front() != '!') throw std::invalid_argument("Missing logic negation sign");
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:51: Assuming the condition is false

    if (dc_string_.front() != '(' or dc_string_.back() != ')')
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:51: Left side of '||' is false

    if (dc_string_.front() != '(' or dc_string_.back() != ')')
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:51: Assuming the condition is false

    if (dc_string_.front() != '(' or dc_string_.back() != ')')
                                     ^

src/core/algorithms/dc/parser/dc_parser.cpp:51: Taking false branch

    if (dc_string_.front() != '(' or dc_string_.back() != ')')
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:57: Assuming the condition is false

    if (dc_string_.empty()) throw std::invalid_argument("Empty DC is not allowed");
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:57: Taking false branch

    if (dc_string_.empty()) throw std::invalid_argument("Empty DC is not allowed");
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:60: Loop condition is true. Entering loop body

    while (has_next_predicate_) {
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:61: Calling 'DCParser::GetNextPredicate'

        Predicate pred = GetNextPredicate();
                         ^

src/core/algorithms/dc/parser/dc_parser.cpp:70: Assuming 'ind' is not equal to 'npos'

    if (ind == std::string::npos) has_next_predicate_ = false;
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:70: Taking false branch

    if (ind == std::string::npos) has_next_predicate_ = false;
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:75: Calling 'DCParser::ConvertToPredicate'

    return ConvertToPredicate(std::move(str_pred));
           ^

src/core/algorithms/dc/parser/dc_parser.cpp:84: Assuming 'ind' is not equal to 'npos'

        if (ind != std::string::npos) {
            ^

src/core/algorithms/dc/parser/dc_parser.cpp:84: Taking true branch

        if (ind != std::string::npos) {
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:86: Execution continues on line 91

            break;
            ^

src/core/algorithms/dc/parser/dc_parser.cpp:90: 'ind' is not equal to 'npos'

    if (ind == std::string::npos) throw std::invalid_argument("Missing permissible operator");
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:90: Taking false branch

    if (ind == std::string::npos) throw std::invalid_argument("Missing permissible operator");
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:99: Calling 'DCParser::GetOperands'

    auto [left_operand, right_operand] = GetOperands(str_left_operand, str_right_operand);
                                         ^

src/core/algorithms/dc/parser/dc_parser.cpp:109: Taking true branch

    if (IsVarOperand(str_left_op)) {
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:111: Memory is allocated

        left_op = new ColumnOperand(ConvertToVariableOperand(str_left_op));
                  ^

src/core/algorithms/dc/parser/dc_parser.cpp:114: Taking true branch

    if (IsVarOperand(str_right_op)) {
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:119: Left side of '&&' is false

    if (left_op == nullptr and right_op == nullptr)
                           ^

src/core/algorithms/dc/parser/dc_parser.cpp:122: Taking false branch

    if (left_op == nullptr) {
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:124: Taking false branch

    } else if (right_op == nullptr) {
           ^

src/core/algorithms/dc/parser/dc_parser.cpp:128: Potential leak of memory pointed to by 'left_op'

    return {std::move(*left_op), std::move(*right_op)};
    ^

right_op = GetOperand(left_op, str_right_op);
}

return {std::move(*left_op), std::move(*right_op)};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Potential leak of memory pointed to by 'right_op' [clang-analyzer-cplusplus.NewDeleteLeaks]

    return {std::move(*left_op), std::move(*right_op)};
    ^
Additional context

src/core/algorithms/dc/parser/dc_parser.cpp:47: Assuming the condition is false

    if (dc_string_.front() != '!') throw std::invalid_argument("Missing logic negation sign");
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:47: Taking false branch

    if (dc_string_.front() != '!') throw std::invalid_argument("Missing logic negation sign");
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:51: Assuming the condition is false

    if (dc_string_.front() != '(' or dc_string_.back() != ')')
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:51: Left side of '||' is false

    if (dc_string_.front() != '(' or dc_string_.back() != ')')
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:51: Assuming the condition is false

    if (dc_string_.front() != '(' or dc_string_.back() != ')')
                                     ^

src/core/algorithms/dc/parser/dc_parser.cpp:51: Taking false branch

    if (dc_string_.front() != '(' or dc_string_.back() != ')')
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:57: Assuming the condition is false

    if (dc_string_.empty()) throw std::invalid_argument("Empty DC is not allowed");
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:57: Taking false branch

    if (dc_string_.empty()) throw std::invalid_argument("Empty DC is not allowed");
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:60: Loop condition is true. Entering loop body

    while (has_next_predicate_) {
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:61: Calling 'DCParser::GetNextPredicate'

        Predicate pred = GetNextPredicate();
                         ^

src/core/algorithms/dc/parser/dc_parser.cpp:70: Assuming 'ind' is not equal to 'npos'

    if (ind == std::string::npos) has_next_predicate_ = false;
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:70: Taking false branch

    if (ind == std::string::npos) has_next_predicate_ = false;
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:75: Calling 'DCParser::ConvertToPredicate'

    return ConvertToPredicate(std::move(str_pred));
           ^

src/core/algorithms/dc/parser/dc_parser.cpp:84: Assuming 'ind' is not equal to 'npos'

        if (ind != std::string::npos) {
            ^

src/core/algorithms/dc/parser/dc_parser.cpp:84: Taking true branch

        if (ind != std::string::npos) {
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:86: Execution continues on line 91

            break;
            ^

src/core/algorithms/dc/parser/dc_parser.cpp:90: 'ind' is not equal to 'npos'

    if (ind == std::string::npos) throw std::invalid_argument("Missing permissible operator");
        ^

src/core/algorithms/dc/parser/dc_parser.cpp:90: Taking false branch

    if (ind == std::string::npos) throw std::invalid_argument("Missing permissible operator");
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:99: Calling 'DCParser::GetOperands'

    auto [left_operand, right_operand] = GetOperands(str_left_operand, str_right_operand);
                                         ^

src/core/algorithms/dc/parser/dc_parser.cpp:109: Taking true branch

    if (IsVarOperand(str_left_op)) {
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:114: Taking true branch

    if (IsVarOperand(str_right_op)) {
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:116: Memory is allocated

        right_op = new ColumnOperand(ConvertToVariableOperand(str_right_op));
                   ^

src/core/algorithms/dc/parser/dc_parser.cpp:119: Left side of '&&' is false

    if (left_op == nullptr and right_op == nullptr)
                           ^

src/core/algorithms/dc/parser/dc_parser.cpp:122: Taking false branch

    if (left_op == nullptr) {
    ^

src/core/algorithms/dc/parser/dc_parser.cpp:124: Taking false branch

    } else if (right_op == nullptr) {
           ^

src/core/algorithms/dc/parser/dc_parser.cpp:128: Potential leak of memory pointed to by 'right_op'

    return {std::move(*left_op), std::move(*right_op)};
    ^

@@ -71,6 +71,18 @@ struct Rect {

return true;
}

std::string ToString() const {
std::stringstream ss;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: implicit instantiation of undefined template 'std::basic_stringstream' [clang-diagnostic-error]

        std::stringstream ss;
                          ^
Additional context

/usr/include/c++/13/iosfwd:109: template is declared here

    class basic_stringstream;
          ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant