Skip to content

Remove parsert::clear and all of its overrides #8244

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

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions src/ansi-c/ansi_c_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,6 @@ class ansi_c_parsert:public parsert

bool parse() override;

void clear() override
{
parsert::clear();
parse_tree.clear();

// scanner state
tag_following=false;
asm_block_following=false;
parenthesis_counter=0;
string_literal.clear();
pragma_pack.clear();
pragma_cprover_stack.clear();

// set up global scope
scopes.clear();
scopes.push_back(scopet());
}

// internal state of the scanner
bool tag_following;
bool asm_block_following;
Expand Down
6 changes: 0 additions & 6 deletions src/assembler/assembler_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ class assembler_parsert:public parsert
}

bool parse() override;

void clear() override
{
parsert::clear();
instructions.clear();
}
};

#endif // CPROVER_ASSEMBLER_ASSEMBLER_PARSER_H
6 changes: 0 additions & 6 deletions src/cpp/cpp_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ bool cpp_languaget::parse(
// save result
cpp_parse_tree.swap(cpp_parser.parse_tree);

// save some memory
cpp_parser.clear();

return result;
}

Expand Down Expand Up @@ -260,9 +257,6 @@ bool cpp_languaget::to_expr(
result = cpp_typecheck(expr, message_handler, ns);
}

// save some memory
cpp_parser.clear();

return result;
}

Expand Down
8 changes: 0 additions & 8 deletions src/cpp/cpp_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ class cpp_parsert:public parsert

virtual bool parse() override;

virtual void clear() override
{
parsert::clear();
parse_tree.clear();
token_buffer.clear();
asm_block_following=false;
}

explicit cpp_parsert(message_handlert &message_handler)
: parsert(message_handler),
mode(configt::ansi_ct::flavourt::ANSI),
Expand Down
3 changes: 0 additions & 3 deletions src/json/json_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ bool parse_json(
if(json_parser.stack.size()==1)
dest.swap(json_parser.stack.top());

// save some memory
json_parser.clear();

return result;
}

Expand Down
5 changes: 0 additions & 5 deletions src/json/json_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ class json_parsert:public parsert
dest.swap(stack.top());
stack.pop();
}

virtual void clear() override
{
stack=stackt();
}
};

// 'do it all' functions
Expand Down
6 changes: 0 additions & 6 deletions src/statement-list/statement_list_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,6 @@ bool statement_list_parsert::parse()
return parse_fail;
}

void statement_list_parsert::clear()
{
parsert::clear();
parse_tree.clear();
}

void statement_list_parsert::print_tree(std::ostream &out) const
{
output_parse_tree(out, parse_tree);
Expand Down
4 changes: 0 additions & 4 deletions src/statement-list/statement_list_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ class statement_list_parsert : public parsert
/// \param other: Parse tree which should be used in the swap operation.
void swap_tree(statement_list_parse_treet &other);

/// Removes all functions and function blocks from the parse tree and
/// clears the internal state of the parser.
void clear() override;

private:
/// Tree that is being filled by the parsing process.
statement_list_parse_treet parse_tree;
Expand Down
19 changes: 8 additions & 11 deletions src/util/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,20 @@ class parsert

std::vector<exprt> stack;

virtual void clear()
DEPRECATED(SINCE(2023, 12, 20, "use parsert(message_handler) instead"))
parsert() : in(nullptr), line_no(0), previous_line_no(0), column(1)
{
line_no=0;
previous_line_no=0;
column=1;
stack.clear();
source_location.clear();
last_line.clear();
}

DEPRECATED(SINCE(2023, 12, 20, "use parsert(message_handler) instead"))
parsert():in(nullptr) { clear(); }
explicit parsert(message_handlert &message_handler)
: in(nullptr), log(message_handler)
: in(nullptr),
log(message_handler),
line_no(0),
previous_line_no(0),
column(1)
{
clear();
}

virtual ~parsert() { }

// The following are for the benefit of the scanner
Expand Down
11 changes: 0 additions & 11 deletions src/xmllang/xml_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ class xml_parsert:public parsert
stack.push_back(&current().elements.back());
}

/// Clears the parser state. May be removed in future as there should not be a
/// need to re-use an existing parser object.
void clear() override
{
parse_tree.clear();
// set up stack
stack.clear();
stack.push_back(&parse_tree.element);
parsert::clear();
}

protected:
static int instance_count;
};
Expand Down