Skip to content

Find source location from a property irep_idt #1586

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
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
24 changes: 24 additions & 0 deletions src/goto-programs/show_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@ Author: Daniel Kroening, [email protected]
#include "goto_functions.h"
#include "goto_model.h"


optionalt<source_locationt> find_property(
const irep_idt &property,
const goto_functionst & goto_functions)
{
for(const auto &fct : goto_functions.function_map)
{
const goto_programt &goto_program = fct.second.body;

for(const auto &ins : goto_program.instructions)
{
if(ins.is_assert())
{
if(ins.source_location.get_property_id() == property)
{
return ins.source_location;
}
}
}
}
return { };
}


void show_properties(
const namespacet &ns,
const irep_idt &identifier,
Expand Down
12 changes: 12 additions & 0 deletions src/goto-programs/show_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Author: Daniel Kroening, [email protected]
#define CPROVER_GOTO_PROGRAMS_SHOW_PROPERTIES_H

#include <util/ui_message.h>
#include <util/optional.h>

class namespacet;
class goto_modelt;
Expand All @@ -28,4 +29,15 @@ void show_properties(
ui_message_handlert::uit ui,
const goto_functionst &goto_functions);

/// \brief Returns a source_locationt that corresponds
/// to the property given by an irep_idt.
/// \param property irep_idt that identifies property
/// \param goto_functions program in which to search for
/// the property
/// \return optional<source_locationt> the location of the
/// property, if found.
optionalt<source_locationt> find_property(
const irep_idt &property,
const goto_functionst &goto_functions);

#endif // CPROVER_GOTO_PROGRAMS_SHOW_PROPERTIES_H