aboutsummaryrefslogtreecommitdiff
path: root/libcpp/line-map.c
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-07-11 16:02:20 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-07-11 16:02:20 +0000
commitb73690a459fb63c57b4da8176b8e9acbd5eb0a66 (patch)
tree62b14ee9ae7d25092b5db8ab48c08fccc2eab016 /libcpp/line-map.c
parent675f4c6bd6adaa3bed418f162c78d4a9d4c72dd7 (diff)
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@238213 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp/line-map.c')
-rw-r--r--libcpp/line-map.c12
1 files changed, 0 insertions, 12 deletions
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index 8dea0d381c5..141af9d2cde 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -31,18 +31,6 @@ along with this program; see the file COPYING3. If not see
disabled). */
const unsigned int LINE_MAP_MAX_COLUMN_NUMBER = (1U << 12);
-/* Do not pack ranges if locations get higher than this.
- If you change this, update:
- gcc.dg/plugin/location_overflow_plugin.c
- gcc.dg/plugin/location-overflow-test-*.c. */
-const source_location LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES = 0x50000000;
-
-/* Do not track column numbers if locations get higher than this.
- If you change this, update:
- gcc.dg/plugin/location_overflow_plugin.c
- gcc.dg/plugin/location-overflow-test-*.c. */
-const source_location LINE_MAP_MAX_LOCATION_WITH_COLS = 0x60000000;
-
/* Highest possible source location encoded within an ordinary or
macro map. */
const source_location LINE_MAP_MAX_SOURCE_LOCATION = 0x70000000;