• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GCC with patches for OS216


Commit MetaInfo

Revision718930c0c8f8d25d185cb65e38c79a19458b6628 (tree)
Zeit2020-01-15 10:47:21
AutorDavid Malcolm <dmalcolm@redh...>
CommiterDavid Malcolm

Log Message

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.

Ändern Zusammenfassung

Diff

--- a/gcc/analyzer/ChangeLog
+++ b/gcc/analyzer/ChangeLog
@@ -1,5 +1,10 @@
11 2020-01-14 David Malcolm <dmalcolm@redhat.com>
22
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+
38 PR analyzer/58237
49 * engine.cc (leak_stmt_finder::find_stmt): Use get_pure_location
510 when comparing against UNKNOWN_LOCATION.
--- a/gcc/analyzer/supergraph.cc
+++ b/gcc/analyzer/supergraph.cc
@@ -450,6 +450,8 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const
450450 pp_string (pp, "<TABLE BORDER=\"0\">");
451451 pp_write_text_to_stream (pp);
452452
453+ bool had_row = false;
454+
453455 if (m_returning_call)
454456 {
455457 gv->begin_tr ();
@@ -464,18 +466,22 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const
464466 if (args.m_node_annotator)
465467 args.m_node_annotator->add_stmt_annotations (gv, m_returning_call);
466468 pp_newline (pp);
469+
470+ had_row = true;
467471 }
468472
469473 if (entry_p ())
470474 {
471475 pp_string (pp, "<TR><TD>ENTRY</TD></TR>");
472476 pp_newline (pp);
477+ had_row = true;
473478 }
474479
475480 if (return_p ())
476481 {
477482 pp_string (pp, "<TR><TD>EXIT</TD></TR>");
478483 pp_newline (pp);
484+ had_row = true;
479485 }
480486
481487 /* Phi nodes. */
@@ -492,6 +498,7 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const
492498 args.m_node_annotator->add_stmt_annotations (gv, stmt);
493499
494500 pp_newline (pp);
501+ had_row = true;
495502 }
496503
497504 /* Statements. */
@@ -508,6 +515,15 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const
508515 args.m_node_annotator->add_stmt_annotations (gv, stmt);
509516
510517 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);
511527 }
512528
513529 pp_string (pp, "</TABLE>>];\n\n");
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
11 2020-01-14 David Malcolm <dmalcolm@redhat.com>
22
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+
38 PR analyzer/58237
49 * gcc.dg/analyzer/file-paths-1.c: New test.
510
--- a/gcc/testsuite/gcc.dg/analyzer/dot-output.c
+++ b/gcc/testsuite/gcc.dg/analyzer/dot-output.c
@@ -27,6 +27,22 @@ int *test (int *buf, int n, int *out)
2727 return result;
2828 }
2929
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+
3046 /* { dg-final { dg-check-dot "dot-output.c.callgraph.dot" } } */
3147 /* { dg-final { dg-check-dot "dot-output.c.eg.dot" } } */
3248 /* { dg-final { dg-check-dot "dot-output.c.state-purge.dot" } } */