-
Notifications
You must be signed in to change notification settings - Fork 284
Fixes use of wrong identifier when pretty printing bitfield types #1676
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
Fixes use of wrong identifier when pretty printing bitfield types #1676
Conversation
|
Fix looks good; any chance of a regression test to go with it? Preferably the one / a version of the one submitted in the original ticket. |
|
I might be responsible for a some of this code. May I ask for a slightly bigger refactoring to use pointer_offset_bits instead? All those |
|
@tautschnig I'm not sure how you'd want to use pointer_offset_bits here. Also, what would you want to replace the get_string calls with? |
|
|
@martin-cs I didn't find a test category that really fit for the test I was doing (though if there is one I'll happy to change this), so I made my own @tautschnig I'm not entirely sure if I understood you correctly, is this what you had in mind? |
fc95904 to
2b424a1
Compare
tautschnig
left a comment
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.
Thank you for all this additional work! Some more fixes are necessary, though.
regression/Makefile
Outdated
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'd just add it to the goto-instrument directory.
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.
done
src/ansi-c/type2name.cpp
Outdated
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 there a strong reason not to use a function at file scope?
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.
Not really. I can do that if you prefer; I just put it in the function scope because I wasn't expecting to use it outside of the function and I don't need to pass parameters this way.
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.
My reasons for preferring the file-scoped function: 1) Consistency: we don't do it elsewhere. 2) I'm not sure how well doxygen can cope with it. 3) The function calls do not make clear what is captured, thus making the code harder to read.
None of this is a blocker, but readability is a very important aspect.
src/ansi-c/type2name.cpp
Outdated
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.
No, that would yield "symbol". Use id2string(t.size().get(ID_identifier))
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.
done
src/ansi-c/type2name.cpp
Outdated
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.
nil would actually be a valid name! component_name.empty() would be the error you are looking for.
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.
done
2b424a1 to
06a353a
Compare
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.
Nit pick: no new line at end-of-file
|
(reminder: both AppVeyor and travis report failures for known issues that are unrelated to this PR) |
chrisr-diffblue
left a comment
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.
Looks good to me, but could you just add the missing new-line, then I'll merge.
06a353a to
defda7b
Compare
The width of a bitfield is indicated with
ID_width. Old version oftype2namewas usingID_sizeinstead, which (silently) threw away the information about the width of a bitfield in the pretty printed type.As a side note, I'm not sure it's such a good idea for the get* type functions to fail silently.