History

gcc-9.1

Wolfgang Thaller committed 7 years ago

Commit 6fbf4221 parent ec13cc931387 files · +2442466 −1054331Browse files

Showing the changes to gcc/libcpp/include (5 of 31387 files). Show all

Unified · Split

5 files
  1. gcc/libcpp/include/cpp-id-data.h +0 −82
  2. gcc/libcpp/include/cpplib.h +238 −150
  3. gcc/libcpp/include/line-map.h +310 −210
  4. gcc/libcpp/include/mkdeps.h +1 −1
  5. gcc/libcpp/include/symtab.h +1 −1
gcc/libcpp/include/cpp-id-data.h+0−82
@@ -1,82 +0,0 @@
1−/* Structures that hang off cpp_identifier, for PCH.
2− Copyright (C) 1986-2018 Free Software Foundation, Inc.
3−
4−This program is free software; you can redistribute it and/or modify it
5−under the terms of the GNU General Public License as published by the
6−Free Software Foundation; either version 3, or (at your option) any
7−later version.
8−
9−This program is distributed in the hope that it will be useful,
10−but WITHOUT ANY WARRANTY; without even the implied warranty of
11−MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12−GNU General Public License for more details.
13−
14−You should have received a copy of the GNU General Public License
15−along with this program; see the file COPYING3. If not see
16−<http://www.gnu.org/licenses/>. */
17−
18−#include "cpplib.h"
19−
20−#if !defined (HAVE_UCHAR) && !defined (IN_GCC)
21−typedef unsigned char uchar;
22−#endif
23−
24−#define UC (const unsigned char *) /* Intended use: UC"string" */
25−
26−/* Chained list of answers to an assertion. */
27−struct GTY(()) answer {
28− struct answer *next;
29− unsigned int count;
30− cpp_token GTY ((length ("%h.count"))) first[1];
31−};
32−
33−/* Each macro definition is recorded in a cpp_macro structure.
34− Variadic macros cannot occur with traditional cpp. */
35−struct GTY(()) cpp_macro {
36− /* Parameters, if any. If parameter names use extended identifiers,
37− the original spelling of those identifiers, not the canonical
38− UTF-8 spelling, goes here. */
39− cpp_hashnode ** GTY ((nested_ptr (union tree_node,
40− "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
41− "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"),
42− length ("%h.paramc")))
43− params;
44−
45− /* Replacement tokens (ISO) or replacement text (traditional). See
46− comment at top of cpptrad.c for how traditional function-like
47− macros are encoded. */
48− union cpp_macro_u
49− {
50− cpp_token * GTY ((tag ("0"), length ("%0.count"))) tokens;
51− const unsigned char * GTY ((tag ("1"))) text;
52− } GTY ((desc ("%1.traditional"))) exp;
53−
54− /* Definition line number. */
55− source_location line;
56−
57− /* Number of tokens in expansion, or bytes for traditional macros. */
58− unsigned int count;
59−
60− /* Number of parameters. */
61− unsigned short paramc;
62−
63− /* If a function-like macro. */
64− unsigned int fun_like : 1;
65−
66− /* If a variadic macro. */
67− unsigned int variadic : 1;
68−
69− /* If macro defined in system header. */
70− unsigned int syshdr : 1;
71−
72− /* Nonzero if it has been expanded or had its existence tested. */
73− unsigned int used : 1;
74−
75− /* Indicate which field of 'exp' is in use. */
76− unsigned int traditional : 1;
77−
78− /* Indicate whether the tokens include extra CPP_PASTE tokens at the
79− end to track invalid redefinitions with consecutive CPP_PASTE
80− tokens. */
81− unsigned int extra_tokens : 1;
82−};
gcc/libcpp/include/cpplib.h+238−150
@@ -1,5 +1,5 @@
11 /* Definitions for CPP library.
2− Copyright (C) 1995-2018 Free Software Foundation, Inc.
2+ Copyright (C) 1995-2019 Free Software Foundation, Inc.
33 Written by Per Bothner, 1994-95.
44
55 This program is free software; you can redistribute it and/or modify it
@@ -36,7 +36,6 @@ typedef struct cpp_macro cpp_macro; · 30 unmodified lines
3636 typedef struct cpp_callbacks cpp_callbacks;
3737 typedef struct cpp_dir cpp_dir;
3838
39−struct answer;
4039 struct _cpp_file;
4140
4241 /* The first three groups, apart from '=', can appear in preprocessor
@@ -168,8 +167,9 @@ enum cpp_ttype · 125 unmodified lines
168167 #undef TK
169168
170169 /* C language kind, used when calling cpp_create_reader. */
171−enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, CLK_GNUC17,
170+enum c_lang {CLK_GNUC89 = 0, CLK_GNUC99, CLK_GNUC11, CLK_GNUC17, CLK_GNUC2X,
172171 CLK_STDC89, CLK_STDC94, CLK_STDC99, CLK_STDC11, CLK_STDC17,
172+ CLK_STDC2X,
173173 CLK_GNUCXX, CLK_CXX98, CLK_GNUCXX11, CLK_CXX11,
174174 CLK_GNUCXX14, CLK_CXX14, CLK_GNUCXX17, CLK_CXX17,
175175 CLK_GNUCXX2A, CLK_CXX2A, CLK_ASM};
@@ -240,8 +240,10 @@ struct GTY(()) cpp_identifier { · 64 unmodified lines
240240 /* A preprocessing token. This has been carefully packed and should
241241 occupy 16 bytes on 32-bit hosts and 24 bytes on 64-bit hosts. */
242242 struct GTY(()) cpp_token {
243− source_location src_loc; /* Location of first char of token,
244− together with range of full token. */
243+
244+ /* Location of first char of token, together with range of full token. */
245+ location_t src_loc;
246+
245247 ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT; /* token type */
246248 unsigned short flags; /* flags - see above */
247249
@@ -550,6 +552,59 @@ struct cpp_options · 302 unmodified lines
550552 bool canonical_system_headers;
551553 };
552554
555+/* Diagnostic levels. To get a diagnostic without associating a
556+ position in the translation unit with it, use cpp_error_with_line
557+ with a line number of zero. */
558+
559+enum cpp_diagnostic_level {
560+ /* Warning, an error with -Werror. */
561+ CPP_DL_WARNING = 0,
562+ /* Same as CPP_DL_WARNING, except it is not suppressed in system headers. */
563+ CPP_DL_WARNING_SYSHDR,
564+ /* Warning, an error with -pedantic-errors or -Werror. */
565+ CPP_DL_PEDWARN,
566+ /* An error. */
567+ CPP_DL_ERROR,
568+ /* An internal consistency check failed. Prints "internal error: ",
569+ otherwise the same as CPP_DL_ERROR. */
570+ CPP_DL_ICE,
571+ /* An informative note following a warning. */
572+ CPP_DL_NOTE,
573+ /* A fatal error. */
574+ CPP_DL_FATAL
575+};
576+
577+/* Warning reason codes. Use a reason code of CPP_W_NONE for unclassified
578+ warnings and diagnostics that are not warnings. */
579+
580+enum cpp_warning_reason {
581+ CPP_W_NONE = 0,
582+ CPP_W_DEPRECATED,
583+ CPP_W_COMMENTS,
584+ CPP_W_MISSING_INCLUDE_DIRS,
585+ CPP_W_TRIGRAPHS,
586+ CPP_W_MULTICHAR,
587+ CPP_W_TRADITIONAL,
588+ CPP_W_LONG_LONG,
589+ CPP_W_ENDIF_LABELS,
590+ CPP_W_NUM_SIGN_CHANGE,
591+ CPP_W_VARIADIC_MACROS,
592+ CPP_W_BUILTIN_MACRO_REDEFINED,
593+ CPP_W_DOLLARS,
594+ CPP_W_UNDEF,
595+ CPP_W_UNUSED_MACROS,
596+ CPP_W_CXX_OPERATOR_NAMES,
597+ CPP_W_NORMALIZE,
598+ CPP_W_INVALID_PCH,
599+ CPP_W_WARNING_DIRECTIVE,
600+ CPP_W_LITERAL_SUFFIX,
601+ CPP_W_DATE_TIME,
602+ CPP_W_PEDANTIC,
603+ CPP_W_C90_C99_COMPAT,
604+ CPP_W_CXX11_COMPAT,
605+ CPP_W_EXPANSION_TO_DEFINED
606+};
607+
553608 /* Callback for header lookup for HEADER, which is the name of a
554609 source file. It is used as a method of last resort to find headers
555610 that are not otherwise found during the normal include processing.
@@ -571,12 +626,12 @@ struct cpp_callbacks · 15 unmodified lines
571626 void (*file_change) (cpp_reader *, const line_map_ordinary *);
572627
573628 void (*dir_change) (cpp_reader *, const char *);
574− void (*include) (cpp_reader *, source_location, const unsigned char *,
629+ void (*include) (cpp_reader *, location_t, const unsigned char *,
575630 const char *, int, const cpp_token **);
576− void (*define) (cpp_reader *, source_location, cpp_hashnode *);
577− void (*undef) (cpp_reader *, source_location, cpp_hashnode *);
578− void (*ident) (cpp_reader *, source_location, const cpp_string *);
579− void (*def_pragma) (cpp_reader *, source_location);
631+ void (*define) (cpp_reader *, location_t, cpp_hashnode *);
632+ void (*undef) (cpp_reader *, location_t, cpp_hashnode *);
633+ void (*ident) (cpp_reader *, location_t, const cpp_string *);
634+ void (*def_pragma) (cpp_reader *, location_t);
580635 int (*valid_pch) (cpp_reader *, const char *, int);
581636 void (*read_pch) (cpp_reader *, const char *, int, const char *);
582637 missing_header_cb missing_header;
@@ -587,26 +642,29 @@ struct cpp_callbacks · 4 unmodified lines
587642
588643 /* Called to emit a diagnostic. This callback receives the
589644 translated message. */
590− bool (*error) (cpp_reader *, int, int, rich_location *,
591− const char *, va_list *)
645+ bool (*diagnostic) (cpp_reader *,
646+ enum cpp_diagnostic_level,
647+ enum cpp_warning_reason,
648+ rich_location *,
649+ const char *, va_list *)
592650 ATTRIBUTE_FPTR_PRINTF(5,0);
593651
594652 /* Callbacks for when a macro is expanded, or tested (whether
595653 defined or not at the time) in #ifdef, #ifndef or "defined". */
596− void (*used_define) (cpp_reader *, source_location, cpp_hashnode *);
597− void (*used_undef) (cpp_reader *, source_location, cpp_hashnode *);
654+ void (*used_define) (cpp_reader *, location_t, cpp_hashnode *);
655+ void (*used_undef) (cpp_reader *, location_t, cpp_hashnode *);
598656 /* Called before #define and #undef or other macro definition
599657 changes are processed. */
600658 void (*before_define) (cpp_reader *);
601659 /* Called whenever a macro is expanded or tested.
602660 Second argument is the location of the start of the current expansion. */
603− void (*used) (cpp_reader *, source_location, cpp_hashnode *);
661+ void (*used) (cpp_reader *, location_t, cpp_hashnode *);
604662
605663 /* Callback to identify whether an attribute exists. */
606664 int (*has_attribute) (cpp_reader *);
607665
608− /* Callback that can change a user builtin into normal macro. */
609− bool (*user_builtin_macro) (cpp_reader *, cpp_hashnode *);
666+ /* Callback that can change a user lazy into normal macro. */
667+ void (*user_lazy_macro) (cpp_reader *, cpp_macro *, unsigned);
610668
611669 /* Callback to parse SOURCE_DATE_EPOCH from environment. */
612670 time_t (*get_source_date_epoch) (cpp_reader *);
@@ -620,7 +678,7 @@ struct cpp_callbacks · 7 unmodified lines
620678 The content contains the opening slash-star (or slash-slash),
621679 and for C-style comments contains the closing star-slash. For
622680 C++-style comments it does not include the terminating newline. */
623− void (*comment) (cpp_reader *, source_location, const unsigned char *,
681+ void (*comment) (cpp_reader *, location_t, const unsigned char *,
624682 size_t);
625683
626684 /* Callback for filename remapping in __FILE__ and __BASE_FILE__ macro
@@ -671,14 +729,81 @@ struct cpp_dir · 44 unmodified lines
671729 dev_t dev;
672730 };
673731
674−/* The structure of a node in the hash table. The hash table has
675− entries for all identifiers: either macros defined by #define
676− commands (type NT_MACRO), assertions created with #assert
677− (NT_ASSERTION), or neither of the above (NT_VOID). Builtin macros
678− like __LINE__ are flagged NODE_BUILTIN. Poisoned identifiers are
679− flagged NODE_POISONED. NODE_OPERATOR (C++ only) indicates an
680− identifier that behaves like an operator such as "xor".
681− NODE_DIAGNOSTIC is for speed in lex_token: it indicates a
732+/* The kind of the cpp_macro. */
733+enum cpp_macro_kind {
734+ cmk_macro, /* An ISO macro (token expansion). */
735+ cmk_assert, /* An assertion. */
736+ cmk_traditional /* A traditional macro (text expansion). */
737+};
738+
739+/* Each macro definition is recorded in a cpp_macro structure.
740+ Variadic macros cannot occur with traditional cpp. */
741+struct GTY(()) cpp_macro {
742+ union cpp_parm_u
743+ {
744+ /* Parameters, if any. If parameter names use extended identifiers,
745+ the original spelling of those identifiers, not the canonical
746+ UTF-8 spelling, goes here. */
747+ cpp_hashnode ** GTY ((tag ("false"),
748+ nested_ptr (union tree_node,
749+ "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
750+ "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL"),
751+ length ("%1.paramc"))) params;
752+
753+ /* If this is an assertion, the next one in the chain. */
754+ cpp_macro *GTY ((tag ("true"))) next;
755+ } GTY ((desc ("%1.kind == cmk_assert"))) parm;
756+
757+ /* Definition line number. */
758+ location_t line;
759+
760+ /* Number of tokens in body, or bytes for traditional macros. */
761+ /* Do we really need 2^32-1 range here? */
762+ unsigned int count;
763+
764+ /* Number of parameters. */
765+ unsigned short paramc;
766+
767+ /* Non-zero if this is a user-lazy macro, value provided by user. */
768+ unsigned char lazy;
769+
770+ /* The kind of this macro (ISO, trad or assert) */
771+ unsigned kind : 2;
772+
773+ /* If a function-like macro. */
774+ unsigned int fun_like : 1;
775+
776+ /* If a variadic macro. */
777+ unsigned int variadic : 1;
778+
779+ /* If macro defined in system header. */
780+ unsigned int syshdr : 1;
781+
782+ /* Nonzero if it has been expanded or had its existence tested. */
783+ unsigned int used : 1;
784+
785+ /* Indicate whether the tokens include extra CPP_PASTE tokens at the
786+ end to track invalid redefinitions with consecutive CPP_PASTE
787+ tokens. */
788+ unsigned int extra_tokens : 1;
789+
790+ /* 1 bits spare (32-bit). 33 on 64-bit target. */
791+
792+ union cpp_exp_u
793+ {
794+ /* Trailing array of replacement tokens (ISO), or assertion body value. */
795+ cpp_token GTY ((tag ("false"), length ("%1.count"))) tokens[1];
796+
797+ /* Pointer to replacement text (traditional). See comment at top
798+ of cpptrad.c for how traditional function-like macros are
799+ encoded. */
800+ const unsigned char *GTY ((tag ("true"))) text;
801+ } GTY ((desc ("%1.kind == cmk_traditional"))) exp;
802+};
803+
804+/* Poisoned identifiers are flagged NODE_POISONED. NODE_OPERATOR (C++
805+ only) indicates an identifier that behaves like an operator such as
806+ "xor". NODE_DIAGNOSTIC is for speed in lex_token: it indicates a
682807 diagnostic may be required for this node. Currently this only
683808 applies to __VA_ARGS__, poisoned identifiers, and -Wc++-compat
684809 warnings about NODE_OPERATOR. */
@@ -686,21 +811,21 @@ struct cpp_dir · 1 unmodified line
686811 /* Hash node flags. */
687812 #define NODE_OPERATOR (1 << 0) /* C++ named operator. */
688813 #define NODE_POISONED (1 << 1) /* Poisoned identifier. */
689−#define NODE_BUILTIN (1 << 2) /* Builtin macro. */
690−#define NODE_DIAGNOSTIC (1 << 3) /* Possible diagnostic when lexed. */
691−#define NODE_WARN (1 << 4) /* Warn if redefined or undefined. */
692−#define NODE_DISABLED (1 << 5) /* A disabled macro. */
693−#define NODE_MACRO_ARG (1 << 6) /* Used during #define processing. */
694−#define NODE_USED (1 << 7) /* Dumped with -dU. */
695−#define NODE_CONDITIONAL (1 << 8) /* Conditional macro */
696−#define NODE_WARN_OPERATOR (1 << 9) /* Warn about C++ named operator. */
814+#define NODE_DIAGNOSTIC (1 << 2) /* Possible diagnostic when lexed. */
815+#define NODE_WARN (1 << 3) /* Warn if redefined or undefined. */
816+#define NODE_DISABLED (1 << 4) /* A disabled macro. */
817+#define NODE_USED (1 << 5) /* Dumped with -dU. */
818+#define NODE_CONDITIONAL (1 << 6) /* Conditional macro */
819+#define NODE_WARN_OPERATOR (1 << 7) /* Warn about C++ named operator. */
697820
698821 /* Different flavors of hash node. */
699822 enum node_type
700823 {
701− NT_VOID = 0, /* No definition yet. */
702− NT_MACRO, /* A macro of some form. */
703− NT_ASSERTION /* Predicate for #assert. */
824+ NT_VOID = 0, /* Maybe an assert? */
825+ NT_MACRO_ARG, /* A macro arg. */
826+ NT_USER_MACRO, /* A user macro. */
827+ NT_BUILTIN_MACRO, /* A builtin macro. */
828+ NT_MACRO_MASK = NT_USER_MACRO /* Mask for either macro kind. */
704829 };
705830
706831 /* Different flavors of builtin macro. _Pragma is an operator, but we
@@ -717,46 +842,27 @@ enum cpp_builtin_type · 10 unmodified lines
717842 BT_PRAGMA, /* `_Pragma' operator */
718843 BT_TIMESTAMP, /* `__TIMESTAMP__' */
719844 BT_COUNTER, /* `__COUNTER__' */
720− BT_HAS_ATTRIBUTE, /* `__has_attribute__(x)' */
721− BT_FIRST_USER, /* User defined builtin macros. */
722− BT_LAST_USER = BT_FIRST_USER + 63
845+ BT_HAS_ATTRIBUTE /* `__has_attribute__(x)' */
723846 };
724847
725848 #define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE))
726−#define HT_NODE(NODE) ((ht_identifier *) (NODE))
727−#define NODE_LEN(NODE) HT_LEN (&(NODE)->ident)
728−#define NODE_NAME(NODE) HT_STR (&(NODE)->ident)
729−
730−/* Specify which field, if any, of the union is used. */
731−
732−enum {
733− NTV_MACRO,
734− NTV_ANSWER,
735− NTV_BUILTIN,
736− NTV_ARGUMENT,
737− NTV_NONE
738−};
739−
740−#define CPP_HASHNODE_VALUE_IDX(HNODE) \
741− ((HNODE.flags & NODE_MACRO_ARG) ? NTV_ARGUMENT \
742− : HNODE.type == NT_MACRO ? ((HNODE.flags & NODE_BUILTIN) \
743− ? NTV_BUILTIN : NTV_MACRO) \
744− : HNODE.type == NT_ASSERTION ? NTV_ANSWER \
745− : NTV_NONE)
849+#define HT_NODE(NODE) (&(NODE)->ident)
850+#define NODE_LEN(NODE) HT_LEN (HT_NODE (NODE))
851+#define NODE_NAME(NODE) HT_STR (HT_NODE (NODE))
746852
747853 /* The common part of an identifier node shared amongst all 3 C front
748854 ends. Also used to store CPP identifiers, which are a superset of
749855 identifiers in the grammatical sense. */
750856
751857 union GTY(()) _cpp_hashnode_value {
752− /* If a macro. */
753− cpp_macro * GTY((tag ("NTV_MACRO"))) macro;
754− /* Answers to an assertion. */
755− struct answer * GTY ((tag ("NTV_ANSWER"))) answers;
858+ /* Assert (maybe NULL) */
859+ cpp_macro * GTY((tag ("NT_VOID"))) answers;
860+ /* Macro (never NULL) */
861+ cpp_macro * GTY((tag ("NT_USER_MACRO"))) macro;
756862 /* Code for a builtin macro. */
757− enum cpp_builtin_type GTY ((tag ("NTV_BUILTIN"))) builtin;
863+ enum cpp_builtin_type GTY ((tag ("NT_BUILTIN_MACRO"))) builtin;
758864 /* Macro argument index. */
759− unsigned short GTY ((tag ("NTV_ARGUMENT"))) arg_index;
865+ unsigned short GTY ((tag ("NT_MACRO_ARG"))) arg_index;
760866 };
761867
762868 struct GTY(()) cpp_hashnode {
@@ -766,10 +872,12 @@ struct GTY(()) cpp_hashnode { · 3 unmodified lines
766872 then index into directive table.
767873 Otherwise, a NODE_OPERATOR. */
768874 unsigned char rid_code; /* Rid code - for front ends. */
769− ENUM_BITFIELD(node_type) type : 6; /* CPP node type. */
770− unsigned int flags : 10; /* CPP flags. */
875+ ENUM_BITFIELD(node_type) type : 2; /* CPP node type. */
876+ unsigned int flags : 8; /* CPP flags. */
877+
878+ /* 6 bits spare (plus another 32 on 64-bit hosts). */
771879
772− union _cpp_hashnode_value GTY ((desc ("CPP_HASHNODE_VALUE_IDX (%1)"))) value;
880+ union _cpp_hashnode_value GTY ((desc ("%1.type"))) value;
773881 };
774882
775883 /* A class for iterating through the source locations within a
@@ -778,13 +886,13 @@ struct GTY(()) cpp_hashnode { · 2 unmodified lines
778886
779887 class cpp_string_location_reader {
780888 public:
781− cpp_string_location_reader (source_location src_loc,
889+ cpp_string_location_reader (location_t src_loc,
782890 line_maps *line_table);
783891
784892 source_range get_next ();
785893
786894 private:
787− source_location m_loc;
895+ location_t m_loc;
788896 int m_offset_per_column;
789897 line_maps *m_line_table;
790898 };
@@ -889,11 +997,32 @@ extern int cpp_avoid_paste (cpp_reader *, const cpp_token *, · 98 unmodified lines
889997 const cpp_token *);
890998 extern const cpp_token *cpp_get_token (cpp_reader *);
891999 extern const cpp_token *cpp_get_token_with_location (cpp_reader *,
892− source_location *);
893−extern bool cpp_fun_like_macro_p (cpp_hashnode *);
1000+ location_t *);
1001+inline bool cpp_user_macro_p (const cpp_hashnode *node)
1002+{
1003+ return node->type == NT_USER_MACRO;
1004+}
1005+inline bool cpp_builtin_macro_p (const cpp_hashnode *node)
1006+{
1007+ return node->type == NT_BUILTIN_MACRO;
1008+}
1009+inline bool cpp_macro_p (const cpp_hashnode *node)
1010+{
1011+ return node->type & NT_MACRO_MASK;
1012+}
1013+
1014+/* Returns true if NODE is a function-like user macro. */
1015+inline bool cpp_fun_like_macro_p (cpp_hashnode *node)
1016+{
1017+ return cpp_user_macro_p (node) && node->value.macro->fun_like;
1018+}
1019+
8941020 extern const unsigned char *cpp_macro_definition (cpp_reader *,
8951021 cpp_hashnode *);
896−extern source_location cpp_macro_definition_location (cpp_hashnode *);
1022+inline location_t cpp_macro_definition_location (cpp_hashnode *node)
1023+{
1024+ return node->value.macro->line;
1025+}
8971026 extern void _cpp_backup_tokens (cpp_reader *, unsigned int);
8981027 extern const cpp_token *cpp_peek_token (cpp_reader *, int);
8991028
@@ -926,6 +1055,9 @@ extern void cpp_assert (cpp_reader *, const char *); · 26 unmodified lines
9261055 extern void cpp_undef (cpp_reader *, const char *);
9271056 extern void cpp_unassert (cpp_reader *, const char *);
9281057
1058+/* Mark a node as a lazily defined macro. */
1059+extern void cpp_define_lazily (cpp_reader *, cpp_hashnode *node, unsigned N);
1060+
9291061 /* Undefine all macros and assertions. */
9301062 extern void cpp_undef_all (cpp_reader *);
9311063
@@ -996,7 +1128,7 @@ struct cpp_num · 64 unmodified lines
9961128 /* Classify a CPP_NUMBER token. The return value is a combination of
9971129 the flags from the above sets. */
9981130 extern unsigned cpp_classify_number (cpp_reader *, const cpp_token *,
999− const char **, source_location);
1131+ const char **, location_t);
10001132
10011133 /* Return the classification flags for a float suffix. */
10021134 extern unsigned int cpp_interpret_float_suffix (cpp_reader *, const char *,
@@ -1014,99 +1146,55 @@ extern cpp_num cpp_interpret_integer (cpp_reader *, const cpp_token *, · 11 unmodified lines
10141146 others assumed clear, to fill out a cpp_num structure. */
10151147 cpp_num cpp_num_sign_extend (cpp_num, size_t);
10161148
1017−/* Diagnostic levels. To get a diagnostic without associating a
1018− position in the translation unit with it, use cpp_error_with_line
1019− with a line number of zero. */
1020−
1021−enum {
1022− /* Warning, an error with -Werror. */
1023− CPP_DL_WARNING = 0,
1024− /* Same as CPP_DL_WARNING, except it is not suppressed in system headers. */
1025− CPP_DL_WARNING_SYSHDR,
1026− /* Warning, an error with -pedantic-errors or -Werror. */
1027− CPP_DL_PEDWARN,
1028− /* An error. */
1029− CPP_DL_ERROR,
1030− /* An internal consistency check failed. Prints "internal error: ",
1031− otherwise the same as CPP_DL_ERROR. */
1032− CPP_DL_ICE,
1033− /* An informative note following a warning. */
1034− CPP_DL_NOTE,
1035− /* A fatal error. */
1036− CPP_DL_FATAL
1037−};
1038−
1039−/* Warning reason codes. Use a reason code of zero for unclassified warnings
1040− and errors that are not warnings. */
1041−enum {
1042− CPP_W_NONE = 0,
1043− CPP_W_DEPRECATED,
1044− CPP_W_COMMENTS,
1045− CPP_W_MISSING_INCLUDE_DIRS,
1046− CPP_W_TRIGRAPHS,
1047− CPP_W_MULTICHAR,
1048− CPP_W_TRADITIONAL,
1049− CPP_W_LONG_LONG,
1050− CPP_W_ENDIF_LABELS,
1051− CPP_W_NUM_SIGN_CHANGE,
1052− CPP_W_VARIADIC_MACROS,
1053− CPP_W_BUILTIN_MACRO_REDEFINED,
1054− CPP_W_DOLLARS,
1055− CPP_W_UNDEF,
1056− CPP_W_UNUSED_MACROS,
1057− CPP_W_CXX_OPERATOR_NAMES,
1058− CPP_W_NORMALIZE,
1059− CPP_W_INVALID_PCH,
1060− CPP_W_WARNING_DIRECTIVE,
1061− CPP_W_LITERAL_SUFFIX,
1062− CPP_W_DATE_TIME,
1063− CPP_W_PEDANTIC,
1064− CPP_W_C90_C99_COMPAT,
1065− CPP_W_CXX11_COMPAT,
1066− CPP_W_EXPANSION_TO_DEFINED
1067−};
1068−
10691149 /* Output a diagnostic of some kind. */
1070−extern bool cpp_error (cpp_reader *, int, const char *msgid, ...)
1150+extern bool cpp_error (cpp_reader *, enum cpp_diagnostic_level,
1151+ const char *msgid, ...)
10711152 ATTRIBUTE_PRINTF_3;
1072−extern bool cpp_warning (cpp_reader *, int, const char *msgid, ...)
1153+extern bool cpp_warning (cpp_reader *, enum cpp_warning_reason,
1154+ const char *msgid, ...)
10731155 ATTRIBUTE_PRINTF_3;
1074−extern bool cpp_pedwarning (cpp_reader *, int, const char *msgid, ...)
1156+extern bool cpp_pedwarning (cpp_reader *, enum cpp_warning_reason,
1157+ const char *msgid, ...)
10751158 ATTRIBUTE_PRINTF_3;
1076−extern bool cpp_warning_syshdr (cpp_reader *, int, const char *msgid, ...)
1159+extern bool cpp_warning_syshdr (cpp_reader *, enum cpp_warning_reason reason,
1160+ const char *msgid, ...)
10771161 ATTRIBUTE_PRINTF_3;
10781162
10791163 /* Output a diagnostic with "MSGID: " preceding the
10801164 error string of errno. No location is printed. */
1081−extern bool cpp_errno (cpp_reader *, int, const char *msgid);
1165+extern bool cpp_errno (cpp_reader *, enum cpp_diagnostic_level,
1166+ const char *msgid);
10821167 /* Similarly, but with "FILENAME: " instead of "MSGID: ", where
10831168 the filename is not localized. */
1084−extern bool cpp_errno_filename (cpp_reader *, int, const char *filename,
1085− source_location loc);
1169+extern bool cpp_errno_filename (cpp_reader *, enum cpp_diagnostic_level,
1170+ const char *filename, location_t loc);
10861171
10871172 /* Same as cpp_error, except additionally specifies a position as a
10881173 (translation unit) physical line and physical column. If the line is
10891174 zero, then no location is printed. */
1090−extern bool cpp_error_with_line (cpp_reader *, int, source_location,
1091− unsigned, const char *msgid, ...)
1175+extern bool cpp_error_with_line (cpp_reader *, enum cpp_diagnostic_level,
1176+ location_t, unsigned,
1177+ const char *msgid, ...)
10921178 ATTRIBUTE_PRINTF_5;
1093−extern bool cpp_warning_with_line (cpp_reader *, int, source_location,
1094− unsigned, const char *msgid, ...)
1179+extern bool cpp_warning_with_line (cpp_reader *, enum cpp_warning_reason,
1180+ location_t, unsigned,
1181+ const char *msgid, ...)
10951182 ATTRIBUTE_PRINTF_5;
1096−extern bool cpp_pedwarning_with_line (cpp_reader *, int, source_location,
1097− unsigned, const char *msgid, ...)
1183+extern bool cpp_pedwarning_with_line (cpp_reader *, enum cpp_warning_reason,
1184+ location_t, unsigned,
1185+ const char *msgid, ...)
10981186 ATTRIBUTE_PRINTF_5;
1099−extern bool cpp_warning_with_line_syshdr (cpp_reader *, int, source_location,
1100− unsigned, const char *msgid, ...)
1187+extern bool cpp_warning_with_line_syshdr (cpp_reader *, enum cpp_warning_reason,
1188+ location_t, unsigned,
1189+ const char *msgid, ...)
11011190 ATTRIBUTE_PRINTF_5;
11021191
1103−extern bool cpp_error_at (cpp_reader * pfile, int level,
1104− source_location src_loc, const char *msgid, ...)
1192+extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
1193+ location_t src_loc, const char *msgid, ...)
11051194 ATTRIBUTE_PRINTF_4;
11061195
1107−extern bool cpp_error_at (cpp_reader * pfile, int level,
1108− rich_location *richloc, const char *msgid,
1109− ...)
1196+extern bool cpp_error_at (cpp_reader * pfile, enum cpp_diagnostic_level,
1197+ rich_location *richloc, const char *msgid, ...)
11101198 ATTRIBUTE_PRINTF_4;
11111199
11121200 /* In lex.c */
@@ -1133,7 +1221,7 @@ typedef struct · 20 unmodified lines
11331221 char *comment;
11341222
11351223 /* source location for the given comment. */
1136− source_location sloc;
1224+ location_t sloc;
11371225 } cpp_comment;
11381226
11391227 /* Structure holding all comments for a given cpp_reader. */
@@ -1172,7 +1260,7 @@ extern unsigned char *cpp_quote_string (unsigned char *, const unsigned char *, · 32 unmodified lines
11721260
11731261 /* In files.c */
11741262 extern bool cpp_included (cpp_reader *, const char *);
1175−extern bool cpp_included_before (cpp_reader *, const char *, source_location);
1263+extern bool cpp_included_before (cpp_reader *, const char *, location_t);
11761264 extern void cpp_make_system_header (cpp_reader *, int, int);
11771265 extern bool cpp_push_include (cpp_reader *, const char *);
11781266 extern bool cpp_push_default_include (cpp_reader *, const char *);
@@ -1195,7 +1283,7 @@ extern int cpp_read_state (cpp_reader *, const char *, FILE *, · 16 unmodified lines
11951283 struct save_macro_data *);
11961284
11971285 /* In lex.c */
1198−extern void cpp_force_token_locations (cpp_reader *, source_location *);
1286+extern void cpp_force_token_locations (cpp_reader *, location_t);
11991287 extern void cpp_stop_forcing_token_locations (cpp_reader *);
12001288
12011289 /* In expr.c */
gcc/libcpp/include/line-map.h+310−210
@@ -1,5 +1,5 @@
11 /* Map (unsigned int) keys to (source file, line, column) triples.
2− Copyright (C) 2001-2018 Free Software Foundation, Inc.
2+ Copyright (C) 2001-2019 Free Software Foundation, Inc.
33
44 This program is free software; you can redistribute it and/or modify it
55 under the terms of the GNU General Public License as published by the
@@ -49,36 +49,34 @@ along with this program; see the file COPYING3. If not see · 43 unmodified lines
4949 /* The type of line numbers. */
5050 typedef unsigned int linenum_type;
5151
52+/* A type for doing arithmetic on line numbers. */
53+typedef long long linenum_arith_t;
54+
5255 /* A function for for use by qsort for comparing line numbers. */
5356
5457 inline int compare (linenum_type lhs, linenum_type rhs)
5558 {
56− /* Avoid truncation issues by using long long for the comparison,
59+ /* Avoid truncation issues by using linenum_arith_t for the comparison,
5760 and only consider the sign of the result. */
58− long long diff = (long long)lhs - (long long)rhs;
61+ linenum_arith_t diff = (linenum_arith_t)lhs - (linenum_arith_t)rhs;
5962 if (diff)
6063 return diff > 0 ? 1 : -1;
6164 return 0;
6265 }
6366
64−/* Reason for creating a new line map with linemap_add. LC_ENTER is
65− when including a new file, e.g. a #include directive in C.
66− LC_LEAVE is when reaching a file's end. LC_RENAME is when a file
67− name or line number changes for neither of the above reasons
68− (e.g. a #line directive in C); LC_RENAME_VERBATIM is like LC_RENAME
69− but a filename of "" is not specially interpreted as standard
70− input. LC_ENTER_MACRO is when a macro expansion is about to start. */
67+/* Reason for creating a new line map with linemap_add. */
7168 enum lc_reason
7269 {
73− LC_ENTER = 0,
74− LC_LEAVE,
75− LC_RENAME,
76− LC_RENAME_VERBATIM,
77− LC_ENTER_MACRO
70+ LC_ENTER = 0, /* Begin #include. */
71+ LC_LEAVE, /* Return to including file. */
72+ LC_RENAME, /* Other reason for name change. */
73+ LC_RENAME_VERBATIM, /* Likewise, but "" != stdin. */
74+ LC_ENTER_MACRO, /* Begin macro expansion. */
7875 /* FIXME: add support for stringize and paste. */
76+ LC_HWM /* High Water Mark. */
7977 };
8078
81−/* The typedef "source_location" is a key within the location database,
79+/* The typedef "location_t" is a key within the location database,
8280 identifying a source location or macro expansion, along with range
8381 information, and (optionally) a pointer for use by gcc.
8482
@@ -168,7 +166,7 @@ enum lc_reason · 83 unmodified lines
168166 | Beyond this point, ordinary linemaps have 0 bits per column:
169167 | each increment of the value corresponds to a new source line.
170168 |
171− 0x70000000 | LINE_MAP_MAX_SOURCE_LOCATION
169+ 0x70000000 | LINE_MAP_MAX_LOCATION
172170 | Beyond the point, we give up on ordinary maps; attempts to
173171 | create locations in them lead to UNKNOWN_LOCATION (0).
174172 |
@@ -187,7 +185,7 @@ enum lc_reason · 12 unmodified lines
187185 | macromap[1]->start_location | Start of macro map 1
188186 -----------+-------------------------------+-------------------------------
189187 | macromap[0]->start_location | Start of macro map 0
190− 0x7fffffff | MAX_SOURCE_LOCATION | Also used as a mask for
188+ 0x7fffffff | MAX_LOCATION_T | Also used as a mask for
191189 | | accessing the ad-hoc data table
192190 -----------+-------------------------------+-------------------------------
193191 0x80000000 | Start of ad-hoc values; the lower 31 bits are used as an index
@@ -288,9 +286,9 @@ enum lc_reason · 94 unmodified lines
288286 finish == ordmap->start + (23 << 12) + (19 << 5)
289287 == ordmap->start + 0x17260
290288
291− To further see how source_location works in practice, see the
289+ To further see how location_t works in practice, see the
292290 worked example in libcpp/location-example.txt. */
293−typedef unsigned int source_location;
291+typedef unsigned int location_t;
294292
295293 /* Do not track column numbers higher than this one. As a result, the
296294 range of column_bits is [12, 18] (or 0 if column numbers are
@@ -300,12 +298,15 @@ const unsigned int LINE_MAP_MAX_COLUMN_NUMBER = (1U << 12); · 3 unmodified lines
300298 /* Do not pack ranges if locations get higher than this.
301299 If you change this, update:
302300 gcc.dg/plugin/location-overflow-test-*.c. */
303−const source_location LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES = 0x50000000;
301+const location_t LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES = 0x50000000;
304302
305303 /* Do not track column numbers if locations get higher than this.
306304 If you change this, update:
307305 gcc.dg/plugin/location-overflow-test-*.c. */
308−const source_location LINE_MAP_MAX_LOCATION_WITH_COLS = 0x60000000;
306+const location_t LINE_MAP_MAX_LOCATION_WITH_COLS = 0x60000000;
307+
308+/* Highest possible source location encoded within an ordinary map. */
309+const location_t LINE_MAP_MAX_LOCATION = 0x70000000;
309310
310311 /* A range of source locations.
311312
@@ -317,15 +318,15 @@ const source_location LINE_MAP_MAX_LOCATION_WITH_COLS = 0x60000000; · 5 unmodified lines
317318 let's do it the simple way, as a pair. */
318319 struct GTY(()) source_range
319320 {
320− source_location m_start;
321− source_location m_finish;
321+ location_t m_start;
322+ location_t m_finish;
322323
323324 /* We avoid using constructors, since various structs that
324325 don't yet have constructors will embed instances of
325326 source_range. */
326327
327− /* Make a source_range from a source_location. */
328− static source_range from_location (source_location loc)
328+ /* Make a source_range from a location_t. */
329+ static source_range from_location (location_t loc)
329330 {
330331 source_range result;
331332 result.m_start = loc;
@@ -333,9 +334,9 @@ struct GTY(()) source_range · 1 unmodified line
333334 return result;
334335 }
335336
336− /* Make a source_range from a pair of source_location. */
337− static source_range from_locations (source_location start,
338− source_location finish)
337+ /* Make a source_range from a pair of location_t. */
338+ static source_range from_locations (location_t start,
339+ location_t finish)
339340 {
340341 source_range result;
341342 result.m_start = start;
@@ -377,11 +378,13 @@ typedef size_t (*line_map_round_alloc_size_func) (size_t); · 35 unmodified lines
377378 location of the expansion point of PLUS. That location is mapped in
378379 the map that is active right before the location of the invocation
379380 of PLUS. */
380−struct GTY((tag ("0"), desc ("%h.reason == LC_ENTER_MACRO ? 2 : 1"))) line_map {
381− source_location start_location;
382381
383− /* The reason for creation of this line map. */
384− ENUM_BITFIELD (lc_reason) reason : CHAR_BIT;
382+/* This contains GTY mark-up to support precompiled headers.
383+ line_map is an abstract class, only derived objects exist. */
384+struct GTY((tag ("0"), desc ("MAP_ORDINARY_P (&%h) ? 1 : 2"))) line_map {
385+ location_t start_location;
386+
387+ /* Size and alignment is (usually) 4 bytes. */
385388 };
386389
387390 /* An ordinary line map encodes physical source locations. Those
@@ -395,15 +398,14 @@ struct GTY((tag ("0"), desc ("%h.reason == LC_ENTER_MACRO ? 2 : 1"))) line_map { · 7 unmodified lines
395398 (The top line is line 1 and the leftmost column is column 1; line/column 0
396399 means "entire file/line" or "unknown line/column" or "not applicable".)
397400
398− The highest possible source location is MAX_SOURCE_LOCATION. */
401+ The highest possible source location is MAX_LOCATION_T. */
399402 struct GTY((tag ("1"))) line_map_ordinary : public line_map {
400− const char *to_file;
401− linenum_type to_line;
403+ /* Base class is 4 bytes. */
402404
403− /* An index into the set that gives the line mapping at whose end
404− the current one was included. File(s) at the bottom of the
405− include stack have this set to -1. */
406− int included_from;
405+ /* 4 bytes of integers, each 1 byte for easy extraction/insertion. */
406+
407+ /* The reason for creation of this line map. */
408+ ENUM_BITFIELD (lc_reason) reason : 8;
407409
408410 /* SYSP is one for a system header, two for a C system header file
409411 that therefore needs to be extern "C" protected in C++, and zero
@@ -411,7 +413,7 @@ struct GTY((tag ("1"))) line_map_ordinary : public line_map { · 1 unmodified line
411413 cpp_buffer. */
412414 unsigned char sysp;
413415
414− /* Number of the low-order source_location bits used for column numbers
416+ /* Number of the low-order location_t bits used for column numbers
415417 and ranges. */
416418 unsigned int m_column_and_range_bits : 8;
417419
@@ -429,11 +431,23 @@ struct GTY((tag ("1"))) line_map_ordinary : public line_map { · 11 unmodified lines
429431 | | (e.g. 7) | (e.g. 5) |
430432 +-------------------------+-----------------------+-------------------+ */
431433 unsigned int m_range_bits : 8;
434+
435+ /* Pointer alignment boundary on both 32 and 64-bit systems. */
436+
437+ const char *to_file;
438+ linenum_type to_line;
439+
440+ /* Location from whence this line map was included. For regular
441+ #includes, this location will be the last location of a map. For
442+ outermost file, this is 0. */
443+ location_t included_from;
444+
445+ /* Size is 20 or 24 bytes, no padding */
432446 };
433447
434448 /* This is the highest possible source location encoded within an
435449 ordinary or macro map. */
436−const source_location MAX_SOURCE_LOCATION = 0x7FFFFFFF;
450+const location_t MAX_LOCATION_T = 0x7FFFFFFF;
437451
438452 struct cpp_hashnode;
439453
@@ -443,15 +457,20 @@ struct cpp_hashnode; · 3 unmodified lines
443457 The offset from START_LOCATION is used to index into
444458 MACRO_LOCATIONS; this holds the original location of the token. */
445459 struct GTY((tag ("2"))) line_map_macro : public line_map {
446− /* The cpp macro which expansion gave birth to this macro map. */
447− struct cpp_hashnode * GTY ((nested_ptr (union tree_node,
448− "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
449− "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL")))
450− macro;
460+ /* Base is 4 bytes. */
451461
452462 /* The number of tokens inside the replacement-list of MACRO. */
453463 unsigned int n_tokens;
454464
465+ /* Pointer alignment boundary. */
466+
467+ /* The cpp macro whose expansion gave birth to this macro map. */
468+ struct cpp_hashnode *
469+ GTY ((nested_ptr (union tree_node,
470+ "%h ? CPP_HASHNODE (GCC_IDENT_TO_HT_IDENT (%h)) : NULL",
471+ "%h ? HT_IDENT_TO_GCC_IDENT (HT_NODE (%h)) : NULL")))
472+ macro;
473+
455474 /* This array of location is actually an array of pairs of
456475 locations. The elements inside it thus look like:
457476
@@ -505,14 +524,16 @@ struct GTY((tag ("2"))) line_map_macro : public line_map { · 47 unmodified lines
505524 In the example above x1 (for token "+") is going to be the same
506525 as y1. x0 is the spelling location for the argument token "1",
507526 and x2 is the spelling location for the argument token "2". */
508− source_location * GTY((atomic)) macro_locations;
527+ location_t * GTY((atomic)) macro_locations;
509528
510529 /* This is the location of the expansion point of the current macro
511530 map. It's the location of the macro name. That location is held
512531 by the map that was current right before the current one. It
513532 could have been either a macro or an ordinary map, depending on
514533 if we are in a nested expansion context not. */
515− source_location expansion;
534+ location_t expansion;
535+
536+ /* Size is 20 or 32 (4 bytes padding on 64-bit). */
516537 };
517538
518539 #if CHECKING_P && (GCC_VERSION >= 2007)
@@ -540,6 +561,34 @@ struct GTY((tag ("2"))) line_map_macro : public line_map { · 21 unmodified lines
540561 #define linemap_assert_fails(EXPR) (! (EXPR))
541562 #endif
542563
564+/* Get whether location LOC is an ad-hoc, ordinary or macro location. */
565+
566+inline bool
567+IS_ORDINARY_LOC (location_t loc)
568+{
569+ return loc < LINE_MAP_MAX_LOCATION;
570+}
571+
572+inline bool
573+IS_ADHOC_LOC (location_t loc)
574+{
575+ return loc > MAX_LOCATION_T;
576+}
577+
578+inline bool
579+IS_MACRO_LOC (location_t loc)
580+{
581+ return !IS_ORDINARY_LOC (loc) && !IS_ADHOC_LOC (loc);
582+}
583+
584+/* Categorize line map kinds. */
585+
586+inline bool
587+MAP_ORDINARY_P (const line_map *map)
588+{
589+ return IS_ORDINARY_LOC (map->start_location);
590+}
591+
543592 /* Return TRUE if MAP encodes locations coming from a macro
544593 replacement-list at macro expansion point. */
545594 bool
@@ -552,7 +601,7 @@ linemap_macro_expansion_map_p (const struct line_map *); · 6 unmodified lines
552601 inline line_map_ordinary *
553602 linemap_check_ordinary (struct line_map *map)
554603 {
555− linemap_assert (!linemap_macro_expansion_map_p (map));
604+ linemap_assert (MAP_ORDINARY_P (map));
556605 return (line_map_ordinary *)map;
557606 }
558607
@@ -563,7 +612,7 @@ linemap_check_ordinary (struct line_map *map) · 4 unmodified lines
563612 inline const line_map_ordinary *
564613 linemap_check_ordinary (const struct line_map *map)
565614 {
566− linemap_assert (!linemap_macro_expansion_map_p (map));
615+ linemap_assert (MAP_ORDINARY_P (map));
567616 return (const line_map_ordinary *)map;
568617 }
569618
@@ -572,7 +621,7 @@ linemap_check_ordinary (const struct line_map *map) · 2 unmodified lines
572621
573622 inline line_map_macro *linemap_check_macro (line_map *map)
574623 {
575− linemap_assert (linemap_macro_expansion_map_p (map));
624+ linemap_assert (!MAP_ORDINARY_P (map));
576625 return (line_map_macro *)map;
577626 }
578627
@@ -582,13 +631,13 @@ inline line_map_macro *linemap_check_macro (line_map *map) · 3 unmodified lines
582631 inline const line_map_macro *
583632 linemap_check_macro (const line_map *map)
584633 {
585− linemap_assert (linemap_macro_expansion_map_p (map));
634+ linemap_assert (!MAP_ORDINARY_P (map));
586635 return (const line_map_macro *)map;
587636 }
588637
589638 /* Read the start location of MAP. */
590639
591−inline source_location
640+inline location_t
592641 MAP_START_LOCATION (const line_map *map)
593642 {
594643 return map->start_location;
@@ -602,17 +651,6 @@ ORDINARY_MAP_STARTING_LINE_NUMBER (const line_map_ordinary *ord_map) · 7 unmodified lines
602651 return ord_map->to_line;
603652 }
604653
605−/* Get the index of the ordinary map at whose end
606− ordinary map MAP was included.
607−
608− File(s) at the bottom of the include stack have this set. */
609−
610−inline int
611−ORDINARY_MAP_INCLUDER_FILE_INDEX (const line_map_ordinary *ord_map)
612−{
613− return ord_map->included_from;
614−}
615−
616654 /* Return a positive value if map encodes locations from a system
617655 header, 0 otherwise. Returns 1 if ordinary map MAP encodes locations
618656 in a system header and 2 if it encodes locations in a C system header
@@ -652,7 +690,7 @@ MACRO_MAP_NUM_MACRO_TOKENS (const line_map_macro *macro_map) · 33 unmodified lines
652690 /* Get the array of pairs of locations within macro map MAP.
653691 See the declaration of line_map_macro for more information. */
654692
655−inline source_location *
693+inline location_t *
656694 MACRO_MAP_LOCATIONS (const line_map_macro *macro_map)
657695 {
658696 return macro_map->macro_locations;
@@ -660,7 +698,7 @@ MACRO_MAP_LOCATIONS (const line_map_macro *macro_map) · 1 unmodified line
660698
661699 /* Get the location of the expansion point of the macro map MAP. */
662700
663−inline source_location
701+inline location_t
664702 MACRO_MAP_EXPANSION_POINT_LOCATION (const line_map_macro *macro_map)
665703 {
666704 return macro_map->expansion;
@@ -707,7 +745,7 @@ struct GTY(()) maps_info_macro { · 40 unmodified lines
707745 /* Data structure to associate a source_range together with an arbitrary
708746 data pointer with a source location. */
709747 struct GTY(()) location_adhoc_data {
710− source_location locus;
748+ location_t locus;
711749 source_range src_range;
712750 void * GTY((skip)) data;
713751 };
@@ -726,7 +764,7 @@ struct htab; · 12 unmodified lines
726764
727765 struct GTY(()) location_adhoc_data_map {
728766 struct htab * GTY((skip)) htab;
729− source_location curr_loc;
767+ location_t curr_loc;
730768 unsigned int allocated;
731769 struct location_adhoc_data GTY((length ("%h.allocated"))) *data;
732770 };
@@ -746,18 +784,17 @@ struct GTY(()) line_maps { · 13 unmodified lines
746784 /* If true, prints an include trace a la -H. */
747785 bool trace_includes;
748786
749− /* Highest source_location "given out". */
750− source_location highest_location;
787+ /* Highest location_t "given out". */
788+ location_t highest_location;
751789
752− /* Start of line of highest source_location "given out". */
753− source_location highest_line;
790+ /* Start of line of highest location_t "given out". */
791+ location_t highest_line;
754792
755793 /* The maximum column number we can quickly allocate. Higher numbers
756794 may require allocating a new line_map. */
757795 unsigned int max_column_hint;
758796
759− /* If non-null, the allocator to use when resizing 'maps'. If null,
760− xrealloc is used. */
797+ /* The allocator to use when resizing 'maps', defaults to xrealloc. */
761798 line_map_realloc reallocator;
762799
763800 /* The allocators' function used to know the actual size it
@@ -768,7 +805,7 @@ struct GTY(()) line_maps { · 4 unmodified lines
768805
769806 /* The special location value that is used as spelling location for
770807 built-in tokens. */
771− source_location builtin_location;
808+ location_t builtin_location;
772809
773810 /* True if we've seen a #line or # 44 "file" directive. */
774811 bool seen_line_directive;
@@ -998,12 +1035,12 @@ LINEMAPS_LAST_MACRO_MAP (const line_maps *set) · 223 unmodified lines
9981035
9991036 /* Returns the lowest location [of a token resulting from macro
10001037 expansion] encoded in this line table. */
1001−inline source_location
1038+inline location_t
10021039 LINEMAPS_MACRO_LOWEST_LOCATION (const line_maps *set)
10031040 {
10041041 return LINEMAPS_MACRO_USED (set)
10051042 ? MAP_START_LOCATION (LINEMAPS_LAST_MACRO_MAP (set))
1006− : MAX_SOURCE_LOCATION;
1043+ : MAX_LOCATION_T + 1;
10071044 }
10081045
10091046 /* Returns the last macro map allocated in the line table SET. */
@@ -1013,41 +1050,33 @@ LINEMAPS_LAST_ALLOCATED_MACRO_MAP (const line_maps *set) · 3 unmodified lines
10131050 return (line_map_macro *)LINEMAPS_LAST_ALLOCATED_MAP (set, true);
10141051 }
10151052
1016−extern source_location get_combined_adhoc_loc (struct line_maps *,
1017− source_location,
1053+extern location_t get_combined_adhoc_loc (struct line_maps *,
1054+ location_t,
10181055 source_range,
10191056 void *);
1020−extern void *get_data_from_adhoc_loc (struct line_maps *, source_location);
1021−extern source_location get_location_from_adhoc_loc (struct line_maps *,
1022− source_location);
1057+extern void *get_data_from_adhoc_loc (struct line_maps *, location_t);
1058+extern location_t get_location_from_adhoc_loc (struct line_maps *,
1059+ location_t);
10231060
1024−extern source_range get_range_from_loc (line_maps *set, source_location loc);
1025−
1026−/* Get whether location LOC is an ad-hoc location. */
1027−
1028−inline bool
1029−IS_ADHOC_LOC (source_location loc)
1030−{
1031− return (loc & MAX_SOURCE_LOCATION) != loc;
1032−}
1061+extern source_range get_range_from_loc (line_maps *set, location_t loc);
10331062
10341063 /* Get whether location LOC is a "pure" location, or
10351064 whether it is an ad-hoc location, or embeds range information. */
10361065
10371066 bool
1038−pure_location_p (line_maps *set, source_location loc);
1067+pure_location_p (line_maps *set, location_t loc);
10391068
10401069 /* Given location LOC within SET, strip away any packed range information
10411070 or ad-hoc information. */
10421071
1043−extern source_location get_pure_location (line_maps *set,
1044− source_location loc);
1072+extern location_t get_pure_location (line_maps *set,
1073+ location_t loc);
10451074
10461075 /* Combine LOC and BLOCK, giving a combined adhoc location. */
10471076
1048−inline source_location
1077+inline location_t
10491078 COMBINE_LOCATION_DATA (struct line_maps *set,
1050− source_location loc,
1079+ location_t loc,
10511080 source_range src_range,
10521081 void *block)
10531082 {
@@ -1061,19 +1090,19 @@ extern void rebuild_location_adhoc_htab (struct line_maps *); · 7 unmodified lines
10611090 spelling location for built-in tokens. This BUILTIN_LOCATION has
10621091 to be strictly less than RESERVED_LOCATION_COUNT. */
10631092 extern void linemap_init (struct line_maps *set,
1064− source_location builtin_location);
1093+ location_t builtin_location);
10651094
10661095 /* Check for and warn about line_maps entered but not exited. */
10671096
10681097 extern void linemap_check_files_exited (struct line_maps *);
10691098
1070−/* Return a source_location for the start (i.e. column==0) of
1099+/* Return a location_t for the start (i.e. column==0) of
10711100 (physical) line TO_LINE in the current source file (as in the
10721101 most recent linemap_add). MAX_COLUMN_HINT is the highest column
10731102 number we expect to use in this line (but it does not change
10741103 the highest_location). */
10751104
1076−extern source_location linemap_line_start
1105+extern location_t linemap_line_start
10771106 (struct line_maps *set, linenum_type to_line, unsigned int max_column_hint);
10781107
10791108 /* Add a mapping of logical source line to physical source file and
@@ -1100,7 +1129,7 @@ extern const struct line_map *linemap_add · 20 unmodified lines
11001129 binary search. If no line map have been allocated yet, this
11011130 function returns NULL. */
11021131 extern const struct line_map *linemap_lookup
1103− (struct line_maps *, source_location);
1132+ (struct line_maps *, location_t);
11041133
11051134 /* Returns TRUE if the line table set tracks token locations across
11061135 macro expansion, FALSE otherwise. */
@@ -1119,114 +1148,86 @@ const char* linemap_map_get_macro_name (const line_map_macro *); · 12 unmodified lines
11191148 that is part of a macro replacement-list defined in a system
11201149 header, but expanded in a non-system file. */
11211150 int linemap_location_in_system_header_p (struct line_maps *,
1122− source_location);
1151+ location_t);
11231152
11241153 /* Return TRUE if LOCATION is a source code location of a token that is part of
11251154 a macro expansion, FALSE otherwise. */
11261155 bool linemap_location_from_macro_expansion_p (const struct line_maps *,
1127− source_location);
1156+ location_t);
11281157
11291158 /* TRUE if LOCATION is a source code location of a token that is part of the
11301159 definition of a macro, FALSE otherwise. */
11311160 bool linemap_location_from_macro_definition_p (struct line_maps *,
1132− source_location);
1161+ location_t);
11331162
11341163 /* With the precondition that LOCATION is the locus of a token that is
11351164 an argument of a function-like macro MACRO_MAP and appears in the
11361165 expansion of MACRO_MAP, return the locus of that argument in the
11371166 context of the caller of MACRO_MAP. */
11381167
1139−extern source_location linemap_macro_map_loc_unwind_toward_spelling
1140− (line_maps *set, const line_map_macro *macro_map, source_location location);
1168+extern location_t linemap_macro_map_loc_unwind_toward_spelling
1169+ (line_maps *set, const line_map_macro *macro_map, location_t location);
11411170
1142−/* source_location values from 0 to RESERVED_LOCATION_COUNT-1 will
1171+/* location_t values from 0 to RESERVED_LOCATION_COUNT-1 will
11431172 be reserved for libcpp user as special values, no token from libcpp
11441173 will contain any of those locations. */
1145−const source_location RESERVED_LOCATION_COUNT = 2;
1174+const location_t RESERVED_LOCATION_COUNT = 2;
11461175
1147−/* Converts a map and a source_location to source line. */
1176+/* Converts a map and a location_t to source line. */
11481177 inline linenum_type
1149−SOURCE_LINE (const line_map_ordinary *ord_map, source_location loc)
1178+SOURCE_LINE (const line_map_ordinary *ord_map, location_t loc)
11501179 {
11511180 return ((loc - ord_map->start_location)
11521181 >> ord_map->m_column_and_range_bits) + ord_map->to_line;
11531182 }
11541183
1155−/* Convert a map and source_location to source column number. */
1184+/* Convert a map and location_t to source column number. */
11561185 inline linenum_type
1157−SOURCE_COLUMN (const line_map_ordinary *ord_map, source_location loc)
1186+SOURCE_COLUMN (const line_map_ordinary *ord_map, location_t loc)
11581187 {
11591188 return ((loc - ord_map->start_location)
11601189 & ((1 << ord_map->m_column_and_range_bits) - 1)) >> ord_map->m_range_bits;
11611190 }
11621191
1163−/* Return the location of the last source line within an ordinary
1164− map. */
1165−inline source_location
1166−LAST_SOURCE_LINE_LOCATION (const line_map_ordinary *map)
1167−{
1168− return (((map[1].start_location - 1
1169− - map->start_location)
1170− & ~((1 << map->m_column_and_range_bits) - 1))
1171− + map->start_location);
1172−}
1173−
1174−/* Returns the last source line number within an ordinary map. This
1175− is the (last) line of the #include, or other directive, that caused
1176− a map change. */
1177−inline linenum_type
1178−LAST_SOURCE_LINE (const line_map_ordinary *map)
1179−{
1180− return SOURCE_LINE (map, LAST_SOURCE_LINE_LOCATION (map));
1181−}
1182−
1183−/* Return the last column number within an ordinary map. */
11841192
1185−inline linenum_type
1186−LAST_SOURCE_COLUMN (const line_map_ordinary *map)
1193+inline location_t
1194+linemap_included_from (const line_map_ordinary *ord_map)
11871195 {
1188− return SOURCE_COLUMN (map, LAST_SOURCE_LINE_LOCATION (map));
1196+ return ord_map->included_from;
11891197 }
11901198
1191−/* Returns the map a given map was included from, or NULL if the map
1192− belongs to the main file, i.e, a file that wasn't included by
1193− another one. */
1194−inline line_map_ordinary *
1195−INCLUDED_FROM (struct line_maps *set, const line_map_ordinary *ord_map)
1196−{
1197− return ((ord_map->included_from == -1)
1198− ? NULL
1199− : LINEMAPS_ORDINARY_MAP_AT (set, ord_map->included_from));
1200−}
1199+/* The linemap containing the included-from location of MAP. */
1200+const line_map_ordinary *linemap_included_from_linemap
1201+ (line_maps *set, const line_map_ordinary *map);
12011202
12021203 /* True if the map is at the bottom of the include stack. */
12031204
12041205 inline bool
12051206 MAIN_FILE_P (const line_map_ordinary *ord_map)
12061207 {
1207− return ord_map->included_from < 0;
1208+ return ord_map->included_from == 0;
12081209 }
12091210
1210−/* Encode and return a source_location from a column number. The
1211+/* Encode and return a location_t from a column number. The
12111212 source line considered is the last source line used to call
12121213 linemap_line_start, i.e, the last source line which a location was
12131214 encoded from. */
1214−extern source_location
1215+extern location_t
12151216 linemap_position_for_column (struct line_maps *, unsigned int);
12161217
12171218 /* Encode and return a source location from a given line and
12181219 column. */
1219−source_location
1220+location_t
12201221 linemap_position_for_line_and_column (line_maps *set,
12211222 const line_map_ordinary *,
12221223 linenum_type, unsigned int);
12231224
1224−/* Encode and return a source_location starting from location LOC and
1225+/* Encode and return a location_t starting from location LOC and
12251226 shifting it by OFFSET columns. This function does not support
12261227 virtual locations. */
1227−source_location
1228+location_t
12281229 linemap_position_for_loc_and_offset (struct line_maps *set,
1229− source_location loc,
1230+ location_t loc,
12301231 unsigned int offset);
12311232
12321233 /* Return the file this map is for. */
@@ -1258,16 +1259,16 @@ LINEMAP_SYSP (const line_map_ordinary *ord_map) · 25 unmodified lines
12581259 the same token as the token for POST, and a negative value
12591260 otherwise. */
12601261 int linemap_compare_locations (struct line_maps *set,
1261− source_location pre,
1262− source_location post);
1262+ location_t pre,
1263+ location_t post);
12631264
12641265 /* Return TRUE if LOC_A denotes the location a token that comes
12651266 topogically before the token denoted by location LOC_B, or if they
12661267 are equal. */
12671268 inline bool
12681269 linemap_location_before_p (struct line_maps *set,
1269− source_location loc_a,
1270− source_location loc_b)
1270+ location_t loc_a,
1271+ location_t loc_b)
12711272 {
12721273 return linemap_compare_locations (set, loc_a, loc_b) >= 0;
12731274 }
@@ -1288,23 +1289,50 @@ typedef struct · 14 unmodified lines
12881289 bool sysp;
12891290 } expanded_location;
12901291
1291−/* A location within a rich_location: a caret&range, with
1292− the caret potentially flagged for display. */
1292+class range_label;
12931293
1294−struct location_range
1295−{
1296− source_location m_loc;
1294+/* A hint to diagnostic_show_locus on how to print a source range within a
1295+ rich_location.
12971296
1298− /* Should a caret be drawn for this range? Typically this is
1299− true for the 0th range, and false for subsequent ranges,
1300− but the Fortran frontend overrides this for rendering things like:
1297+ Typically this is SHOW_RANGE_WITH_CARET for the 0th range, and
1298+ SHOW_RANGE_WITHOUT_CARET for subsequent ranges,
1299+ but the Fortran frontend uses SHOW_RANGE_WITH_CARET repeatedly for
1300+ printing things like:
13011301
13021302 x = x + y
13031303 1 2
13041304 Error: Shapes for operands at (1) and (2) are not conformable
13051305
1306− where "1" and "2" are notionally carets. */
1307− bool m_show_caret_p;
1306+ where "1" and "2" are notionally carets. */
1307+
1308+enum range_display_kind
1309+{
1310+ /* Show the pertinent source line(s), the caret, and underline(s). */
1311+ SHOW_RANGE_WITH_CARET,
1312+
1313+ /* Show the pertinent source line(s) and underline(s), but don't
1314+ show the caret (just an underline). */
1315+ SHOW_RANGE_WITHOUT_CARET,
1316+
1317+ /* Just show the source lines; don't show the range itself.
1318+ This is for use when displaying some line-insertion fix-it hints (for
1319+ showing the user context on the change, for when it doesn't make sense
1320+ to highlight the first column on the next line). */
1321+ SHOW_LINES_WITHOUT_RANGE
1322+};
1323+
1324+/* A location within a rich_location: a caret&range, with
1325+ the caret potentially flagged for display, and an optional
1326+ label. */
1327+
1328+struct location_range
1329+{
1330+ location_t m_loc;
1331+
1332+ enum range_display_kind m_range_display_kind;
1333+
1334+ /* If non-NULL, the label for this range. */
1335+ const range_label *m_label;
13081336 };
13091337
13101338 /* A partially-embedded vec for use within rich_location for storing
@@ -1446,6 +1474,8 @@ class fixit_hint; · 135 unmodified lines
14461474 Additional ranges may be added to help the user identify other
14471475 pertinent clauses in a diagnostic.
14481476
1477+ Ranges can (optionally) be given labels via class range_label.
1478+
14491479 rich_location instances are intended to be allocated on the stack
14501480 when generating diagnostics, and to be short-lived.
14511481
@@ -1491,18 +1521,22 @@ class fixit_hint; · 39 unmodified lines
14911521 equal to their caret point. The frontend overrides the diagnostic
14921522 context's default caret character for these ranges.
14931523
1494− Example E
1495− *********
1524+ Example E (range labels)
1525+ ************************
14961526 printf ("arg0: %i arg1: %s arg2: %i",
14971527 ^~
1528+ |
1529+ const char *
14981530 100, 101, 102);
14991531 ~~~
1532+ |
1533+ int
15001534 This rich location has two ranges:
15011535 - range 0 is at the "%s" with start = caret = "%" and finish at
1502− the "s".
1536+ the "s". It has a range_label ("const char *").
15031537 - range 1 has start/finish covering the "101" and is not flagged for
1504− caret printing; it is perhaps at the start of "101".
1505−
1538+ caret printing. The caret is at the start of "101", where its
1539+ range_label is printed ("int").
15061540
15071541 Fix-it hints
15081542 ------------
@@ -1562,9 +1596,21 @@ class fixit_hint; · 53 unmodified lines
15621596 added via
15631597 richloc.add_fixit_replace ("color");
15641598
1599+ Example J: fix-it hint: line insertion
1600+ **************************************
1601+
1602+ 3 | #include <stddef.h>
1603+ + |+#include <stdio.h>
1604+ 4 | int the_next_line;
1605+
1606+ This rich location has a single range at line 4 column 1, marked
1607+ with SHOW_LINES_WITHOUT_RANGE (to avoid printing a meaningless caret
1608+ on the "i" of int). It has a insertion fix-it hint of the string
1609+ "#include <stdio.h>\n".
1610+
15651611 Adding a fix-it hint can fail: for example, attempts to insert content
15661612 at the transition between two line maps may fail due to there being no
1567− source_location (aka location_t) value to express the new location.
1613+ location_t value to express the new location.
15681614
15691615 Attempts to add a fix-it hint within a macro expansion will fail.
15701616
@@ -1594,21 +1640,25 @@ class rich_location · 23 unmodified lines
15941640 /* Constructors. */
15951641
15961642 /* Constructing from a location. */
1597− rich_location (line_maps *set, source_location loc);
1643+ rich_location (line_maps *set, location_t loc,
1644+ const range_label *label = NULL);
15981645
15991646 /* Destructor. */
16001647 ~rich_location ();
16011648
16021649 /* Accessors. */
1603− source_location get_loc () const { return get_loc (0); }
1604− source_location get_loc (unsigned int idx) const;
1650+ location_t get_loc () const { return get_loc (0); }
1651+ location_t get_loc (unsigned int idx) const;
16051652
16061653 void
1607− add_range (source_location loc, bool show_caret_p);
1654+ add_range (location_t loc,
1655+ enum range_display_kind range_display_kind
1656+ = SHOW_RANGE_WITHOUT_CARET,
1657+ const range_label *label = NULL);
16081658
16091659 void
1610− set_range (line_maps *set, unsigned int idx, source_location loc,
1611− bool show_caret_p);
1660+ set_range (unsigned int idx, location_t loc,
1661+ enum range_display_kind range_display_kind);
16121662
16131663 unsigned int get_num_locations () const { return m_ranges.count (); }
16141664
@@ -1631,7 +1681,7 @@ class rich_location · 16 unmodified lines
16311681
16321682 /* Suggest inserting NEW_CONTENT immediately before the start of WHERE. */
16331683 void
1634− add_fixit_insert_before (source_location where,
1684+ add_fixit_insert_before (location_t where,
16351685 const char *new_content);
16361686
16371687 /* Suggest inserting NEW_CONTENT immediately after the end of the primary
@@ -1641,7 +1691,7 @@ class rich_location · 3 unmodified lines
16411691
16421692 /* Suggest inserting NEW_CONTENT immediately after the end of WHERE. */
16431693 void
1644− add_fixit_insert_after (source_location where,
1694+ add_fixit_insert_after (location_t where,
16451695 const char *new_content);
16461696
16471697 /* Methods for adding removal fix-it hints. */
@@ -1653,7 +1703,7 @@ class rich_location · 5 unmodified lines
16531703 /* Suggest removing the content covered between the start and finish
16541704 of WHERE. */
16551705 void
1656− add_fixit_remove (source_location where);
1706+ add_fixit_remove (location_t where);
16571707
16581708 /* Suggest removing the content covered by SRC_RANGE. */
16591709 void
@@ -1668,7 +1718,7 @@ class rich_location · 8 unmodified lines
16681718 /* Suggest replacing the content between the start and finish of
16691719 WHERE with NEW_CONTENT. */
16701720 void
1671− add_fixit_replace (source_location where,
1721+ add_fixit_replace (location_t where,
16721722 const char *new_content);
16731723
16741724 /* Suggest replacing the content covered by SRC_RANGE with
@@ -1704,10 +1754,10 @@ class rich_location · 29 unmodified lines
17041754 }
17051755
17061756 private:
1707− bool reject_impossible_fixit (source_location where);
1757+ bool reject_impossible_fixit (location_t where);
17081758 void stop_supporting_fixits ();
1709− void maybe_add_fixit (source_location start,
1710− source_location next_loc,
1759+ void maybe_add_fixit (location_t start,
1760+ location_t next_loc,
17111761 const char *new_content);
17121762
17131763 public:
@@ -1729,6 +1779,56 @@ protected: · 15 unmodified lines
17291779 bool m_fixits_cannot_be_auto_applied;
17301780 };
17311781
1782+/* A struct for the result of range_label::get_text: a NUL-terminated buffer
1783+ of localized text, and a flag to determine if the caller should "free" the
1784+ buffer. */
1785+
1786+struct label_text
1787+{
1788+ label_text ()
1789+ : m_buffer (NULL), m_caller_owned (false)
1790+ {}
1791+
1792+ label_text (char *buffer, bool caller_owned)
1793+ : m_buffer (buffer), m_caller_owned (caller_owned)
1794+ {}
1795+
1796+ void maybe_free ()
1797+ {
1798+ if (m_caller_owned)
1799+ free (m_buffer);
1800+ }
1801+
1802+ char *m_buffer;
1803+ bool m_caller_owned;
1804+};
1805+
1806+/* Abstract base class for labelling a range within a rich_location
1807+ (e.g. for labelling expressions with their type).
1808+
1809+ Generating the text could require non-trivial work, so this work
1810+ is delayed (via the "get_text" virtual function) until the diagnostic
1811+ printing code "knows" it needs it, thus avoiding doing it e.g. for
1812+ warnings that are filtered by command-line flags. This virtual
1813+ function also isolates libcpp and the diagnostics subsystem from
1814+ the front-end and middle-end-specific code for generating the text
1815+ for the labels.
1816+
1817+ Like the rich_location instances they annotate, range_label instances
1818+ are intended to be allocated on the stack when generating diagnostics,
1819+ and to be short-lived. */
1820+
1821+class range_label
1822+{
1823+ public:
1824+ virtual ~range_label () {}
1825+
1826+ /* Get localized text for the label.
1827+ The RANGE_IDX is provided, allowing for range_label instances to be
1828+ shared by multiple ranges if need be (the "flyweight" design pattern). */
1829+ virtual label_text get_text (unsigned range_idx) const = 0;
1830+};
1831+
17321832 /* A fix-it hint: a suggested insertion, replacement, or deletion of text.
17331833 We handle these three types of edit with one class, by representing
17341834 them as replacement of a half-open range:
@@ -1746,16 +1846,16 @@ protected: · 11 unmodified lines
17461846 class fixit_hint
17471847 {
17481848 public:
1749− fixit_hint (source_location start,
1750− source_location next_loc,
1849+ fixit_hint (location_t start,
1850+ location_t next_loc,
17511851 const char *new_content);
17521852 ~fixit_hint () { free (m_bytes); }
17531853
17541854 bool affects_line_p (const char *file, int line) const;
1755− source_location get_start_loc () const { return m_start; }
1756− source_location get_next_loc () const { return m_next_loc; }
1757− bool maybe_append (source_location start,
1758− source_location next_loc,
1855+ location_t get_start_loc () const { return m_start; }
1856+ location_t get_next_loc () const { return m_next_loc; }
1857+ bool maybe_append (location_t start,
1858+ location_t next_loc,
17591859 const char *new_content);
17601860
17611861 const char *get_string () const { return m_bytes; }
@@ -1770,8 +1870,8 @@ class fixit_hint · 8 unmodified lines
17701870 this is a half-open/half-closed range:
17711871 [start, next_loc)
17721872 so that we can support insertion via start == next_loc. */
1773− source_location m_start;
1774− source_location m_next_loc;
1873+ location_t m_start;
1874+ location_t m_next_loc;
17751875 char *m_bytes;
17761876 size_t m_len;
17771877 };
@@ -1835,10 +1935,10 @@ enum location_resolution_kind · 57 unmodified lines
18351935 resolves to a location reserved for the client code, like
18361936 UNKNOWN_LOCATION or BUILTINS_LOCATION in GCC. */
18371937
1838−source_location linemap_resolve_location (struct line_maps *,
1839− source_location loc,
1840− enum location_resolution_kind lrk,
1841− const line_map_ordinary **loc_map);
1938+location_t linemap_resolve_location (struct line_maps *,
1939+ location_t loc,
1940+ enum location_resolution_kind lrk,
1941+ const line_map_ordinary **loc_map);
18421942
18431943 /* Suppose that LOC is the virtual location of a token coming from the
18441944 expansion of a macro M. This function then steps up to get the
@@ -1847,9 +1947,9 @@ source_location linemap_resolve_location (struct line_maps *, · 2 unmodified lines
18471947 the point where M' was expanded. LOC_MAP is an output parameter.
18481948 When non-NULL, *LOC_MAP is set to the map of the returned
18491949 location. */
1850−source_location linemap_unwind_toward_expansion (struct line_maps *,
1851− source_location loc,
1852− const struct line_map **loc_map);
1950+location_t linemap_unwind_toward_expansion (struct line_maps *,
1951+ location_t loc,
1952+ const struct line_map **loc_map);
18531953
18541954 /* If LOC is the virtual location of a token coming from the expansion
18551955 of a macro M and if its spelling location is reserved (e.g, a
@@ -1865,9 +1965,9 @@ source_location linemap_unwind_toward_expansion (struct line_maps *, · 9 unmodified lines
18651965
18661966 *MAP is set to the map of the returned location if the later is
18671967 different from LOC. */
1868−source_location linemap_unwind_to_first_non_reserved_loc (struct line_maps *,
1869− source_location loc,
1870− const struct line_map **map);
1968+location_t linemap_unwind_to_first_non_reserved_loc (struct line_maps *,
1969+ location_t loc,
1970+ const struct line_map **map);
18711971
18721972 /* Expand source code location LOC and return a user readable source
18731973 code location. LOC must be a spelling (non-virtual) location. If
@@ -1875,7 +1975,7 @@ source_location linemap_unwind_to_first_non_reserved_loc (struct line_maps *, · 1 unmodified line
18751975 location is returned. */
18761976 expanded_location linemap_expand_location (struct line_maps *,
18771977 const struct line_map *,
1878− source_location loc);
1978+ location_t loc);
18791979
18801980 /* Statistics about maps allocation and usage as returned by
18811981 linemap_get_statistics. */
@@ -1902,7 +2002,7 @@ struct linemap_stats · 20 unmodified lines
19022002 location emitted for that file. */
19032003 bool linemap_get_file_highest_location (struct line_maps * set,
19042004 const char *file_name,
1905− source_location *loc);
2005+ location_t *loc);
19062006
19072007 /* Compute and return statistics about the memory consumption of some
19082008 parts of the line table SET. */
@@ -1910,7 +2010,7 @@ void linemap_get_statistics (struct line_maps *, struct linemap_stats *); · 1 unmodified line
19102010
19112011 /* Dump debugging information about source location LOC into the file
19122012 stream STREAM. SET is the line map set LOC comes from. */
1913−void linemap_dump_location (struct line_maps *, source_location, FILE *);
2013+void linemap_dump_location (struct line_maps *, location_t, FILE *);
19142014
19152015 /* Dump line map at index IX in line table SET to STREAM. If STREAM
19162016 is NULL, use stderr. IS_MACRO is true if the caller wants to
@@ -1922,7 +2022,7 @@ void linemap_dump (FILE *, struct line_maps *, unsigned, bool); · 5 unmodified lines
19222022 specifies how many macro maps to dump. */
19232023 void line_table_dump (FILE *, struct line_maps *, unsigned int, unsigned int);
19242024
1925−/* An enum for distinguishing the various parts within a source_location. */
2025+/* An enum for distinguishing the various parts within a location_t. */
19262026
19272027 enum location_aspect
19282028 {
@@ -1931,14 +2031,14 @@ enum location_aspect · 2 unmodified lines
19312031 LOCATION_ASPECT_FINISH
19322032 };
19332033
1934−/* The rich_location class requires a way to expand source_location instances.
2034+/* The rich_location class requires a way to expand location_t instances.
19352035 We would directly use expand_location_to_spelling_point, which is
19362036 implemented in gcc/input.c, but we also need to use it for rich_location
19372037 within genmatch.c.
19382038 Hence we require client code of libcpp to implement the following
19392039 symbol. */
19402040 extern expanded_location
1941−linemap_client_expand_location_to_spelling_point (source_location,
2041+linemap_client_expand_location_to_spelling_point (location_t,
19422042 enum location_aspect);
19432043
19442044 #endif /* !LIBCPP_LINE_MAP_H */
gcc/libcpp/include/mkdeps.h+1−1
@@ -1,5 +1,5 @@
11 /* Dependency generator for Makefile fragments.
2− Copyright (C) 2000-2018 Free Software Foundation, Inc.
2+ Copyright (C) 2000-2019 Free Software Foundation, Inc.
33 Contributed by Zack Weinberg, Mar 2000
44
55 This program is free software; you can redistribute it and/or modify it
gcc/libcpp/include/symtab.h+1−1
@@ -1,5 +1,5 @@
11 /* Hash tables.
2− Copyright (C) 2000-2018 Free Software Foundation, Inc.
2+ Copyright (C) 2000-2019 Free Software Foundation, Inc.
33
44 This program is free software; you can redistribute it and/or modify it
55 under the terms of the GNU General Public License as published by the

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t