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

Replace all uses of deprecated functions by non-deprecated ones [depends-on: #5621, #5587, #5599, #4050] #3800

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# Enable lots of warnings
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror -Wswitch-enum \
-Wno-deprecated-declarations -Wno-maybe-uninitialized")
-Wno-maybe-uninitialized")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
# Ensure NDEBUG is not set for release builds
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
# Enable lots of warnings
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror -Wswitch-enum -Wno-deprecated-declarations")
"${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror -Wswitch-enum")
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# This would be the place to enable warnings for Windows builds, although
# config.inc doesn't seem to do that currently
Expand Down
10 changes: 6 additions & 4 deletions jbmc/src/java_bytecode/java_bytecode_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ Author: Daniel Kroening, [email protected]
class java_bytecode_parsert final : public parsert
{
public:
explicit java_bytecode_parsert(bool skip_instructions)
: skip_instructions(skip_instructions)
java_bytecode_parsert(
bool skip_instructions,
message_handlert &message_handler)
: parsert(message_handler), skip_instructions(skip_instructions)
{
}

Expand Down Expand Up @@ -1809,9 +1811,9 @@ std::optional<java_bytecode_parse_treet> java_bytecode_parse(
message_handlert &message_handler,
bool skip_instructions)
{
java_bytecode_parsert java_bytecode_parser(skip_instructions);
java_bytecode_parsert java_bytecode_parser(
skip_instructions, message_handler);
java_bytecode_parser.in=&istream;
java_bytecode_parser.log.set_message_handler(message_handler);

bool parser_result=java_bytecode_parser.parse();

Expand Down
4 changes: 2 additions & 2 deletions src/analyses/ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ class ait : public ai_recursive_interproceduralt
// Not recommended as it will throw an exception if a location has not
// been reached in an analysis and there is no (other) way of telling
// if a location has been reached.
DEPRECATED(SINCE(2019, 08, 01, "use abstract_state_{before,after} instead"))
// DEPRECATED(SINCE(2019, 08, 01, "use abstract_state_{before,after} instead"))
const domainT &operator[](locationt l) const
{
auto p = storage->abstract_state_before(l, *domain_factory);
Expand All @@ -607,7 +607,7 @@ class ait : public ai_recursive_interproceduralt
// Support the legacy get_state interface which is needed for a few domains
// This is one of the few users of the legacy get_state(locationt) method
// in location_sensitive_storaget.
DEPRECATED(SINCE(2019, 08, 01, "use get_state(trace_ptrt p) instead"))
// DEPRECATED(SINCE(2019, 08, 01, "use get_state(trace_ptrt p) instead"))
virtual statet &get_state(locationt l)
{
auto &s = dynamic_cast<location_sensitive_storaget &>(*storage);
Expand Down
2 changes: 1 addition & 1 deletion src/analyses/ai_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class location_sensitive_storaget : public trace_map_storaget
// Care should be exercised in using this. It is possible to create domains
// without any corresponding history object(s). This can lead to somewhat
// unexpected behaviour depending on which APIs you use.
DEPRECATED(SINCE(2019, 08, 01, "use get_state(trace_ptrt p) instead"))
// DEPRECATED(SINCE(2019, 08, 01, "use get_state(trace_ptrt p) instead"))
statet &get_state(locationt l, const ai_domain_factory_baset &fac)
{
typename state_mapt::const_iterator it = state_map.find(l);
Expand Down
8 changes: 4 additions & 4 deletions src/ansi-c/ansi_c_internal_additions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ max_malloc_size(std::size_t pointer_width, std::size_t object_bits)
return ((mp_integer)1) << (mp_integer)bits_for_positive_offset;
}

void ansi_c_internal_additions(std::string &code)
void ansi_c_internal_additions(
std::string &code,
bool support_ts_18661_3_Floatn_types)
{
// clang-format off
// do the built-in types and variables
Expand Down Expand Up @@ -247,9 +249,7 @@ void ansi_c_internal_additions(std::string &code)
config.ansi_c.mode == configt::ansi_ct::flavourt::ARM)
{
code+=gcc_builtin_headers_types;
// check the parser and not config.ansi_c.ts_18661_3_Floatn_types to adjust
// behaviour depending on C or C++ context
if(ansi_c_parser.ts_18661_3_Floatn_types)
if(support_ts_18661_3_Floatn_types)
code += gcc_builtin_headers_types_gcc7plus;

// there are many more, e.g., look at
Expand Down
4 changes: 3 additions & 1 deletion src/ansi-c/ansi_c_internal_additions.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Author: Daniel Kroening, [email protected]

#include <string>

void ansi_c_internal_additions(std::string &code);
void ansi_c_internal_additions(
std::string &code,
bool support_ts_18661_3_Floatn_types);
void ansi_c_architecture_strings(std::string &code);

extern const char clang_builtin_headers[];
Expand Down
14 changes: 6 additions & 8 deletions src/ansi-c/ansi_c_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,19 @@ bool ansi_c_languaget::parse(
// parsing

std::string code;
ansi_c_internal_additions(code);
ansi_c_internal_additions(code, config.ansi_c.ts_18661_3_Floatn_types);
std::istringstream codestr(code);

ansi_c_parser.clear();
ansi_c_parsert ansi_c_parser{message_handler};
ansi_c_parser.set_file(ID_built_in);
ansi_c_parser.in=&codestr;
ansi_c_parser.log.set_message_handler(message_handler);
ansi_c_parser.for_has_scope=config.ansi_c.for_has_scope;
ansi_c_parser.ts_18661_3_Floatn_types=config.ansi_c.ts_18661_3_Floatn_types;
ansi_c_parser.cpp98=false; // it's not C++
ansi_c_parser.cpp11=false; // it's not C++
ansi_c_parser.mode=config.ansi_c.mode;

ansi_c_scanner_init();
ansi_c_scanner_init(ansi_c_parser);

bool result=ansi_c_parser.parse();

Expand All @@ -90,7 +89,7 @@ bool ansi_c_languaget::parse(
ansi_c_parser.set_line_no(0);
ansi_c_parser.set_file(path);
ansi_c_parser.in=&i_preprocessed;
ansi_c_scanner_init();
ansi_c_scanner_init(ansi_c_parser);
result=ansi_c_parser.parse();
}

Expand Down Expand Up @@ -197,13 +196,12 @@ bool ansi_c_languaget::to_expr(

// parsing

ansi_c_parser.clear();
ansi_c_parsert ansi_c_parser{message_handler};
ansi_c_parser.set_file(irep_idt());
ansi_c_parser.in=&i_preprocessed;
ansi_c_parser.log.set_message_handler(message_handler);
ansi_c_parser.mode=config.ansi_c.mode;
ansi_c_parser.ts_18661_3_Floatn_types=config.ansi_c.ts_18661_3_Floatn_types;
ansi_c_scanner_init();
ansi_c_scanner_init(ansi_c_parser);

bool result=ansi_c_parser.parse();

Expand Down
10 changes: 0 additions & 10 deletions src/ansi-c/ansi_c_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ Author: Daniel Kroening, [email protected]

#include "c_storage_spec.h"

ansi_c_parsert ansi_c_parser;

ansi_c_id_classt ansi_c_parsert::lookup(
const irep_idt &base_name,
irep_idt &identifier, // output
Expand Down Expand Up @@ -73,14 +71,6 @@ void ansi_c_parsert::add_tag_with_body(irept &tag)
}
}

extern char *yyansi_ctext;

int yyansi_cerror(const std::string &error)
{
ansi_c_parser.parse_error(error, yyansi_ctext);
return 0;
}

void ansi_c_parsert::add_declarator(
exprt &declaration,
irept &declarator)
Expand Down
18 changes: 10 additions & 8 deletions src/ansi-c/ansi_c_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ Author: Daniel Kroening, [email protected]
#include "ansi_c_parse_tree.h"
#include "ansi_c_scope.h"

int yyansi_cparse();
class ansi_c_parsert;
int yyansi_cparse(ansi_c_parsert &);

class ansi_c_parsert:public parsert
{
public:
ansi_c_parse_treet parse_tree;

ansi_c_parsert()
: tag_following(false),
explicit ansi_c_parsert(message_handlert &message_handler)
: parsert(message_handler),
tag_following(false),
asm_block_following(false),
parenthesis_counter(0),
mode(modet::NONE),
Expand All @@ -35,11 +37,14 @@ class ansi_c_parsert:public parsert
for_has_scope(false),
ts_18661_3_Floatn_types(false)
{
// set up global scope
scopes.clear();
scopes.push_back(scopet());
}

virtual bool parse() override
{
return yyansi_cparse()!=0;
return yyansi_cparse(*this) != 0;
}

virtual void clear() override
Expand Down Expand Up @@ -166,9 +171,6 @@ class ansi_c_parsert:public parsert
std::list<std::map<const irep_idt, bool>> pragma_cprover_stack;
};

extern ansi_c_parsert ansi_c_parser;

int yyansi_cerror(const std::string &error);
void ansi_c_scanner_init();
void ansi_c_scanner_init(ansi_c_parsert &);

#endif // CPROVER_ANSI_C_ANSI_C_PARSER_H
8 changes: 4 additions & 4 deletions src/ansi-c/builtin_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@ static bool convert(
{
std::istringstream in(s.str());

ansi_c_parser.clear();
ansi_c_parsert ansi_c_parser{message_handler};
ansi_c_parser.set_file(ID_built_in);
ansi_c_parser.in=&in;
ansi_c_parser.log.set_message_handler(message_handler);
ansi_c_parser.for_has_scope=config.ansi_c.for_has_scope;
ansi_c_parser.cpp98=false; // it's not C++
ansi_c_parser.cpp11=false; // it's not C++
ansi_c_parser.mode=config.ansi_c.mode;

ansi_c_scanner_init();
ansi_c_scanner_init(ansi_c_parser);

if(ansi_c_parser.parse())
return true;
Expand Down Expand Up @@ -97,6 +96,7 @@ static bool convert(
//! \return 'true' on error
bool builtin_factory(
const irep_idt &identifier,
bool support_ts_18661_3_Floatn_types,
symbol_table_baset &symbol_table,
message_handlert &mh)
{
Expand All @@ -106,7 +106,7 @@ bool builtin_factory(
std::ostringstream s;

std::string code;
ansi_c_internal_additions(code);
ansi_c_internal_additions(code, support_ts_18661_3_Floatn_types);
s << code;

// our own extensions
Expand Down
1 change: 1 addition & 0 deletions src/ansi-c/builtin_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class symbol_table_baset;
//! \return 'true' in case of error
bool builtin_factory(
const irep_idt &identifier,
bool support_ts_18661_3_Floatn_types,
symbol_table_baset &,
message_handlert &);

Expand Down
2 changes: 2 additions & 0 deletions src/ansi-c/c_typecheck_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ class c_typecheck_baset:

virtual bool gcc_types_compatible_p(const typet &, const typet &);

virtual bool builtin_factory(const irep_idt &);

// types
virtual void typecheck_type(typet &type);
virtual void typecheck_compound_type(struct_union_typet &type);
Expand Down
11 changes: 10 additions & 1 deletion src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,15 @@ void c_typecheck_baset::typecheck_obeys_contract_call(
expr.type() = bool_typet();
}

bool c_typecheck_baset::builtin_factory(const irep_idt &identifier)
{
return ::builtin_factory(
identifier,
config.ansi_c.ts_18661_3_Floatn_types,
symbol_table,
get_message_handler());
}

void c_typecheck_baset::typecheck_side_effect_function_call(
side_effect_expr_function_callt &expr)
{
Expand Down Expand Up @@ -2106,7 +2115,7 @@ void c_typecheck_baset::typecheck_side_effect_function_call(
typecheck_typed_target_call(expr);
}
// Is this a builtin?
else if(!builtin_factory(identifier, symbol_table, get_message_handler()))
else if(!builtin_factory(identifier))
{
// yes, it's a builtin
}
Expand Down
16 changes: 15 additions & 1 deletion src/ansi-c/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,27 @@
#ifdef ANSI_C_DEBUG
#define YYDEBUG 1
#endif
#define PARSER ansi_c_parser
#define PARSER (*ansi_c_parser)

#include "ansi_c_parser.h"

int yyansi_clex();
extern char *yyansi_ctext;

static ansi_c_parsert *ansi_c_parser;
int yyansi_cparse(void);
int yyansi_cparse(ansi_c_parsert &_ansi_c_parser)
{
ansi_c_parser = &_ansi_c_parser;
return yyansi_cparse();
}

int yyansi_cerror(const std::string &error)
{
ansi_c_parser->parse_error(error, yyansi_ctext);
return 0;
}

#include "parser_static.inc"

#include "literals/convert_integer_literal.h"
Expand Down
26 changes: 14 additions & 12 deletions src/ansi-c/scanner.l
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static int isatty(int) { return 0; }
#include "literals/convert_string_literal.h"
#include "literals/unescape_string.h"

#define PARSER ansi_c_parser
#define PARSER (*ansi_c_parser)
#define YYSTYPE unsigned
#undef ECHO
#define ECHO
Expand All @@ -49,6 +49,19 @@ static int isatty(int) { return 0; }
extern int yyansi_cdebug;
#endif

static ansi_c_parsert *ansi_c_parser;
void ansi_c_scanner_init(ansi_c_parsert &_ansi_c_parser)
{
#ifdef ANSI_C_DEBUG
yyansi_cdebug=1;
#endif
ansi_c_parser = &_ansi_c_parser;
YY_FLUSH_BUFFER;
BEGIN(0);
}

int yyansi_cerror(const std::string &error);

#define loc() \
{ newstack(yyansi_clval); PARSER.set_source_location(parser_stack(yyansi_clval)); }

Expand Down Expand Up @@ -264,17 +277,6 @@ enable_or_disable ("enable"|"disable")
%x CPROVER_PRAGMA
%x OTHER_PRAGMA

%{
void ansi_c_scanner_init()
{
#ifdef ANSI_C_DEBUG
yyansi_cdebug=1;
#endif
YY_FLUSH_BUFFER;
BEGIN(0);
}
%}

%%

<INITIAL>.|\n { BEGIN(GRAMMAR);
Expand Down
6 changes: 3 additions & 3 deletions src/assembler/assembler_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Author: Daniel Kroening, [email protected]

#include "assembler_parser.h"

assembler_parsert assembler_parser;

extern char *yyassemblertext;

int yyassemblererror(const std::string &error)
int yyassemblererror(
assembler_parsert &assembler_parser,
const std::string &error)
{
assembler_parser.parse_error(error, yyassemblertext);
return 0;
Expand Down
Loading
Loading