This is the mail archive of the gcc-cvs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

r238213 - in /trunk: gcc/ChangeLog gcc/input.c ...


Author: dmalcolm
Date: Mon Jul 11 16:02:20 2016
New Revision: 238213

URL: https://gcc.gnu.org/viewcvs?rev=238213&root=gcc&view=rev
Log:
input.c: add lexing selftests and a test matrix for line_table states

This patch adds explicit testing of lexing a source file,
generalizing this (and the test of ordinary line maps) over
a 2-dimensional test matrix covering:

  (1) line_table->default_range_bits: some frontends use a non-zero value
  and others use zero

  (2) the fallback modes within line-map.c: there are various threshold
  values for source_location/location_t beyond line-map.c changes
  behavior (disabling of the range-packing optimization, disabling
  of column-tracking).  We exercise these by starting the line_table
  at interesting values at or near these thresholds.

This helps ensures that location data works in all of these states,
and that (I hope) we don't have lingering bugs relating to the
transition between line_table states.

gcc/ChangeLog:
	* input.c: Include cpplib.h.
	(selftest::temp_source_file): New class.
	(selftest::temp_source_file::temp_source_file): New ctor.
	(selftest::temp_source_file::~temp_source_file): New dtor.
	(selftest::should_have_column_data_p): New function.
	(selftest::test_should_have_column_data_p): New function.
	(selftest::temp_line_table): New class.
	(selftest::temp_line_table::temp_line_table): New ctor.
	(selftest::temp_line_table::~temp_line_table): New dtor.
	(selftest::test_accessing_ordinary_linemaps): Add case_ param; use
	it to create a temp_line_table.
	(selftest::assert_loceq): Only verify LOCATION_COLUMN for
	locations that are known to have column data.
	(selftest::line_table_case): New struct.
	(selftest::test_reading_source_line): Move tempfile handling
	to class temp_source_file.
	(ASSERT_TOKEN_AS_TEXT_EQ): New macro.
	(selftest::assert_token_loc_eq): New function.
	(ASSERT_TOKEN_LOC_EQ): New macro.
	(selftest::test_lexer): New function.
	(selftest::boundary_locations): New array.
	(selftest::input_c_tests): Call test_should_have_column_data_p.
	Loop over a test matrix of interesting values of location and
	default_range_bits, calling test_lexer on each case in the matrix.
	Move call to test_accessing_ordinary_linemaps into the matrix.
	* selftest.h (ASSERT_EQ): Reimplement in terms of...
	(ASSERT_EQ_AT): New macro.

gcc/testsuite/ChangeLog:
	* gcc.dg/plugin/location_overflow_plugin.c (plugin_init): Avoid
	hardcoding the values of LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES
	and LINE_MAP_MAX_LOCATION_WITH_COLS.

libcpp/ChangeLog:
	* include/line-map.h (LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES):
	Move here from line-map.c.
	(LINE_MAP_MAX_LOCATION_WITH_COLS): Likewise.
	* line-map.c (LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES): Move from
	here to line-map.h.
	(LINE_MAP_MAX_LOCATION_WITH_COLS): Likewise.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/input.c
    trunk/gcc/selftest.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c
    trunk/libcpp/ChangeLog
    trunk/libcpp/include/line-map.h
    trunk/libcpp/line-map.c


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]