-
Notifications
You must be signed in to change notification settings - Fork 5
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
Various bugs in mkString
#703
Comments
Recent changes to main (#703 probably) improved the rewriting on a test I added.
Recent changes to main (#703 probably) improved the rewriting on a test I added.
As I dug into the reasons why all the conditionals in the PR so far were needed under the current design of the rest of mkString, I realized that the design could be straightened out a bit and correctly handle one more case involving checked pointers to fixed-size arrays. This doesn't address the more difficult problems with wild pointers to fixed-size arrays or with wild pointer levels being in reverse order in general (see #703).
Item 6 sounds like #161 |
Yes indeed! Thanks. I think I'll keep the duplicate copy of the description here so we can have it at hand as we consider any larger improvements to I think I now know the basic redesign that would be needed to fix problems (5) and (6) and maybe other problems we haven't yet specifically identified. In essence, since the declarator syntax for wild pointers and both wild and checked arrays is inside-out (in contrast to checked pointers, which are right-side-out), so as we scan the type levels from outer to inner, we need to be able to add strings for inner type levels onto both the left and the right sides of the declarator. Currently, |
PointerVariableConstraint::mkString
has bugs in how it prints certain types. I guess they aren't affecting important use cases yet, but they might in the future, and in principle, we'd likemkString
to be able to correctly format arbitrary types. We can start with this as an umbrella issue and file more specific issues if it's helpful.int *x
gets printed asint * x
. Fixed by Insert itypes correctly for constant sized arrays #702._Ptr<int> *x
gets printed asint *_Ptr<int> x
. This is hard to trigger in the current 3C but might become more common if the "outer wild -> inner wild" constraints were removed, as described in Remove double-pointer "outer wild -> inner wild" constraints? #656.Some cases involving arrays will be fixed in mkString fixes (mostly moved from the multi-decl overhaul) #714.DeclRewriter::buildItypeDecl
to always usemkString
rather than getting the type from Clang (qtyToStr
, etc.) and then run the regression tests.One common bug is an extra space in a function return type likeI didn't look through all the test failures to see if there are other bugs.int * foo(void) : itype(_Ptr<int>)
, apparently coming from this code; this will be fixed in mkString fixes (mostly moved from the multi-decl overhaul) #714.int (*x)[10]
gets printed asint *[10] x
. I haven't been able to find an example that triggersmkString
on this case without modifying the code as in (4). However, there's a similar example without a name, where the only problem is missing parentheses around the*
in the output:mkString
writes wild pointer levels in reverse order (mixes up type qualifiers) #161)mkString
traverses type levels from outer to inner and prints wild pointer symbols*
directly toSs
in the order they are seen, so the outermost*
ends up on the left and the innermost*
on the right. It should be the other way around. One notable case in which this makes a difference is when the qualifiers on the different levels differ. Example:More generally, the logic in
PointerVariableConstraint::mkString
is very ad-hoc and could use a thorough re-think.The text was updated successfully, but these errors were encountered: