selftest.h: add class line_table_test
commit7ec388edd62f8da8b806b166fa548d9779420131
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Aug 2016 16:22:10 +0000 (18 16:22 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 18 Aug 2016 16:22:10 +0000 (18 16:22 +0000)
tree88147dd9aecf18036124b1ad90c384efc1d40d24
parent360e911de1a1b94191dfe579747cf4f134170407
selftest.h: add class line_table_test

input.c has a fixture class for running each selftest with a fresh
line_table, and logic for looping over various interesting line_table
test cases.

This patch exposes the above in selftest.h so that such
location-handling tests can be written in other files, renaming the
class from temp_line_table to line_table_test.

Also, the patch moves the stored line table ptr from being a member of
the test class to being a global GC-root, to avoid it being collected
if the GC runs during such a test.

gcc/ChangeLog:
* input.c (saved_line_table): New global.
(class selftest::temp_line_table): Rename to line_table_test and
move declaration to selftest.h, and drop field m_old_line_table.
(selftest::temp_line_table::temp_line_table): Rename ctor to...
(selftest::line_table_test::line_table_test): ...this.  Add a
default ctor.  Store current value of line_table within
saved_line_table.
(selftest::temp_line_table::~temp_line_table): Rename dtor to...
(selftest::line_table_test::~line_table_test): ...this, and
restore line_table from the saved_line_table, rather than
m_old_line_table.
(selftest::test_accessing_ordinary_linemaps): Update for above
renaming.
(selftest::test_lexer): Likewise.
(struct selftest::lexer_test): Likewise.
(selftest::lexer_test::lexer_test): Likewise.
(selftest::input_c_tests): Move the looping over test cases from
here into...
(selftest::for_each_line_table_case): New function.
* input.h (saved_line_table): New decl.
* selftest.h (struct selftest::line_table_case): New forward decl.
(class selftest::line_table_test): New class, moved here from
selftest::temp_line_table in input.c, and renamed.
(selftest::for_each_line_table_case): New decl.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239580 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/input.c
gcc/input.h
gcc/selftest.h