annotate gcc/input.h @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Declarations for variables relating to reading the source file.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 Used by parsers, lexical analyzers, and error message routines.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
3 Copyright (C) 1993-2020 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #ifndef GCC_INPUT_H
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #define GCC_INPUT_H
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #include "line-map.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
26 extern GTY(()) class line_maps *line_table;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
27 extern GTY(()) class line_maps *saved_line_table;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 /* A value which will never be used to represent a real location. */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
30 #define UNKNOWN_LOCATION ((location_t) 0)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 /* The location for declarations in "<built-in>" */
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
33 #define BUILTINS_LOCATION ((location_t) 1)
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
34
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
35 /* line-map.c reserves RESERVED_LOCATION_COUNT to the user. Ensure
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
36 both UNKNOWN_LOCATION and BUILTINS_LOCATION fit into that. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
37 STATIC_ASSERT (BUILTINS_LOCATION < RESERVED_LOCATION_COUNT);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
39 extern bool is_location_from_builtin_token (location_t);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
40 extern expanded_location expand_location (location_t);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
41 extern int location_compute_display_column (expanded_location);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
42
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
43 /* A class capturing the bounds of a buffer, to allow for run-time
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
44 bounds-checking in a checked build. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
45
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
46 class char_span
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
47 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
48 public:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
49 char_span (const char *ptr, size_t n_elts) : m_ptr (ptr), m_n_elts (n_elts) {}
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
50
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
51 /* Test for a non-NULL pointer. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
52 operator bool() const { return m_ptr; }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
53
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
54 /* Get length, not including any 0-terminator (which may not be,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
55 in fact, present). */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
56 size_t length () const { return m_n_elts; }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
57
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
58 const char *get_buffer () const { return m_ptr; }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
59
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
60 char operator[] (int idx) const
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
61 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
62 gcc_assert (idx >= 0);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
63 gcc_assert ((size_t)idx < m_n_elts);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
64 return m_ptr[idx];
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
65 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
66
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
67 char_span subspan (int offset, int n_elts) const
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
68 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
69 gcc_assert (offset >= 0);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
70 gcc_assert (offset < (int)m_n_elts);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
71 gcc_assert (n_elts >= 0);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
72 gcc_assert (offset + n_elts <= (int)m_n_elts);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
73 return char_span (m_ptr + offset, n_elts);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
74 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
75
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
76 char *xstrdup () const
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
77 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
78 return ::xstrndup (m_ptr, m_n_elts);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
79 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
80
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
81 private:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
82 const char *m_ptr;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
83 size_t m_n_elts;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
84 };
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
85
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
86 extern char_span location_get_source_line (const char *file_path, int line);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
87
111
kono
parents: 67
diff changeset
88 extern bool location_missing_trailing_newline (const char *file_path);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
89 extern expanded_location
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
90 expand_location_to_spelling_point (location_t,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
91 enum location_aspect aspect
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
92 = LOCATION_ASPECT_CARET);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
93 extern location_t expansion_point_location_if_in_system_header (location_t);
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
94 extern location_t expansion_point_location (location_t);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 extern location_t input_location;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 #define LOCATION_FILE(LOC) ((expand_location (LOC)).file)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 #define LOCATION_LINE(LOC) ((expand_location (LOC)).line)
111
kono
parents: 67
diff changeset
100 #define LOCATION_COLUMN(LOC)((expand_location (LOC)).column)
kono
parents: 67
diff changeset
101 #define LOCATION_LOCUS(LOC) \
kono
parents: 67
diff changeset
102 ((IS_ADHOC_LOC (LOC)) ? get_location_from_adhoc_loc (line_table, LOC) \
kono
parents: 67
diff changeset
103 : (LOC))
kono
parents: 67
diff changeset
104 #define LOCATION_BLOCK(LOC) \
kono
parents: 67
diff changeset
105 ((tree) ((IS_ADHOC_LOC (LOC)) ? get_data_from_adhoc_loc (line_table, (LOC)) \
kono
parents: 67
diff changeset
106 : NULL))
kono
parents: 67
diff changeset
107 #define RESERVED_LOCATION_P(LOC) \
kono
parents: 67
diff changeset
108 (LOCATION_LOCUS (LOC) < RESERVED_LOCATION_COUNT)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
111
kono
parents: 67
diff changeset
110 /* Return a positive value if LOCATION is the locus of a token that is
kono
parents: 67
diff changeset
111 located in a system header, O otherwise. It returns 1 if LOCATION
kono
parents: 67
diff changeset
112 is the locus of a token that is located in a system header, and 2
kono
parents: 67
diff changeset
113 if LOCATION is the locus of a token located in a C system header
kono
parents: 67
diff changeset
114 that therefore needs to be extern "C" protected in C++.
kono
parents: 67
diff changeset
115
kono
parents: 67
diff changeset
116 Note that this function returns 1 if LOCATION belongs to a token
kono
parents: 67
diff changeset
117 that is part of a macro replacement-list defined in a system
kono
parents: 67
diff changeset
118 header, but expanded in a non-system file. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
119
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
120 static inline int
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
121 in_system_header_at (location_t loc)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
122 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
123 return linemap_location_in_system_header_p (line_table, loc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
124 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
125
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
126 /* Return true if LOCATION is the locus of a token that
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
127 comes from a macro expansion, false otherwise. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
128
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
129 static inline bool
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
130 from_macro_expansion_at (location_t loc)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
131 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
132 return linemap_location_from_macro_expansion_p (line_table, loc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
133 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
134
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
135 /* Return true if LOCATION is the locus of a token that comes from
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
136 a macro definition, false otherwise. This differs from from_macro_expansion_at
111
kono
parents: 67
diff changeset
137 in its treatment of macro arguments, for which this returns false. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
138
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
139 static inline bool
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
140 from_macro_definition_at (location_t loc)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
141 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
142 return linemap_location_from_macro_definition_p (line_table, loc);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
143 }
111
kono
parents: 67
diff changeset
144
kono
parents: 67
diff changeset
145 static inline location_t
kono
parents: 67
diff changeset
146 get_pure_location (location_t loc)
kono
parents: 67
diff changeset
147 {
kono
parents: 67
diff changeset
148 return get_pure_location (line_table, loc);
kono
parents: 67
diff changeset
149 }
kono
parents: 67
diff changeset
150
kono
parents: 67
diff changeset
151 /* Get the start of any range encoded within location LOC. */
kono
parents: 67
diff changeset
152
kono
parents: 67
diff changeset
153 static inline location_t
kono
parents: 67
diff changeset
154 get_start (location_t loc)
kono
parents: 67
diff changeset
155 {
kono
parents: 67
diff changeset
156 return get_range_from_loc (line_table, loc).m_start;
kono
parents: 67
diff changeset
157 }
kono
parents: 67
diff changeset
158
kono
parents: 67
diff changeset
159 /* Get the endpoint of any range encoded within location LOC. */
kono
parents: 67
diff changeset
160
kono
parents: 67
diff changeset
161 static inline location_t
kono
parents: 67
diff changeset
162 get_finish (location_t loc)
kono
parents: 67
diff changeset
163 {
kono
parents: 67
diff changeset
164 return get_range_from_loc (line_table, loc).m_finish;
kono
parents: 67
diff changeset
165 }
kono
parents: 67
diff changeset
166
kono
parents: 67
diff changeset
167 extern location_t make_location (location_t caret,
kono
parents: 67
diff changeset
168 location_t start, location_t finish);
kono
parents: 67
diff changeset
169 extern location_t make_location (location_t caret, source_range src_range);
kono
parents: 67
diff changeset
170
kono
parents: 67
diff changeset
171 void dump_line_table_statistics (void);
kono
parents: 67
diff changeset
172
kono
parents: 67
diff changeset
173 void dump_location_info (FILE *stream);
kono
parents: 67
diff changeset
174
kono
parents: 67
diff changeset
175 void diagnostics_file_cache_fini (void);
kono
parents: 67
diff changeset
176
kono
parents: 67
diff changeset
177 void diagnostics_file_cache_forcibly_evict_file (const char *file_path);
kono
parents: 67
diff changeset
178
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
179 class GTY(()) string_concat
111
kono
parents: 67
diff changeset
180 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
181 public:
111
kono
parents: 67
diff changeset
182 string_concat (int num, location_t *locs);
kono
parents: 67
diff changeset
183
kono
parents: 67
diff changeset
184 int m_num;
kono
parents: 67
diff changeset
185 location_t * GTY ((atomic)) m_locs;
kono
parents: 67
diff changeset
186 };
kono
parents: 67
diff changeset
187
kono
parents: 67
diff changeset
188 struct location_hash : int_hash <location_t, UNKNOWN_LOCATION> { };
kono
parents: 67
diff changeset
189
kono
parents: 67
diff changeset
190 class GTY(()) string_concat_db
kono
parents: 67
diff changeset
191 {
kono
parents: 67
diff changeset
192 public:
kono
parents: 67
diff changeset
193 string_concat_db ();
kono
parents: 67
diff changeset
194 void record_string_concatenation (int num, location_t *locs);
kono
parents: 67
diff changeset
195
kono
parents: 67
diff changeset
196 bool get_string_concatenation (location_t loc,
kono
parents: 67
diff changeset
197 int *out_num,
kono
parents: 67
diff changeset
198 location_t **out_locs);
kono
parents: 67
diff changeset
199
kono
parents: 67
diff changeset
200 private:
kono
parents: 67
diff changeset
201 static location_t get_key_loc (location_t loc);
kono
parents: 67
diff changeset
202
kono
parents: 67
diff changeset
203 /* For the fields to be private, we must grant access to the
kono
parents: 67
diff changeset
204 generated code in gtype-desc.c. */
kono
parents: 67
diff changeset
205
kono
parents: 67
diff changeset
206 friend void ::gt_ggc_mx_string_concat_db (void *x_p);
kono
parents: 67
diff changeset
207 friend void ::gt_pch_nx_string_concat_db (void *x_p);
kono
parents: 67
diff changeset
208 friend void ::gt_pch_p_16string_concat_db (void *this_obj, void *x_p,
kono
parents: 67
diff changeset
209 gt_pointer_operator op,
kono
parents: 67
diff changeset
210 void *cookie);
kono
parents: 67
diff changeset
211
kono
parents: 67
diff changeset
212 hash_map <location_hash, string_concat *> *m_table;
kono
parents: 67
diff changeset
213 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 #endif