Emit 'else if' without nesting. No functional change intended. (#2944)
Instead of:
if (a) {
x;
} else {
if (b) {
y;
} else {
if (c) {
z;
} else {
w;
}
}
}
Emit:
if (a) {
x;
} else if (b) {
y;
} else if (c) {
z;
} else {
w;
}
This commit is contained in:
parent
267c6f6dce
commit
1a6378291a
|
|
@ -812,11 +812,19 @@ public:
|
|||
if (!nodep->branchPred().unknown()) puts(")");
|
||||
puts(") {\n");
|
||||
iterateAndNextNull(nodep->ifsp());
|
||||
if (nodep->elsesp()) {
|
||||
puts("} else {\n");
|
||||
iterateAndNextNull(nodep->elsesp());
|
||||
puts("}");
|
||||
if (!nodep->elsesp()) {
|
||||
puts("\n");
|
||||
} else {
|
||||
if (VN_IS(nodep->elsesp(), NodeIf) && !nodep->elsesp()->nextp()) {
|
||||
puts(" else ");
|
||||
iterateAndNextNull(nodep->elsesp());
|
||||
} else {
|
||||
puts(" else {\n");
|
||||
iterateAndNextNull(nodep->elsesp());
|
||||
puts("}\n");
|
||||
}
|
||||
}
|
||||
puts("}\n");
|
||||
}
|
||||
virtual void visit(AstExprStmt* nodep) override {
|
||||
// GCC allows compound statements in expressions, but this is not standard.
|
||||
|
|
|
|||
Loading…
Reference in New Issue