GCC Middle and Back End API Reference
binary_op_rich_location Class Reference

#include <gcc-rich-location.h>

Inheritance diagram for binary_op_rich_location:
Collaboration diagram for binary_op_rich_location:

Public Member Functions

 binary_op_rich_location (const op_location_t &loc, tree arg0, tree arg1, bool show_types)
 
void add_expr (tree expr, range_label *label)
 
void maybe_add_expr (tree t, range_label *label)
 
void add_fixit_misspelled_id (location_t misspelled_token_loc, tree hint_id)
 
bool add_location_if_nearby (location_t loc, bool restrict_to_current_line_spans=true, const range_label *label=NULL)
 
void add_fixit_insert_formatted (const char *content, location_t insertion_point, location_t indent)
 

Static Private Member Functions

static bool use_operator_loc_p (const op_location_t &loc, tree arg0, tree arg1)
 

Private Attributes

maybe_range_label_for_tree_type_mismatch m_label_for_arg0
 
maybe_range_label_for_tree_type_mismatch m_label_for_arg1
 

Detailed Description

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.   

Constructor & Destructor Documentation

◆ binary_op_rich_location()

binary_op_rich_location::binary_op_rich_location ( const op_location_t & loc,
tree arg0,
tree arg1,
bool show_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().

Member Function Documentation

◆ add_expr()

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_fixit_insert_formatted()

void gcc_rich_location::add_fixit_insert_formatted ( const char * content,
location_t insertion_point,
location_t indent )
inherited
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().

◆ add_fixit_misspelled_id()

void gcc_rich_location::add_fixit_misspelled_id ( location_t misspelled_token_loc,
tree hint_id )
inherited
Add a fixit hint suggesting replacing the range at MISSPELLED_TOKEN_LOC
with the identifier HINT_ID.   

References gcc_assert, ggc_alloc(), IDENTIFIER_POINTER, and TREE_CODE.

◆ add_location_if_nearby()

bool gcc_rich_location::add_location_if_nearby ( location_t loc,
bool restrict_to_current_line_spans = true,
const range_label * label = NULL )
inherited
If LOC is within the spans of lines that will already be printed for
this gcc_rich_location, then add it as a secondary location and return true.

Otherwise return false.   

References ggc_alloc(), and global_dc.

◆ maybe_add_expr()

void gcc_rich_location::maybe_add_expr ( tree t,
range_label * label )
inherited
If T is an expression, add a range for it to the rich_location,
using LABEL if non-NULL.  

References gcc_rich_location::add_expr(), and EXPR_P.

Referenced by binary_op_rich_location().

◆ use_operator_loc_p()

bool binary_op_rich_location::use_operator_loc_p ( const op_location_t & loc,
tree arg0,
tree arg1 )
staticprivate
Determine if binary_op_rich_location's ctor should attempt to make
a 3-location rich_location (the location of the operator and of
the 2 arguments), or fall back to a 1-location rich_location showing
just the combined location of the operation as a whole.   

References EXPR_HAS_LOCATION, ggc_alloc(), op_location_t::m_combined_loc, op_location_t::m_operator_loc, and UNKNOWN_LOCATION.

Referenced by binary_op_rich_location().

Field Documentation

◆ m_label_for_arg0

maybe_range_label_for_tree_type_mismatch binary_op_rich_location::m_label_for_arg0
private

Referenced by binary_op_rich_location().

◆ m_label_for_arg1

maybe_range_label_for_tree_type_mismatch binary_op_rich_location::m_label_for_arg1
private

Referenced by binary_op_rich_location().


The documentation for this class was generated from the following files: