Skip to content
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

Multi-decl overhaul (including inline struct fixes) #657

Merged
merged 66 commits into from
Nov 22, 2021

Conversation

mattmccutchen-cci
Copy link
Member

@mattmccutchen-cci mattmccutchen-cci commented Jul 29, 2021

As of 2021-07-29, this change still has a ways to go before it's ready for review, but I thought I was overdue to file a draft PR to make it easier to find, now that I'm pretty confident that the inline-struct-fixes branch is the one I'll be submitting. I'd welcome early feedback, though be aware that I'm already planning to redo some parts of the change and I'll likely rewrite the commit history, which would make previously added line-level review comments harder to access.

Completed and planned work for this PR:

Now that we automatically name them:

- When -alltypes is on, we no longer need to warn that the multi-decl
  may be rewritten incorrectly.

- When -alltypes is off, we no longer generate constraints to try to
  avoid the need to rewrite the multi-decl at all.

InlineStructDetector did one thing unrelated to its name: it constrained
all union fields wild. Move that logic to ProgramInfo::addVariable, make
the constraint reason message more specific, and update root_cause.c to
expect the new message.
The problem already affected several regression tests for more complex
cases (which expected the extra space), and we didn't seem to notice or
care. But now it is affecting every unchanged variable of that form in a
multi-decl that gets rewritten, and this broke several other regression
tests.
multi-decl rewriting splits them rather than losing them.

Fixes #531
except for a "declaration does not declare anything" compiler warning
that will be addressed by de-nesting the inline structs.
A fixup to "Get the correct form...".
declaration as if it were a definition.

Fixes #644.
The existing regression tests pass, but more testing is needed.
More are still needed.
Delete the test of "Unable to rewrite a typedef with multiple names"
from root_cause.c because that case no longer causes wildness. (I think
it makes sense to just delete the test.)
Now that this case works, add a few tests of it.
In the process, fix a bug that I found in the lookup of the type of an
unchanged typedef.
@kyleheadley
Copy link
Member

kyleheadley commented Oct 20, 2021

I'm still getting lots of errors from libtiff because a typedef struct name doesn't exist. They all relate to OJPEGState found in tif_ojpeg.c. But Olden is working now, thanks.

@mattmccutchen-cci
Copy link
Member Author

I'm still getting lots of errors from libtiff because a typedef struct name doesn't exist. They all relate to OJPEGState found in tif_ojpeg.c.

I added a fix to this PR. Thanks again for the report!

Copy link
Collaborator

@john-h-kastner john-h-kastner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with everything in this PR. It looks like you're planning to add regression tests for the benchmark issues that Kyle found. Provided that happens and no more such issues are found, I think this can be merged.

@kyleheadley
Copy link
Member

kyleheadley commented Oct 21, 2021

Ping me when you've merged this branch with the main branch (even prior to the final squash-merge). There are a few regression test fails that kept me on branch next-without-range-bounds. I've merged this into it with no problems so the regressions should be easy to fix. But I'd like to move on to this more official version when it's ready.

@kyleheadley
Copy link
Member

kyleheadley commented Oct 25, 2021

Benchmark run from action branch upgrade_filter. All passing.

That branch is under review but should mean that all regression tests pass and all benchmark failures are the result of bounds problems or have GitHub issues filed for them already.

@mattmccutchen-cci
Copy link
Member Author

Last call for review of this PR. I think the only notable changes I made since John's approval are:

  • Add regression tests for the two bugs that Kyle found via the benchmark tests.
  • Use PrintingPolicy instead of temporarily mutating a VarDecl (d3de950)
  • Formatting (clang-format and manual re-wrapping of comments)
  • Update comments, including citing newly filed issues.
  • Convert some "TODO: Can X happen?" comments and fatal assertions to "placeholder" non-fatal assertions.
  • Factor out duplicate code from the multivardecls.c and itypes_for_extern.c regression tests (0bbfe7f).

The regression tests passed on my machine, and the benchmark tests are running now. If the benchmark tests pass, I'm ready to merge this PR.

@john-h-kastner
Copy link
Collaborator

The regression tests passed on my machine, and the benchmark tests are running now. If the benchmark tests pass, I'm ready to merge this PR.

Results look good to me. I'm happy to see this merged.

@mattmccutchen-cci mattmccutchen-cci linked an issue Nov 22, 2021 that may be closed by this pull request
@mattmccutchen-cci mattmccutchen-cci merged commit abd7a00 into main Nov 22, 2021
mattmccutchen-cci added a commit that referenced this pull request Dec 1, 2021
With this change, all callers of emitSupplementaryDeclarations want it
to add a newline at the beginning and not the end, so we can remove the
extra newline there.

- Change getNextComma back to getNextCommaOrSemicolon as it was before
  PR #657.

- Some other comment fixes and minor refactorings. Notably: in
  emitSupplementaryDeclarations, change the InsertTextAfter call to the
  equivalent InsertText to try to avoid confusion with
  InsertTextAfterToken.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment