Skip to content

Commit 29be751

Browse files
Merge pull request diffblue#450 from diffblue/documentation/lvsa-api
[SEC-442] Add get_references_reconstructed
2 parents 11d826f + 024e5a1 commit 29be751

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

cbmc/src/pointer-analysis/value_set.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ class namespacet;
3939
/// pairs of an `exprt` and an optional offset if known (0 for both dynamic
4040
/// objects in the example given above). RHS expressions are represented using
4141
/// numbering to avoid storing redundant duplicate expressions.
42+
///
43+
/// This object is used both for building and querying a single value set
44+
///
45+
/// To query the value set use get_value_set and get_reference_set
46+
/// get_value_set takes an expression representing a pointer and returns all
47+
/// the objects pointed to by that pointer
48+
/// get_reference_set takes an expression reprsenting a value and returns
49+
/// other expressions that refer to the same memory as the passed expression
4250
class value_sett
4351
{
4452
public:

src/pointer-analysis/local_value_set_analysis.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,20 @@ void local_value_set_analysist::get_values_reconstructed(
959959
query_value_set.value_set.get_value_set(expr, dest, ns);
960960
}
961961

962+
void local_value_set_analysist::get_references_reconstructed(
963+
locationt l, const exprt &expr, value_setst::valuest &dest)
964+
{
965+
optionalt<local_value_set_domaint> reconstructed_value_set =
966+
reconstruct_value_set(l);
967+
968+
// If reconstruct returns nothing, no reconstruction was necessary--
969+
// query the real value set.
970+
const local_value_set_domaint &query_value_set =
971+
reconstructed_value_set ? *reconstructed_value_set : (*this)[l];
972+
973+
query_value_set.value_set.get_reference_set(expr, dest, ns);
974+
}
975+
962976
optionalt<local_value_set_domaint>
963977
local_value_set_analysist::reconstruct_value_set(locationt l)
964978
{

src/pointer-analysis/local_value_set_analysis.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,17 @@
3030
/// external value sets or fields thereof (represented as a suffix, e.g.
3131
/// `some_static_field.x` or `dynamic_object13.y`).
3232
/// RHS expressions can be dynamic objects, external value sets or null.
33+
///
34+
/// This object is used both for building and querying value sets for each
35+
/// program location
36+
///
37+
/// To query a value set use get_values_reconstructed and
38+
/// get_references_reconstructed
39+
/// get_values_reconstructed takes a location and an expression representing a
40+
/// pointer and returns all the objects pointed to by that pointer
41+
/// get_references_reconstructed takes a location and an expression
42+
/// reprsenting a value and returns other expressions that refer to the same
43+
/// memory as the passed expression
3344
class lvsaa_single_external_set_summaryt : public summaryt
3445
{
3546
public:
@@ -237,6 +248,9 @@ class local_value_set_analysist
237248
void get_values_reconstructed(
238249
locationt l, const exprt &expr, value_setst::valuest &dest);
239250

251+
void get_references_reconstructed(
252+
locationt l, const exprt &expr, value_setst::valuest &dest);
253+
240254
void reconstruct_all_value_sets(const goto_programt &);
241255

242256
protected:

0 commit comments

Comments
 (0)