A subclass of rich_location for showing problems with binary operations.
If enough location information is available, the ctor will make a
3-location rich_location of the form:
arg_0 op arg_1
~~~~~ ^~ ~~~~~
| |
| arg1 type
arg0 type
labelling the types of the arguments if SHOW_TYPES is true.
Otherwise, it will fall back to a 1-location rich_location using the
compound location within LOC:
arg_0 op arg_1
~~~~~~^~~~~~~~
for which we can't label the types.
binary_op_rich_location's ctor.
If use_operator_loc_p (LOC, ARG0, ARG1), then attempt to make a 3-location
rich_location of the form:
arg_0 op arg_1
~~~~~ ^~ ~~~~~
| |
| arg1 type
arg0 type
labelling the types of the arguments if SHOW_TYPES is true.
Otherwise, make a 1-location rich_location using the compound
location within LOC:
arg_0 op arg_1
~~~~~~^~~~~~~~
for which we can't label the types.
References ggc_alloc(), m_label_for_arg0, m_label_for_arg1, op_location_t::m_operator_loc, gcc_rich_location::maybe_add_expr(), NULL, and use_operator_loc_p().
void gcc_rich_location::add_expr |
( |
tree | expr, |
|
|
range_label * | label ) |
|
inherited |
Implementation of gcc_rich_location class
Copyright (C) 2014-2024 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
Add a range to the rich_location, covering expression EXPR,
using LABEL if non-NULL.
References CAN_HAVE_RANGE_P, EXPR_LOCATION, gcc_assert, and ggc_alloc().
Referenced by gcc_rich_location::maybe_add_expr().
Add a fix-it hint suggesting the insertion of CONTENT before
INSERTION_POINT.
Attempt to handle formatting: if INSERTION_POINT is the first thing on
its line, and INDENT is sufficiently sane, then add CONTENT on its own
line, using the indentation of INDENT.
Otherwise, add CONTENT directly before INSERTION_POINT.
For example, adding "CONTENT;" with the closing brace as the insertion
point and "INDENT;" as the indentation point:
if ()
{
INDENT;
}
would lead to:
if ()
{
INDENT;
CONTENT;
}
but adding it to:
if () {INDENT;}
would lead to:
if () {INDENT;CONTENT;}
References diagnostic_context::get_file_cache(), get_start(), ggc_alloc(), global_dc, LOCATION_COLUMN, pp_formatted_text(), pp_newline(), pp_space, pp_string(), and use_new_line().