From a905ac01603ef1b064b04bd73b4b1b9ba3827e0b Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Wed, 20 Jun 2018 10:16:50 +0000 Subject: [PATCH] Replace lambda by member function reference to silence Visual Studio Visual Studio previously warned about a reference to a local or temporary being returned. This seems spurious, possibly caused by "this" being passed by-value to the lambda and Visual Studio thus assuming a copy was being created. Going via a reference to a member function makes Visual Studio happy (and should not change the behaviour in any way). --- src/pointer-analysis/value_set_analysis.cpp | 3 ++- src/pointer-analysis/value_set_analysis.h | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pointer-analysis/value_set_analysis.cpp b/src/pointer-analysis/value_set_analysis.cpp index d828c7cc1b9..c0566eb1d3a 100644 --- a/src/pointer-analysis/value_set_analysis.cpp +++ b/src/pointer-analysis/value_set_analysis.cpp @@ -19,7 +19,8 @@ Author: Daniel Kroening, kroening@kroening.com #include void value_sets_to_xml( - std::function get_value_set, + const std::function + &get_value_set, const goto_programt &goto_program, xmlt &dest) { diff --git a/src/pointer-analysis/value_set_analysis.h b/src/pointer-analysis/value_set_analysis.h index 6d1b0bb0b6a..34acca8f406 100644 --- a/src/pointer-analysis/value_set_analysis.h +++ b/src/pointer-analysis/value_set_analysis.h @@ -21,7 +21,8 @@ Author: Daniel Kroening, kroening@kroening.com class xmlt; void value_sets_to_xml( - std::function get_value_set, + const std::function + &get_value_set, const goto_programt &goto_program, xmlt &dest); @@ -39,12 +40,18 @@ class value_set_analysis_templatet: { } + const value_sett &get_value_set(goto_programt::const_targett t) + { + return (*this)[t].value_set; + } + void convert( const goto_programt &goto_program, xmlt &dest) const { + using std::placeholders::_1; value_sets_to_xml( - [this](locationt l) { return (*this)[l].value_set; }, + std::bind(&value_set_analysis_templatet::get_value_set, *this, _1), goto_program, dest); }