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
C++: First-class destructors in AST and IR #15318
base: main
Are you sure you want to change the base?
C++: First-class destructors in AST and IR #15318
Conversation
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 started reviewing this before I noticed it was a draft. Sorry! Feel free to ignore my comments if you're still working all these things out 😄
| /** | ||
| * Gets the `n`th compiler-generated destructor call that is performed after this expression, in | ||
| * order of destruction. | ||
| */ |
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 would be good to have an example here (specifically, for when there are multiple destructors attached to an element).
| * Gets the `n`th compiler-generated destructor call that is performed after this expression, in | ||
| * order of destruction. | ||
| */ | ||
| DestructorCall getSyntheticDestructor(int n) { |
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.
Could we avoid using the term "synthetic" in the public API? I don't actually know why the relational is using this term, because I don't think there's anything more "synthetic" about these destructor calls than other things in the AST
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.
Maybe getImplicitDestructor instead?
| result = expr.getParentWithConversions() | ||
| or | ||
| result.(Destructor).getADestruction() = expr | ||
| or | ||
| result.(Expr).getASyntheticDestructor() = expr | ||
| or | ||
| result.(Stmt).getASyntheticDestructor() = expr |
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.
Is it ever the case that an expr has multiple parents with these new cases included?
| ( | ||
| call instanceof ConstructorCall or | ||
| call instanceof DestructorCall | ||
| ) and |
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.
The comment above here is no longer correct, right? i.e., this part:
// Don't bother with destructor calls for now, since we won't see very many of them in the IR
// until we start injecting implicit destructor calls.
99b4e63
to
278b22c
Compare
This PR adds a new
getSyntheticDestructorpredicate toStmtandExpr, and adds destructors to the IR. Currently only theStmtrelation is populated by the extractor.