aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.h
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2018-11-08 14:55:54 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2018-11-08 14:55:54 +0000
commit212755ff9137bcd3975e02f4936c96bdb7eaf709 (patch)
tree3c5fb53164804c22395d16b8ad4db4ae78afe627 /gcc/cgraph.h
parent1c8badf66bec4e0ff73ae24bf4f8cabbef8c137a (diff)
downloadgcc-212755ff9137bcd3975e02f4936c96bdb7eaf709.zip
gcc-212755ff9137bcd3975e02f4936c96bdb7eaf709.tar.gz
gcc-212755ff9137bcd3975e02f4936c96bdb7eaf709.tar.bz2
cgraph: add selftest::symbol_table_test
This patch adds a selftest fixture for overriding the "symtab" global, so that selftests involving symtab nodes can be isolated from each other: each selftest can have its own symbol_table instance. In particular, this ensures that nodes can have a predictable "order" and thus predictable dump names within selftests. gcc/ChangeLog: * cgraph.c: Include "selftest.h". (saved_symtab): New variable. (selftest::symbol_table_test::symbol_table_test): New ctor. (selftest::symbol_table_test::~symbol_table_test): New dtor. (selftest::test_symbol_table_test): New test. (selftest::cgraph_c_tests): New. * cgraph.h (saved_symtab): New decl. (selftest::symbol_table_test): New class. * selftest-run-tests.c (selftest::run_tests): Call selftest::cgraph_c_tests. * selftest.h (selftest::cgraph_c_tests): New decl. From-SVN: r265915
Diffstat (limited to 'gcc/cgraph.h')
-rw-r--r--gcc/cgraph.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index c13d798..0215522 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -3353,4 +3353,27 @@ xstrdup_for_dump (const char *transient_str)
return ggc_strdup (transient_str);
}
+extern GTY(()) symbol_table *saved_symtab;
+
+#if CHECKING_P
+
+namespace selftest {
+
+/* An RAII-style class for use in selftests for temporarily using a different
+ symbol_table, so that such tests can be isolated from each other. */
+
+class symbol_table_test
+{
+ public:
+ /* Constructor. Override "symtab". */
+ symbol_table_test ();
+
+ /* Destructor. Restore the saved_symtab. */
+ ~symbol_table_test ();
+};
+
+} // namespace selftest
+
+#endif /* CHECKING_P */
+
#endif /* GCC_CGRAPH_H */