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

goto-analyzer: --show-local-bitvector #8546

Merged
merged 1 commit into from
Jan 3, 2025
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
3 changes: 3 additions & 0 deletions doc/man/goto-analyzer.1
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ perform taint analysis using rules in given file
\fB\-\-show\-taint\fR
print taint analysis results on stdout
.TP
\fB\-\-show\-local\-bitvector\fR
perform procedure\-local bitvector analysis
.TP
\fB\-\-show\-local\-may\-alias\fR
perform procedure\-local may alias analysis
.SS "C/C++ frontend options:"
Expand Down
8 changes: 8 additions & 0 deletions regression/goto-analyzer/bitvector-analysis/basic1.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
int some_int;
int *pointer_global;

void foobar(int *pointer_parameter)
{
int *pointer_local;
pointer_local = &some_int;
}
8 changes: 8 additions & 0 deletions regression/goto-analyzer/bitvector-analysis/basic1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
basic1.c
--show-local-bitvector
^ foobar::pointer_parameter: \+unknown$
^ foobar::1::pointer_local: \+static_lifetime$
^EXIT=0$
^SIGNAL=0$
--
24 changes: 24 additions & 0 deletions src/goto-analyzer/goto_analyzer_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <goto-programs/show_symbol_table.h>

#include <analyses/ai.h>
#include <analyses/local_bitvector_analysis.h>
#include <analyses/local_may_alias.h>
#include <ansi-c/cprover_library.h>
#include <ansi-c/gcc_version.h>
Expand Down Expand Up @@ -139,6 +140,11 @@
options.set_option("show-local-may-alias", true);
options.set_option("specific-analysis", true);
}
if(cmdline.isset("show-local-bitvector"))
{

Check warning on line 144 in src/goto-analyzer/goto_analyzer_parse_options.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-analyzer/goto_analyzer_parse_options.cpp#L144

Added line #L144 was not covered by tests
options.set_option("show-local-bitvector", true);
options.set_option("specific-analysis", true);
}

// Output format choice
if(cmdline.isset("text"))
Expand Down Expand Up @@ -572,6 +578,23 @@
return CPROVER_EXIT_SUCCESS;
}

if(options.get_bool_option("show-local-bitvector"))
{
namespacet ns(goto_model.symbol_table);

Check warning on line 584 in src/goto-analyzer/goto_analyzer_parse_options.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-analyzer/goto_analyzer_parse_options.cpp#L584

Added line #L584 was not covered by tests
for(const auto &gf_entry : goto_model.goto_functions.function_map)
{

Check warning on line 586 in src/goto-analyzer/goto_analyzer_parse_options.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-analyzer/goto_analyzer_parse_options.cpp#L586

Added line #L586 was not covered by tests
std::cout << ">>>>\n";
std::cout << ">>>> " << gf_entry.first << '\n';
std::cout << ">>>>\n";
local_bitvector_analysist local_bitvector_analysis(gf_entry.second, ns);
local_bitvector_analysis.output(std::cout, gf_entry.second, ns);
std::cout << '\n';
}

return CPROVER_EXIT_SUCCESS;
}

label_properties(goto_model);

if(cmdline.isset("show-properties"))
Expand Down Expand Up @@ -802,6 +825,7 @@
" {y--taint} {ufile_name} \t perform taint analysis using rules in given"
" file\n"
" {y--show-taint} \t print taint analysis results on stdout\n"
" {y--show-local-bitvector} \t perform procedure-local bitvector analysis\n"
" {y--show-local-may-alias} \t perform procedure-local may alias analysis\n"
"\n"
"C/C++ frontend options:\n"
Expand Down
3 changes: 2 additions & 1 deletion src/goto-analyzer/goto_analyzer_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class optionst;

#define GOTO_ANALYSER_OPTIONS_SPECIFIC_ANALYSES \
"(taint):(show-taint)" \
"(show-local-may-alias)"
"(show-local-may-alias)" \
"(show-local-bitvector)"

#define GOTO_ANALYSER_OPTIONS \
OPT_FUNCTIONS \
Expand Down
Loading