]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/gcc-rich-location.c
fix PR68343: disable fuse-*.c tests for isl 0.14 or earlier
[thirdparty/gcc.git] / gcc / gcc-rich-location.c
1 /* Implementation of gcc_rich_location class
2 Copyright (C) 2014-2016 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
19
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "tm.h"
24 #include "rtl.h"
25 #include "hash-set.h"
26 #include "machmode.h"
27 #include "vec.h"
28 #include "double-int.h"
29 #include "input.h"
30 #include "alias.h"
31 #include "symtab.h"
32 #include "wide-int.h"
33 #include "inchash.h"
34 #include "tree-core.h"
35 #include "tree.h"
36 #include "diagnostic-core.h"
37 #include "gcc-rich-location.h"
38 #include "print-tree.h"
39 #include "pretty-print.h"
40 #include "intl.h"
41 #include "cpplib.h"
42 #include "diagnostic.h"
43
44 /* Extract any source range information from EXPR and write it
45 to *R. */
46
47 static bool
48 get_range_for_expr (tree expr, location_range *r)
49 {
50 if (EXPR_HAS_RANGE (expr))
51 {
52 source_range sr = EXPR_LOCATION_RANGE (expr);
53
54 /* Do we have meaningful data? */
55 if (sr.m_start && sr.m_finish)
56 {
57 r->m_start = expand_location (sr.m_start);
58 r->m_finish = expand_location (sr.m_finish);
59 return true;
60 }
61 }
62
63 return false;
64 }
65
66 /* Add a range to the rich_location, covering expression EXPR. */
67
68 void
69 gcc_rich_location::add_expr (tree expr)
70 {
71 gcc_assert (expr);
72
73 location_range r;
74 r.m_show_caret_p = false;
75 if (get_range_for_expr (expr, &r))
76 add_range (&r);
77 }
78
79 /* If T is an expression, add a range for it to the rich_location. */
80
81 void
82 gcc_rich_location::maybe_add_expr (tree t)
83 {
84 if (EXPR_P (t))
85 add_expr (t);
86 }