GCC with patches for OS216
Revision | 718930c0c8f8d25d185cb65e38c79a19458b6628 (tree) |
---|---|
Zeit | 2020-01-15 10:47:21 |
Autor | David Malcolm <dmalcolm@redh...> |
Commiter | David Malcolm |
analyzer: ensure .dot output is valid for an empty BB
This patch fixes an issue with the output of -fdump-analyzer-supergraph
on BBs with no statements, where the resulting files were unreadable by
dot e.g.:
Error: syntax error in line 1
... <TABLE BORDER="0"></TABLE> ...
in label of node node_10
gcc/analyzer/ChangeLog:
* supergraph.cc (supernode::dump_dot): Ensure that the TABLE
element has at least one TR.
gcc/testsuite/ChangeLog:
* gcc.dg/analyzer/dot-output.c: Add test coverage for a BB with
no statements.
@@ -1,5 +1,10 @@ | ||
1 | 1 | 2020-01-14 David Malcolm <dmalcolm@redhat.com> |
2 | 2 | |
3 | + * supergraph.cc (supernode::dump_dot): Ensure that the TABLE | |
4 | + element has at least one TR. | |
5 | + | |
6 | +2020-01-14 David Malcolm <dmalcolm@redhat.com> | |
7 | + | |
3 | 8 | PR analyzer/58237 |
4 | 9 | * engine.cc (leak_stmt_finder::find_stmt): Use get_pure_location |
5 | 10 | when comparing against UNKNOWN_LOCATION. |
@@ -450,6 +450,8 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const | ||
450 | 450 | pp_string (pp, "<TABLE BORDER=\"0\">"); |
451 | 451 | pp_write_text_to_stream (pp); |
452 | 452 | |
453 | + bool had_row = false; | |
454 | + | |
453 | 455 | if (m_returning_call) |
454 | 456 | { |
455 | 457 | gv->begin_tr (); |
@@ -464,18 +466,22 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const | ||
464 | 466 | if (args.m_node_annotator) |
465 | 467 | args.m_node_annotator->add_stmt_annotations (gv, m_returning_call); |
466 | 468 | pp_newline (pp); |
469 | + | |
470 | + had_row = true; | |
467 | 471 | } |
468 | 472 | |
469 | 473 | if (entry_p ()) |
470 | 474 | { |
471 | 475 | pp_string (pp, "<TR><TD>ENTRY</TD></TR>"); |
472 | 476 | pp_newline (pp); |
477 | + had_row = true; | |
473 | 478 | } |
474 | 479 | |
475 | 480 | if (return_p ()) |
476 | 481 | { |
477 | 482 | pp_string (pp, "<TR><TD>EXIT</TD></TR>"); |
478 | 483 | pp_newline (pp); |
484 | + had_row = true; | |
479 | 485 | } |
480 | 486 | |
481 | 487 | /* Phi nodes. */ |
@@ -492,6 +498,7 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const | ||
492 | 498 | args.m_node_annotator->add_stmt_annotations (gv, stmt); |
493 | 499 | |
494 | 500 | pp_newline (pp); |
501 | + had_row = true; | |
495 | 502 | } |
496 | 503 | |
497 | 504 | /* Statements. */ |
@@ -508,6 +515,15 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const | ||
508 | 515 | args.m_node_annotator->add_stmt_annotations (gv, stmt); |
509 | 516 | |
510 | 517 | pp_newline (pp); |
518 | + had_row = true; | |
519 | + } | |
520 | + | |
521 | + /* Graphviz requires a TABLE element to have at least one TR | |
522 | + (and each TR to have at least one TD). */ | |
523 | + if (!had_row) | |
524 | + { | |
525 | + pp_string (pp, "<TR><TD>(empty)</TD></TR>"); | |
526 | + pp_newline (pp); | |
511 | 527 | } |
512 | 528 | |
513 | 529 | pp_string (pp, "</TABLE>>];\n\n"); |
@@ -1,5 +1,10 @@ | ||
1 | 1 | 2020-01-14 David Malcolm <dmalcolm@redhat.com> |
2 | 2 | |
3 | + * gcc.dg/analyzer/dot-output.c: Add test coverage for a BB with | |
4 | + no statements. | |
5 | + | |
6 | +2020-01-14 David Malcolm <dmalcolm@redhat.com> | |
7 | + | |
3 | 8 | PR analyzer/58237 |
4 | 9 | * gcc.dg/analyzer/file-paths-1.c: New test. |
5 | 10 |
@@ -27,6 +27,22 @@ int *test (int *buf, int n, int *out) | ||
27 | 27 | return result; |
28 | 28 | } |
29 | 29 | |
30 | +/* Test that we can generate valid .dot files given a BB with no | |
31 | + statements. */ | |
32 | +extern int func (); | |
33 | +int test_2 (void) | |
34 | +{ | |
35 | + int c1; | |
36 | + do | |
37 | + { | |
38 | + c1 = func (); | |
39 | + if (c1 == '\0') | |
40 | + break; | |
41 | + } | |
42 | + while (c1); | |
43 | + return c1; | |
44 | +} | |
45 | + | |
30 | 46 | /* { dg-final { dg-check-dot "dot-output.c.callgraph.dot" } } */ |
31 | 47 | /* { dg-final { dg-check-dot "dot-output.c.eg.dot" } } */ |
32 | 48 | /* { dg-final { dg-check-dot "dot-output.c.state-purge.dot" } } */ |