Skip to content

Commit 702ab09

Browse files
WIP Invariant with diagnostics
1 parent 0ec4e7d commit 702ab09

File tree

4 files changed

+212
-86
lines changed

4 files changed

+212
-86
lines changed

regression/invariants/driver.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,21 +92,32 @@ int main(int argc, char** argv)
9292
else if(arg=="irep")
9393
INVARIANT_WITH_IREP(false, "error with irep", pointer_type(void_typet()));
9494
else if(arg == "invariant-diagnostics")
95-
INVARIANT(
95+
INVARIANT_WITH_DIAGNOSTICS(
9696
false,
9797
"invariant with diagnostics failure",
9898
"invariant diagnostics information");
9999
else if(arg == "precondition-diagnostics")
100-
PRECONDITION(false, "precondition diagnostics information");
100+
PRECONDITION_WITH_DIAGNOSTICS(
101+
false, "precondition diagnostics information");
101102
else if(arg == "postcondition-diagnostics")
102-
POSTCONDITION(false, "postcondition diagnostics information");
103+
POSTCONDITION_WITH_DIAGNOSTICS(
104+
false, "postcondition diagnostics information");
103105
else if(arg == "check-return-diagnostics")
104-
CHECK_RETURN(false, "check return diagnostics information");
106+
CHECK_RETURN_WITH_DIAGNOSTICS(
107+
false, "check return diagnostics information");
105108
else if(arg == "data-invariant-diagnostics")
106-
DATA_INVARIANT(
109+
DATA_INVARIANT_WITH_DIAGNOSTICS(
107110
false,
108111
"data invariant with diagnostics failure",
109112
"data invariant diagnostics information");
113+
else if(arg == "invariant-with-lots-of-diagnostics")
114+
INVARIANT_WITH_DIAGNOSTICS(
115+
false,
116+
"an invariant that fails",
117+
"diagnostic 1",
118+
"diagnostic 2",
119+
"diagnostic 3",
120+
"diagnostic 4");
110121
else
111122
return 1;
112123
}

src/util/dstring.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ Author: Daniel Kroening, [email protected]
1313
#define CPROVER_UTIL_DSTRING_H
1414

1515
#include <iosfwd>
16+
#include <string>
1617

18+
#include "invariant.h"
1719
#include "string_container.h"
1820

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

203+
template <>
204+
struct diagnostics_helpert<dstringt>
205+
{
206+
static std::string diagnostics_as_string(const dstringt &dstring)
207+
{
208+
return as_string(dstring);
209+
}
210+
};
211+
201212
#endif // CPROVER_UTIL_DSTRING_H

0 commit comments

Comments
 (0)