From aef48c261a74ec98ea23e1ecb59e6832968cba8a Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 7 Jun 2018 13:07:56 +0000 Subject: [PATCH 1/4] Avoid implicit cast int -> bool Visual Studio warns: warning C4800: 'unsigned __int64' : forcing value to bool 'true' or 'false' (performance warning) --- src/goto-programs/goto_model.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/goto-programs/goto_model.h b/src/goto-programs/goto_model.h index f4a3d62cb8e..80c14205968 100644 --- a/src/goto-programs/goto_model.h +++ b/src/goto-programs/goto_model.h @@ -92,7 +92,8 @@ class goto_modelt : public abstract_goto_modelt bool can_produce_function(const irep_idt &id) const override { - return goto_functions.function_map.count(id); + return goto_functions.function_map.find(id) != + goto_functions.function_map.end(); } }; @@ -127,7 +128,8 @@ class wrapper_goto_modelt : public abstract_goto_modelt bool can_produce_function(const irep_idt &id) const override { - return goto_functions.function_map.count(id); + return goto_functions.function_map.find(id) != + goto_functions.function_map.end(); } private: From e23a1bb9c3328fc037b3a26b9bd6cac8d96651e1 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 7 Jun 2018 13:16:40 +0000 Subject: [PATCH 2/4] Avoid deprecated code_typet() constructor --- src/goto-programs/goto_function.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/goto-programs/goto_function.h b/src/goto-programs/goto_function.h index 2db5fe04e17..c84d68b869c 100644 --- a/src/goto-programs/goto_function.h +++ b/src/goto-programs/goto_function.h @@ -46,7 +46,7 @@ class goto_functiont type.set(ID_C_hide, true); } - goto_functiont() + goto_functiont() : body(), type({}, empty_typet()) { } From feb59ab0662b4fea87e85cd494352e58bd56b64d Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 7 Jun 2018 13:17:13 +0000 Subject: [PATCH 3/4] Use not-as-deprecated version of to_integer --- src/util/arith_tools.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/util/arith_tools.h b/src/util/arith_tools.h index 54f8ed60fb8..29406248008 100644 --- a/src/util/arith_tools.h +++ b/src/util/arith_tools.h @@ -10,14 +10,13 @@ Author: Daniel Kroening, kroening@kroening.com #ifndef CPROVER_UTIL_ARITH_TOOLS_H #define CPROVER_UTIL_ARITH_TOOLS_H +#include "invariant.h" #include "mp_arith.h" #include "optional.h" -#include "invariant.h" +#include "std_expr.h" #include "deprecate.h" -class exprt; -class constant_exprt; class typet; // this one will go away @@ -49,7 +48,7 @@ struct numeric_castt final optionalt operator()(const exprt &expr) const { mp_integer out; - if(to_integer(expr, out)) + if(expr.id() != ID_constant || to_integer(to_constant_expr(expr), out)) return {}; return out; } From 04565b460bd3fdb640720729de8104d33a375960 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Thu, 7 Jun 2018 13:17:40 +0000 Subject: [PATCH 4/4] Un-deprecate to_integer(constant_exprt) The recommended substitute uses this function, removing it is currently impossible. --- src/util/arith_tools.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/util/arith_tools.h b/src/util/arith_tools.h index 29406248008..21e615c0c74 100644 --- a/src/util/arith_tools.h +++ b/src/util/arith_tools.h @@ -26,8 +26,6 @@ DEPRECATED("Use the constant_exprt version instead") bool to_integer(const exprt &expr, mp_integer &int_value); // returns 'true' on error -/// \deprecated: use numeric_cast instead -DEPRECATED("Use numeric_cast instead") bool to_integer(const constant_exprt &expr, mp_integer &int_value); // returns 'true' on error