You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think there's an expression that isn't being translated which causes this. This also happens before any of my changes. I can look into fixing this, but would prefer to do this outside of this PR.
See TranslatedElement.qll. We currently handle the cases where the initializer is either a ClassAggregateLiteral or a ConstructorFieldInit which has an explicit initializer expression. Not covered is the case where there is no initializer expression, but where field being initialized does have have an initializer.
We could add something along the lines of:
exists(ConstructorFieldInitinit|not ignoreExpr(init)and
ast = init and
field =init.getTarget()andnotexists(init.getExpr())and
expr = field.getInitializer().getExpr().getFullyConverted())
However, this by itself is not sufficient, as the expression field.getInitializer().getExpr() does not have an enclosing function, while one is assumed to exist in the translation.
Note that the extractor does not generate a value for init.getExpr() in this case, to avoid ending up in a situation where an expression has multiple parents.
dbartol
changed the title
Missing IR generation for field initialization of compiler-generated default constructor
Missing IR generation for field initialization via NSDMI
Mar 1, 2022
Thanks for the investigation. This is indeed not a trivial fix.
Ideas for whoever does attempt to tackle this:
Generate a separate set of IR instructions/operands for the field initializer expression in each constructor in which it is implicitly used. Pro: probably the simplest solution. Con: Breaks the existing invariant that each AST expression has a single IR instruction that produces its result.
Have the extractor generate a copy of the initializer expression to use as the actual field initializer in each constructor that needs it. The IR construction would then treat this like any other initializer. Pro: Preserves existing invariants. Con: Requires extractor change.
I think there's an expression that isn't being translated which causes this. This also happens before any of my changes. I can look into fixing this, but would prefer to do this outside of this PR.
Originally posted by @jketema in #8225 (comment)
The text was updated successfully, but these errors were encountered: