Bug fix for CAst translation. When translating if statements, the system has a case where code to detect dead blocks mistakenly triggers even though the needed CFG edge will be added later. The if processing code now tells the CFG that the block is not dead, which prevents it from being prematurely removed.

This commit is contained in:
Julian Dolby 2017-01-16 21:57:12 -05:00
parent 8d04766aa9
commit 46dddcfb66
1 changed files with 2 additions and 1 deletions

View File

@ -3809,7 +3809,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
}
@Override
protected boolean visitLabelStmt(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) {
protected boolean visitLabelStmt(CAstNode n, WalkContext c, CAstVisitor<WalkContext> visitor) {
WalkContext context = c;
if (!context.getControlFlow().getSourceNodes(n).isEmpty()) {
context.cfg().newBlock(true);
@ -3849,6 +3849,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
falseB = context.cfg().getCurrentBlock();
CAstNode f = n.getChild(2);
context.cfg().deadBlocks.remove(falseB);
visitor.visit(f, context, visitor);
if (isExpr)
context.cfg().addInstruction(new AssignInstruction(context.cfg().currentInstruction, c.getValue(n), c.getValue(f)));