Skip to content

Invariant with diagnostics #2906

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
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 16 additions & 5 deletions regression/invariants/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,32 @@ int main(int argc, char** argv)
else if(arg=="irep")
INVARIANT_WITH_IREP(false, "error with irep", pointer_type(void_typet()));
else if(arg == "invariant-diagnostics")
INVARIANT(
INVARIANT_WITH_DIAGNOSTICS(
false,
"invariant with diagnostics failure",
"invariant diagnostics information");
else if(arg == "precondition-diagnostics")
PRECONDITION(false, "precondition diagnostics information");
PRECONDITION_WITH_DIAGNOSTICS(
false, "precondition diagnostics information");
else if(arg == "postcondition-diagnostics")
POSTCONDITION(false, "postcondition diagnostics information");
POSTCONDITION_WITH_DIAGNOSTICS(
false, "postcondition diagnostics information");
else if(arg == "check-return-diagnostics")
CHECK_RETURN(false, "check return diagnostics information");
CHECK_RETURN_WITH_DIAGNOSTICS(
false, "check return diagnostics information");
else if(arg == "data-invariant-diagnostics")
DATA_INVARIANT(
DATA_INVARIANT_WITH_DIAGNOSTICS(
false,
"data invariant with diagnostics failure",
"data invariant diagnostics information");
else if(arg == "invariant-with-lots-of-diagnostics")
INVARIANT_WITH_DIAGNOSTICS(
false,
"an invariant that fails",
"diagnostic 1",
"diagnostic 2",
"diagnostic 3",
"diagnostic 4");
else
return 1;
}
11 changes: 11 additions & 0 deletions src/util/dstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Author: Daniel Kroening, [email protected]
#define CPROVER_UTIL_DSTRING_H

#include <iosfwd>
#include <string>

#include "invariant.h"
#include "string_container.h"

/// \ref dstringt has one field, an unsigned integer \ref no which is an index
Expand Down Expand Up @@ -198,4 +200,13 @@ struct hash<dstringt> // NOLINT(readability/identifiers)
};
}

template <>
struct diagnostics_helpert<dstringt>
{
static std::string diagnostics_as_string(const dstringt &dstring)
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'm considering making this a function that takes a std::ostream& and writes some string representation of its argument there rather than returning string. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can leave this for future work I'd say :)

{
return as_string(dstring);
}
};

#endif // CPROVER_UTIL_DSTRING_H
Loading