Decompiler: Improve support of in-place C operations #8635
+159
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #7283
These two commits improve the support of in-place operations by
LOADed, then modified using an in-place operation, and finallySTOREd to the same location.Especially the second commit is quite hacky, since
STOREoperations were never meant to be passed toPrintC::emitInplaceOp, and adding support for it adds some extra complexity. The ugliest hack is caused by theLOADin the sequence however, since thatLOADneeds to not be emitted when the loaded value was only used for the in-place operation. This basically requires detecting the same pattern twice - once from theSTOREperspective, and once from theLOADperspective. Also signalling that nothing has been emitted to the other parts of the C-genereration code is done in a very hacky way by abusing thepending_braceprint modifier and then checking for that modifier in several places.I'm afraid especially the second commit disqualifies this PR from ever being merged, but since it seems to work decently well, I hope it'll be useful to some people running their own builds of Ghidra.