1*38fd1498Szrj /* Implementation of gcc_rich_location class 2*38fd1498Szrj Copyright (C) 2014-2018 Free Software Foundation, Inc. 3*38fd1498Szrj 4*38fd1498Szrj This file is part of GCC. 5*38fd1498Szrj 6*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it under 7*38fd1498Szrj the terms of the GNU General Public License as published by the Free 8*38fd1498Szrj Software Foundation; either version 3, or (at your option) any later 9*38fd1498Szrj version. 10*38fd1498Szrj 11*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT ANY 12*38fd1498Szrj WARRANTY; without even the implied warranty of MERCHANTABILITY or 13*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14*38fd1498Szrj for more details. 15*38fd1498Szrj 16*38fd1498Szrj You should have received a copy of the GNU General Public License 17*38fd1498Szrj along with GCC; see the file COPYING3. If not see 18*38fd1498Szrj <http://www.gnu.org/licenses/>. */ 19*38fd1498Szrj 20*38fd1498Szrj #include "config.h" 21*38fd1498Szrj #include "system.h" 22*38fd1498Szrj #include "coretypes.h" 23*38fd1498Szrj #include "tm.h" 24*38fd1498Szrj #include "rtl.h" 25*38fd1498Szrj #include "hash-set.h" 26*38fd1498Szrj #include "vec.h" 27*38fd1498Szrj #include "input.h" 28*38fd1498Szrj #include "alias.h" 29*38fd1498Szrj #include "symtab.h" 30*38fd1498Szrj #include "inchash.h" 31*38fd1498Szrj #include "tree-core.h" 32*38fd1498Szrj #include "tree.h" 33*38fd1498Szrj #include "diagnostic-core.h" 34*38fd1498Szrj #include "gcc-rich-location.h" 35*38fd1498Szrj #include "print-tree.h" 36*38fd1498Szrj #include "pretty-print.h" 37*38fd1498Szrj #include "intl.h" 38*38fd1498Szrj #include "cpplib.h" 39*38fd1498Szrj #include "diagnostic.h" 40*38fd1498Szrj 41*38fd1498Szrj /* Add a range to the rich_location, covering expression EXPR. */ 42*38fd1498Szrj 43*38fd1498Szrj void add_expr(tree expr)44*38fd1498Szrjgcc_rich_location::add_expr (tree expr) 45*38fd1498Szrj { 46*38fd1498Szrj gcc_assert (expr); 47*38fd1498Szrj 48*38fd1498Szrj if (CAN_HAVE_RANGE_P (expr)) 49*38fd1498Szrj add_range (EXPR_LOCATION (expr), false); 50*38fd1498Szrj } 51*38fd1498Szrj 52*38fd1498Szrj /* If T is an expression, add a range for it to the rich_location. */ 53*38fd1498Szrj 54*38fd1498Szrj void maybe_add_expr(tree t)55*38fd1498Szrjgcc_rich_location::maybe_add_expr (tree t) 56*38fd1498Szrj { 57*38fd1498Szrj if (EXPR_P (t)) 58*38fd1498Szrj add_expr (t); 59*38fd1498Szrj } 60*38fd1498Szrj 61*38fd1498Szrj /* Add a fixit hint suggesting replacing the range at MISSPELLED_TOKEN_LOC 62*38fd1498Szrj with the identifier HINT_ID. */ 63*38fd1498Szrj 64*38fd1498Szrj void add_fixit_misspelled_id(location_t misspelled_token_loc,tree hint_id)65*38fd1498Szrjgcc_rich_location::add_fixit_misspelled_id (location_t misspelled_token_loc, 66*38fd1498Szrj tree hint_id) 67*38fd1498Szrj { 68*38fd1498Szrj gcc_assert (TREE_CODE (hint_id) == IDENTIFIER_NODE); 69*38fd1498Szrj 70*38fd1498Szrj add_fixit_replace (misspelled_token_loc, IDENTIFIER_POINTER (hint_id)); 71*38fd1498Szrj } 72