diff --git a/gcc/diagnostics/paths-output.cc b/gcc/diagnostics/paths-output.cc index 2c97bf40679e..e39bfcbf10b2 100644 --- a/gcc/diagnostics/paths-output.cc +++ b/gcc/diagnostics/paths-output.cc @@ -455,7 +455,7 @@ struct event_range const location_t prev_loc = prev_event->get_location (); expanded_location prev_exploc = linemap_client_expand_location_to_spelling_point - (line_table, prev_loc, LOCATION_ASPECT_CARET); + (line_table, prev_loc, location_aspect::caret); /* The destination in-edge's line number has to be <= the source out-edge's line number (if any). */ if (prev_exploc.line >= m_line) @@ -514,7 +514,8 @@ struct event_range { expanded_location exploc = linemap_client_expand_location_to_spelling_point - (line_table, initial_event.get_location (), LOCATION_ASPECT_CARET); + (line_table, initial_event.get_location (), + location_aspect::caret); per_source_line_info &source_line_info = get_per_source_line_info (exploc.line); @@ -556,7 +557,7 @@ struct event_range with respect to the link-printing code. */ expanded_location exploc = linemap_client_expand_location_to_spelling_point - (line_table, new_ev.get_location (), LOCATION_ASPECT_CARET); + (line_table, new_ev.get_location (), location_aspect::caret); per_source_line_info &source_line_info = get_per_source_line_info (exploc.line); const event *prev_event = nullptr; @@ -607,7 +608,7 @@ struct event_range { expanded_location exploc = linemap_client_expand_location_to_spelling_point - (line_table, initial_loc, LOCATION_ASPECT_CARET); + (line_table, initial_loc, location_aspect::caret); if (exploc.file != LOCATION_FILE (dc.m_last_location)) { diagnostics::location_print_policy loc_policy (text_output); @@ -665,7 +666,7 @@ struct event_range { expanded_location exploc = linemap_client_expand_location_to_spelling_point - (line_table, initial_loc, LOCATION_ASPECT_CARET); + (line_table, initial_loc, location_aspect::caret); if (exploc.file != LOCATION_FILE (dc.m_last_location)) { diagnostics::location_print_policy loc_policy (dc); diff --git a/gcc/diagnostics/source-printing.cc b/gcc/diagnostics/source-printing.cc index aeda9ad54e53..e98df9ad6fb3 100644 --- a/gcc/diagnostics/source-printing.cc +++ b/gcc/diagnostics/source-printing.cc @@ -213,7 +213,7 @@ class exploc_with_display_col : public expanded_location { /* m_display_col is now the final column of the byte. If escaping has happened, we may want the first column instead. */ - if (aspect != LOCATION_ASPECT_FINISH) + if (aspect != location_aspect::finish) { expanded_location prev_exploc (exploc); prev_exploc.column--; @@ -1260,14 +1260,14 @@ make_range (diagnostics::file_cache &fc, = {"", end_line, end_col, nullptr, false}; return layout_range (exploc_with_display_col (fc, start_exploc, def_policy (), - LOCATION_ASPECT_START), + location_aspect::start), exploc_with_display_col (fc, finish_exploc, def_policy (), - LOCATION_ASPECT_FINISH), + location_aspect::finish), SHOW_RANGE_WITHOUT_CARET, exploc_with_display_col (fc, start_exploc, def_policy (), - LOCATION_ASPECT_CARET), + location_aspect::caret), 0, nullptr); } @@ -1758,7 +1758,7 @@ layout::layout (const diagnostics::source_print_policy &source_policy, m_primary_loc (richloc.get_range (0)->m_loc), m_exploc (m_file_cache, richloc.get_expanded_location (0), m_char_policy, - LOCATION_ASPECT_CARET), + location_aspect::caret), m_layout_ranges (richloc.get_num_locations ()), m_fixit_hints (richloc.get_num_fixit_hints ()), m_line_spans (1 + richloc.get_num_locations ()), @@ -1819,13 +1819,13 @@ layout::maybe_add_location_range (const location_range *loc_range, /* Expand the various locations. */ expanded_location start = linemap_client_expand_location_to_spelling_point - (m_line_table, src_range.m_start, LOCATION_ASPECT_START); + (m_line_table, src_range.m_start, location_aspect::start); expanded_location finish = linemap_client_expand_location_to_spelling_point - (m_line_table, src_range.m_finish, LOCATION_ASPECT_FINISH); + (m_line_table, src_range.m_finish, location_aspect::finish); expanded_location caret = linemap_client_expand_location_to_spelling_point - (m_line_table, loc_range->m_loc, LOCATION_ASPECT_CARET); + (m_line_table, loc_range->m_loc, location_aspect::caret); /* If any part of the range isn't in the same file as the primary location of this diagnostic, ignore the range. */ @@ -1858,14 +1858,14 @@ layout::maybe_add_location_range (const location_range *loc_range, but it may require further sanitization. */ layout_range ri (exploc_with_display_col (m_file_cache, start, m_char_policy, - LOCATION_ASPECT_START), + location_aspect::start), exploc_with_display_col (m_file_cache, finish, m_char_policy, - LOCATION_ASPECT_FINISH), + location_aspect::finish), range_display_kind, exploc_with_display_col (m_file_cache, caret, m_char_policy, - LOCATION_ASPECT_CARET), + location_aspect::caret), original_idx, loc_range->m_label); /* If we have a range that finishes before it starts (perhaps diff --git a/gcc/input.cc b/gcc/input.cc index b9a553954401..aad983947114 100644 --- a/gcc/input.cc +++ b/gcc/input.cc @@ -112,16 +112,16 @@ expand_location_1 (const line_maps *set, default: gcc_unreachable (); /* Fall through. */ - case LOCATION_ASPECT_CARET: + case location_aspect::caret: break; - case LOCATION_ASPECT_START: + case location_aspect::start: { location_t start = get_start (loc); if (start != loc) return expand_location_1 (set, start, expansion_point_p, aspect); } break; - case LOCATION_ASPECT_FINISH: + case location_aspect::finish: { location_t finish = get_finish (loc); if (finish != loc) @@ -148,9 +148,9 @@ get_source_text_between (diagnostics::file_cache &fc, location_t start, location_t end) { expanded_location expstart - = expand_location_to_spelling_point (start, LOCATION_ASPECT_START); + = expand_location_to_spelling_point (start, location_aspect::start); expanded_location expend - = expand_location_to_spelling_point (end, LOCATION_ASPECT_FINISH); + = expand_location_to_spelling_point (end, location_aspect::finish); /* If the locations are in different files or the end comes before the start, give up and return nothing. */ @@ -258,7 +258,7 @@ expanded_location expand_location (location_t loc) { return expand_location_1 (line_table, loc, /*expansion_point_p=*/true, - LOCATION_ASPECT_CARET); + location_aspect::caret); } /* Expand the source location LOC into a human readable location. If @@ -911,10 +911,10 @@ get_substring_ranges_for_loc (cpp_reader *pfile, expanded_location start = expand_location_to_spelling_point (src_range.m_start, - LOCATION_ASPECT_START); + location_aspect::start); expanded_location finish = expand_location_to_spelling_point (src_range.m_finish, - LOCATION_ASPECT_FINISH); + location_aspect::finish); if (start.file != finish.file) return "range endpoints are in different files"; if (start.line != finish.line) diff --git a/gcc/input.h b/gcc/input.h index eeef290c1db8..4d2d77415922 100644 --- a/gcc/input.h +++ b/gcc/input.h @@ -79,7 +79,7 @@ get_source_text_between (diagnostics::file_cache &, location_t, location_t); extern expanded_location expand_location_to_spelling_point (location_t, enum location_aspect aspect - = LOCATION_ASPECT_CARET); + = location_aspect::caret); extern location_t expansion_point_location_if_in_system_header (location_t); extern location_t expansion_point_location (location_t); diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h index 21a59af22369..9bcf4d0c8078 100644 --- a/libcpp/include/line-map.h +++ b/libcpp/include/line-map.h @@ -1459,11 +1459,11 @@ void line_table_dump (FILE *, const line_maps *, /* An enum for distinguishing the various parts within a location_t. */ -enum location_aspect +enum class location_aspect { - LOCATION_ASPECT_CARET, - LOCATION_ASPECT_START, - LOCATION_ASPECT_FINISH + caret, + start, + finish }; /* The rich_location class requires a way to expand location_t instances. diff --git a/libcpp/line-map.cc b/libcpp/line-map.cc index 33701b519e1f..2875bf2092b7 100644 --- a/libcpp/line-map.cc +++ b/libcpp/line-map.cc @@ -2326,7 +2326,7 @@ rich_location::get_expanded_location (unsigned int idx) const { m_expanded_location = linemap_client_expand_location_to_spelling_point - (m_line_table, get_loc (0), LOCATION_ASPECT_CARET); + (m_line_table, get_loc (0), location_aspect::caret); if (m_column_override) m_expanded_location.column = m_column_override; m_have_expanded_location = true; @@ -2336,7 +2336,7 @@ rich_location::get_expanded_location (unsigned int idx) const } else return linemap_client_expand_location_to_spelling_point - (m_line_table, get_loc (idx), LOCATION_ASPECT_CARET); + (m_line_table, get_loc (idx), location_aspect::caret); } /* Set the column of the primary location, with 0 meaning @@ -2611,11 +2611,11 @@ rich_location::maybe_add_fixit (location_t start, expanded_location exploc_start = linemap_client_expand_location_to_spelling_point (m_line_table, start, - LOCATION_ASPECT_START); + location_aspect::start); expanded_location exploc_next_loc = linemap_client_expand_location_to_spelling_point (m_line_table, next_loc, - LOCATION_ASPECT_START); + location_aspect::start); /* They must be within the same file... */ if (exploc_start.file != exploc_next_loc.file) { @@ -2717,7 +2717,7 @@ fixit_hint::affects_line_p (const line_maps *set, expanded_location exploc_start = linemap_client_expand_location_to_spelling_point (set, m_start, - LOCATION_ASPECT_START); + location_aspect::start); if (file != exploc_start.file) return false; if (line < exploc_start.line) @@ -2725,7 +2725,7 @@ fixit_hint::affects_line_p (const line_maps *set, expanded_location exploc_next_loc = linemap_client_expand_location_to_spelling_point (set, m_next_loc, - LOCATION_ASPECT_START); + location_aspect::start); if (file != exploc_next_loc.file) return false; if (line > exploc_next_loc.line)