Skip to content

goto-analyzer (un)reachable-functions: build valid json output #1926

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

Merged
merged 1 commit into from
Mar 12, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ CORE
"function": "obviously_dead",$
"function": "not_obviously_dead",$
--
"last line":[[:space:]]*$
^warning: ignoring
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ CORE
"function": "not_called",
"last line": 6
--
"last line":[[:space:]]*$
^warning: ignoring
18 changes: 15 additions & 3 deletions src/goto-analyzer/unreachable_instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,21 @@ static void list_functions(

goto_programt::const_targett end_function=
goto_program.instructions.end();
--end_function;
assert(end_function->is_end_function());
last_location=end_function->source_location;

// find the last instruction with a line number
// TODO(tautschnig): #918 will eventually ensure that every instruction
// has such
do
{
--end_function;
last_location = end_function->source_location;
}
while(
end_function != goto_program.instructions.begin() &&
last_location.get_line().empty());

if(last_location.get_line().empty())
last_location = decl.location;
}
else
// completely ignore functions without a body, both for
Expand Down