Now cover a corner case where we have a tile composed by two successors,
which we entirely dominate, and a common postdominator which we don't
postdominate (basically we miss a superfluos dummy here).
In this case, include in the tile `then` and `else` bodies, but do not
include in the tile the common postdom (it will be taken care by someone
else more higher in the CFG).
When the `--enforce-no-safety-checks` flag is passed during the
enforcing, we avoid emitting the inlined `function_dispatcher` and we
emit instead a call to an `indirect_handle` disposable call created on
the fly to respect the ABI information on the callsite.
Before this commit, when GlobalDeclCreationAction needed to emit
literals for initialization of global variables, it did it using
custom code.
This was not working properly, an in some cases it emitted short
literals which are not allowed in C.
Hence the generated C code that was impossible to recompile without
syntax errors.
This commit fixes this problem, using the getLiteralFromConstant method
of StmtBuilder.
In order to do this, we need to make the StmtBuilder available inside
the GlobalDeclCreationAction, which is not a very clean design.
However, we are already planning to merge the GlobalDeclCreationAction
and the StmtBuilder class, so this issue will be taken care of in the
future.
The simplifyLastContinue beautifier was too ambitious and there were
many corner cases that it handled in the wrong way, leaving the AST in a
shape that could not be emitted, or breaking the semantics.
This commit severely weakens the simplifyLastContinue, so that it does
not break things anymore.
It is now able to match only continue statements that are in the last
position of a sequence node which is the body of a ScsNode.
This obviously is not enough but allows revng-c to pass all the
decompilation tests.
In the future we will need to extend simplifyLastContinue to match more
cases in a sane way.
This commit moves the matching of short-circuited ifs before the stage
of flipping if nodes with emtpy then.
This is necessary because the if short-circuiting may produce if nodes
with empty then, which can be then flipped by the next beautify step.
Before this commit, we couldn't handle simplification of atomic
sequences in cases of switches that had a default.
The reason is that if you remove a case from a switch that has a
default, you are implicitly saying that the case that you remove will be
handled by the default, hence you're changing the semantics.
Now we handle this case by not removing the case, substituting it with a
SwitchBreak node instead.
This commit fixes a bug causing iterator invalidation in
`markUnexpectedPCAsInlined`.
Before this commit we were iterating over a graph while adding nodes,
which could cause iteration invalidation on realloc.
Added assertions that checks that, once, during combing, we start
analyzing a path deriving from an inlined edge, we only encounter nodes
which do not require combing (all predecessors have been visited), or
that are reachable only from inlined edges (this is usually the case for
edges bringing to the `UnexpectedPC` basic block).
When we perform the tagging of the inlined edges in occurence of, we
also perform a duplication of the `UnexpectedPC` basic block.
In this way, we can avoid, walking through inlined edges during the
combing, since we now that all the nodes following an inlined edges will
be dominated by the corresponding conditional bringing to it.
Update the `Body` pointer inside an `ScsNode` when processing the
`copyASTNodesFrom` method, in order to update the `Body` pointer of
nested collapsed nodes.
Remove from the `RegionCFGTreeImpl.h` header the helper functions used
for the first AST simplification that are now part of the
`GenerateAst.h` header.