-
Notifications
You must be signed in to change notification settings - Fork 136
Add Poison to the Kani-GotoC AST #1469
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
Changes from all commits
8a386c2
8de20c0
369c446
beba632
f9ab2bc
8a4a47e
791d877
7d33ed2
838a807
b2dbd39
73ae91c
a758c38
7c76620
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1493,6 +1493,11 @@ impl Expr { | |
| Stmt::assign(self, rhs, loc) | ||
| } | ||
|
|
||
| /// Shorthand to build a `Deinit(self)` statement. See `StmtBody::Deinit` | ||
| pub fn deinit(self, loc: Location) -> Stmt { | ||
| Stmt::deinit(self, loc) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this require that expr be an lvalue?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be nice to add an "is l-value" check to cprover bindings, but obviously not in this pr...
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/model-checking/kani/blob/main/cprover_bindings/src/goto_program/expr.rs#L385
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Annoyingly, enabling it on assign causes the stdlib test to crash. Investigating. |
||
| } | ||
|
|
||
| /// `if (self) { t } else { e }` or `if (self) { t }` | ||
| pub fn if_then_else(self, t: Stmt, e: Option<Stmt>, loc: Location) -> Stmt { | ||
| Stmt::if_then_else(self, t, e, loc) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,13 @@ impl Irep { | |
| } | ||
| } | ||
|
|
||
| /// Adds a `comment` sub to the irep. | ||
| /// Note that there might be comments both on the irep itself and | ||
| /// inside the location sub of the irep. | ||
| pub fn with_comment<T: Into<InternedString>>(self, c: T) -> Self { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cool. doc comment? I know I'm the one who vaguely waved you in the direction of "putting a comment on an irep" but did you dig into exactly how this works? It'd be good to explain I think...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That one is a bit blurry actually. It will add a comment directly to the irep. I do think we need a more standard way of writing comments like that for alternative back-ends |
||
| self.with_named_sub(IrepId::Comment, Irep::just_string_id(c)) | ||
| } | ||
|
|
||
| pub fn with_named_sub(mut self, key: IrepId, value: Irep) -> Self { | ||
| if !value.is_nil() { | ||
| self.named_sub.insert(key, value); | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely want a comment here, especially as "deinit" is not a c notion really, and this is "cprover_bindings"
That's kind of why I thought this should be called "poison" but I don't remember if that was decided against for some reason?
Also, I don't know if this is me reading it weird, but I have the comment note that this is a shorthand/helper (perhaps by example? Like: "Construct a deinit statement from an expression by writing
expr.deinit()"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because @celinval (correct me if I'm wrong) pointed out that "poison" in this form is only intended to model uninitialized memory. So calling it poison is too vague and deinit makes more sense. I tend to agree with that