-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C++: support for designated initializers #116
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
Conversation
Can we get a test with out-of-order designated initializers? Something like |
@rdmarsh2 for your first request, I think the initializers on lines 63-64 of
For your request about child ordering, can you expand on what sort of query you'd like to see? (I think I can explain the problem you saw, and it should now be fixed, but I'm happy to improve the test). |
Those initializers look right; missed it on my first read through. The queries I was observing issues with were:
and
|
@dave-bartolomeo can you have a look to ensure that the extracted data is suitable for IR translation? |
I've added some tests to show that the child expressions of an aggregate literal are in the correct order (and match the correct fields/array elements). |
@@ -173,7 +173,7 @@ class ClassAggregateLiteral extends AggregateLiteral { | |||
*/ | |||
Expr getFieldExpr(Field field) { | |||
field = classType.getAField() and | |||
result = getChild(field.getInitializationOrder()) | |||
aggregate_field_init(this, result, field) |
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.
This should be aggregate_field_init(underlyingElement(this), unresolveElement(result), unresolveElement(field))
@@ -230,7 +230,7 @@ class ArrayAggregateLiteral extends AggregateLiteral { | |||
* element `elementIndex`, if present. | |||
*/ | |||
Expr getElementExpr(int elementIndex) { | |||
result = getChild(elementIndex) | |||
aggregate_array_init(this, result, elementIndex) |
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.
Similarly here
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.
Based on your tests, it appears that for an initialization where the order of the designators in the source code does not match the declaration order of the fields, the order of the children in the AggregateLiteral
will match the order of the init expression in the source code, not field declaration order, right? The C standard leaves the order of evaluation unspecified, and all three major compilers actually emit the initialization in field declaration order. Do we want the child order to match the source, or to match the order of evaluation?
My guess is that we should do whatever we do for constructor init lists, which have the same issue.
We already know the field declaration order, but the source code order is extra information that is potentially useful. |
Right. I was going to make the same point as @ian. Also, changing the order of the child exprs would be a largely orthogonal extractor change to the ones made to support designated initializers. I'm sure we could do it, but I'd like to get this PR merged first (especially since the 1.18 deadline is looming). |
LGTM FWIW, constructor init lists seem to show up in field declaration order, regardless of init list order. The IR currently ignores child order, and sorts initializers by field declaration order, so this change shouldn't impact the IR. Even if it did, the IR is easier to change after feature freeze than the extractor. I assume I shouldn't approve this until the extractor change goes into the private repo? |
Approval is harmless, but it should only be merged at the same time as the private PR. BTW, should I add a release note? |
Yes, definitely add a release note for this change and also other user-visible extractor features added for 1.18. #24 probably qualifies and maybe also the support for |
CFG: make loop expressions post order
Implement Java signature extraction
add test for qlpacks
add test for qlpacks
I've added new tuples to associate aggregate literals, their initializer expressions, and the field or element index being initialized.
This will need to be merged in sync with the internal extractor PR.
This PR also includes the comment-only dbscheme changes from #18, to avoid an extra upgrade script.