Skip to content

Add more documentation for goto programs #2785

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
Sep 6, 2018

Conversation

danpoe
Copy link
Contributor

@danpoe danpoe commented Aug 21, 2018

No description provided.

@@ -99,6 +101,7 @@ class goto_functionst
update_instructions_function();
}

/// Get the identifier of the entry point to a goto program
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather goto model

#include "goto_function.h"

/// Get the identifiers of the local variables declared in the function and the
/// identifiers of the paramters of the function.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: implicitly document the parameters by referring to them in this sentence?

code_typet type;

typedef std::vector<irep_idt> parameter_identifierst;

/// The identifiers of the parameters of this function
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but see #1695.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a comment to #1695. I'll add a comment here to say that parameter_identifiers is currently always empty and that for now they should be retrieved from code_typet.

@@ -17,13 +20,19 @@ Date: May 2018

#include "goto_program.h"

/// A goto function, consisting of function type, function body, and parameter
/// identifiers.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A link to goto_programt should be provided to enable readers to figure out more details.

@@ -18,6 +18,7 @@ Date: June 2003

#include <util/cprover_prefix.h>

/// A set of goto functions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd talk about a map

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I say "a collection of goto functions"? If we say set or map it could seem as if goto_functionst itself is a std::map or std::set.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

@@ -487,6 +487,9 @@ std::string as_string(
}
}

/// Compute the loop numbers of the loops in the goto program. Every backwards
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about: "Assign each loop in the goto program a unique index."

@@ -516,6 +519,15 @@ std::ostream &goto_programt::output(
return out;
}

/// Compute the target numbers for the targets in the goto program.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about: "Assign each control-flow join point in the goto program a unique index."

@@ -613,6 +634,9 @@ class goto_programt
instructions.clear();
}

/// Get end function target
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the term target it may be better to talk about "instruction iterators?" This applies throughout this PR.

@@ -642,6 +669,18 @@ class goto_programt
void get_decl_identifiers(decl_identifierst &decl_identifiers) const;
};

/// Get control-flow successors of a given instruction. The instruction is
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion this function is dangerous. Consequently I've created #2805.

@peterschrammel peterschrammel assigned danpoe and unassigned thk123 and pkesseli Aug 30, 2018
@danpoe danpoe force-pushed the doc/goto-models branch 4 times, most recently from 1764ec4 to 5f8b77d Compare September 5, 2018 13:15
@danpoe
Copy link
Contributor Author

danpoe commented Sep 5, 2018

@tautschnig, @peterschrammel I've now addressed all the comments

@@ -604,7 +621,6 @@ void goto_programt::copy_from(const goto_programt &src)
compute_target_numbers();
}

// number them
bool goto_programt::has_assertion() const
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding documentation (something along the lines of "Returns true if, and only if, the goto program includes an ASSERT instruction the guard of which is not trivially true.")

@@ -614,6 +630,8 @@ bool goto_programt::has_assertion() const
return false;
}

/// Compute for each instruction the set of instructions of which it is a
/// successor of.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "of which" should be removed. But check with someone whose first language is English.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR failed Diffblue compatibility checks (cbmc commit: e65f315).
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.

Common spurious failures:

  • the cbmc commit has disappeared in the mean time (e.g. in a force-push)
  • the author is not in the list of contributors (e.g. first-time contributors).

@danpoe danpoe merged commit aab3e8f into diffblue:develop Sep 6, 2018
@danpoe danpoe deleted the doc/goto-models branch June 2, 2020 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants