Mercurial > hg > CbC > CbC_gcc
comparison gcc/input.h @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 /* Declarations for variables relating to reading the source file. | 1 /* Declarations for variables relating to reading the source file. |
2 Used by parsers, lexical analyzers, and error message routines. | 2 Used by parsers, lexical analyzers, and error message routines. |
3 Copyright (C) 1993-2017 Free Software Foundation, Inc. | 3 Copyright (C) 1993-2018 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
8 the terms of the GNU General Public License as published by the Free | 8 the terms of the GNU General Public License as published by the Free |
32 /* The location for declarations in "<built-in>" */ | 32 /* The location for declarations in "<built-in>" */ |
33 #define BUILTINS_LOCATION ((source_location) 1) | 33 #define BUILTINS_LOCATION ((source_location) 1) |
34 | 34 |
35 /* line-map.c reserves RESERVED_LOCATION_COUNT to the user. Ensure | 35 /* line-map.c reserves RESERVED_LOCATION_COUNT to the user. Ensure |
36 both UNKNOWN_LOCATION and BUILTINS_LOCATION fit into that. */ | 36 both UNKNOWN_LOCATION and BUILTINS_LOCATION fit into that. */ |
37 extern char builtins_location_check[(BUILTINS_LOCATION | 37 STATIC_ASSERT (BUILTINS_LOCATION < RESERVED_LOCATION_COUNT); |
38 < RESERVED_LOCATION_COUNT) ? 1 : -1]; | |
39 | 38 |
40 extern bool is_location_from_builtin_token (source_location); | 39 extern bool is_location_from_builtin_token (source_location); |
41 extern expanded_location expand_location (source_location); | 40 extern expanded_location expand_location (source_location); |
42 extern const char *location_get_source_line (const char *file_path, int line, | 41 |
43 int *line_size); | 42 /* A class capturing the bounds of a buffer, to allow for run-time |
43 bounds-checking in a checked build. */ | |
44 | |
45 class char_span | |
46 { | |
47 public: | |
48 char_span (const char *ptr, size_t n_elts) : m_ptr (ptr), m_n_elts (n_elts) {} | |
49 | |
50 /* Test for a non-NULL pointer. */ | |
51 operator bool() const { return m_ptr; } | |
52 | |
53 /* Get length, not including any 0-terminator (which may not be, | |
54 in fact, present). */ | |
55 size_t length () const { return m_n_elts; } | |
56 | |
57 const char *get_buffer () const { return m_ptr; } | |
58 | |
59 char operator[] (int idx) const | |
60 { | |
61 gcc_assert (idx >= 0); | |
62 gcc_assert ((size_t)idx < m_n_elts); | |
63 return m_ptr[idx]; | |
64 } | |
65 | |
66 char_span subspan (int offset, int n_elts) const | |
67 { | |
68 gcc_assert (offset >= 0); | |
69 gcc_assert (offset < (int)m_n_elts); | |
70 gcc_assert (n_elts >= 0); | |
71 gcc_assert (offset + n_elts <= (int)m_n_elts); | |
72 return char_span (m_ptr + offset, n_elts); | |
73 } | |
74 | |
75 char *xstrdup () const | |
76 { | |
77 return ::xstrndup (m_ptr, m_n_elts); | |
78 } | |
79 | |
80 private: | |
81 const char *m_ptr; | |
82 size_t m_n_elts; | |
83 }; | |
84 | |
85 extern char_span location_get_source_line (const char *file_path, int line); | |
86 | |
44 extern bool location_missing_trailing_newline (const char *file_path); | 87 extern bool location_missing_trailing_newline (const char *file_path); |
45 extern expanded_location expand_location_to_spelling_point (source_location); | 88 extern expanded_location |
89 expand_location_to_spelling_point (source_location, | |
90 enum location_aspect aspect | |
91 = LOCATION_ASPECT_CARET); | |
46 extern source_location expansion_point_location_if_in_system_header (source_location); | 92 extern source_location expansion_point_location_if_in_system_header (source_location); |
47 extern source_location expansion_point_location (source_location); | 93 extern source_location expansion_point_location (source_location); |
48 | 94 |
49 /* Historically GCC used location_t, while cpp used source_location. | 95 /* Historically GCC used location_t, while cpp used source_location. |
50 This could be removed but it hardly seems worth the effort. */ | 96 This could be removed but it hardly seems worth the effort. */ |
71 that therefore needs to be extern "C" protected in C++. | 117 that therefore needs to be extern "C" protected in C++. |
72 | 118 |
73 Note that this function returns 1 if LOCATION belongs to a token | 119 Note that this function returns 1 if LOCATION belongs to a token |
74 that is part of a macro replacement-list defined in a system | 120 that is part of a macro replacement-list defined in a system |
75 header, but expanded in a non-system file. */ | 121 header, but expanded in a non-system file. */ |
76 #define in_system_header_at(LOC) \ | 122 |
77 (linemap_location_in_system_header_p (line_table, LOC)) | 123 static inline int |
78 /* Return a positive value if LOCATION is the locus of a token that | 124 in_system_header_at (location_t loc) |
79 comes from a macro expansion, O otherwise. */ | 125 { |
80 #define from_macro_expansion_at(LOC) \ | 126 return linemap_location_in_system_header_p (line_table, loc); |
81 ((linemap_location_from_macro_expansion_p (line_table, LOC))) | 127 } |
82 /* Return a positive value if LOCATION is the locus of a token that comes from | 128 |
83 a macro definition, O otherwise. This differs from from_macro_expansion_at | 129 /* Return true if LOCATION is the locus of a token that |
130 comes from a macro expansion, false otherwise. */ | |
131 | |
132 static inline bool | |
133 from_macro_expansion_at (location_t loc) | |
134 { | |
135 return linemap_location_from_macro_expansion_p (line_table, loc); | |
136 } | |
137 | |
138 /* Return true if LOCATION is the locus of a token that comes from | |
139 a macro definition, false otherwise. This differs from from_macro_expansion_at | |
84 in its treatment of macro arguments, for which this returns false. */ | 140 in its treatment of macro arguments, for which this returns false. */ |
85 #define from_macro_definition_at(LOC) \ | 141 |
86 ((linemap_location_from_macro_definition_p (line_table, LOC))) | 142 static inline bool |
143 from_macro_definition_at (location_t loc) | |
144 { | |
145 return linemap_location_from_macro_definition_p (line_table, loc); | |
146 } | |
87 | 147 |
88 static inline location_t | 148 static inline location_t |
89 get_pure_location (location_t loc) | 149 get_pure_location (location_t loc) |
90 { | 150 { |
91 return get_pure_location (line_table, loc); | 151 return get_pure_location (line_table, loc); |