Files
gcc/libcpp/location-example.txt
David Malcolm 620e594be5 Eliminate source_location in favor of location_t
Historically GCC used location_t, while libcpp used source_location.

This inconsistency has been annoying me for a while, so this patch
removes source_location in favor of location_t throughout
(as the latter is shorter).

gcc/ChangeLog:
	* builtins.c: Replace "source_location" with "location_t".
	* diagnostic-show-locus.c: Likewise.
	* diagnostic.c: Likewise.
	* dumpfile.c: Likewise.
	* gcc-rich-location.h: Likewise.
	* genmatch.c: Likewise.
	* gimple.h: Likewise.
	* gimplify.c: Likewise.
	* input.c: Likewise.
	* input.h: Likewise.  Eliminate the typedef.
	* omp-expand.c: Likewise.
	* selftest.h: Likewise.
	* substring-locations.h (get_source_location_for_substring):
	Rename to..
	(get_location_within_string): ...this.
	* tree-cfg.c: Replace "source_location" with "location_t".
	* tree-cfgcleanup.c: Likewise.
	* tree-diagnostic.c: Likewise.
	* tree-into-ssa.c: Likewise.
	* tree-outof-ssa.c: Likewise.
	* tree-parloops.c: Likewise.
	* tree-phinodes.c: Likewise.
	* tree-phinodes.h: Likewise.
	* tree-ssa-loop-ivopts.c: Likewise.
	* tree-ssa-loop-manip.c: Likewise.
	* tree-ssa-phiopt.c: Likewise.
	* tree-ssa-phiprop.c: Likewise.
	* tree-ssa-threadupdate.c: Likewise.
	* tree-ssa.c: Likewise.
	* tree-ssa.h: Likewise.
	* tree-vect-loop-manip.c: Likewise.

gcc/c-family/ChangeLog:
	* c-common.c (c_get_substring_location): Update for renaming of
	get_source_location_for_substring to get_location_within_string.
	* c-lex.c: Replace "source_location" with "location_t".
	* c-opts.c: Likewise.
	* c-ppoutput.c: Likewise.

gcc/c/ChangeLog:
	* c-decl.c: Replace "source_location" with "location_t".
	* c-tree.h: Likewise.
	* c-typeck.c: Likewise.
	* gimple-parser.c: Likewise.

gcc/cp/ChangeLog:
	* call.c: Replace "source_location" with "location_t".
	* cp-tree.h: Likewise.
	* cvt.c: Likewise.
	* name-lookup.c: Likewise.
	* parser.c: Likewise.
	* typeck.c: Likewise.

gcc/fortran/ChangeLog:
	* cpp.c: Replace "source_location" with "location_t".
	* gfortran.h: Likewise.

gcc/go/ChangeLog:
	* go-gcc-diagnostics.cc: Replace "source_location" with "location_t".
	* go-gcc.cc: Likewise.
	* go-linemap.cc: Likewise.
	* go-location.h: Likewise.
	* gofrontend/README: Likewise.

gcc/jit/ChangeLog:
	* jit-playback.c: Replace "source_location" with "location_t".

gcc/testsuite/ChangeLog:
	* g++.dg/plugin/comment_plugin.c: Replace "source_location" with
	"location_t".
	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Likewise.

libcc1/ChangeLog:
	* libcc1plugin.cc: Replace "source_location" with "location_t".
	(plugin_context::get_source_location): Rename to...
	(plugin_context::get_location_t): ...this.
	* libcp1plugin.cc: Likewise.

libcpp/ChangeLog:
	* charset.c: Replace "source_location" with "location_t".
	* directives-only.c: Likewise.
	* directives.c: Likewise.
	* errors.c: Likewise.
	* expr.c: Likewise.
	* files.c: Likewise.
	* include/cpplib.h: Likewise.  Rename MAX_SOURCE_LOCATION to
	MAX_LOCATION_T.
	* include/line-map.h: Likewise.
	* init.c: Likewise.
	* internal.h: Likewise.
	* lex.c: Likewise.
	* line-map.c: Likewise.
	* location-example.txt: Likewise.
	* macro.c: Likewise.
	* pch.c: Likewise.
	* traditional.c: Likewise.

From-SVN: r266085
2018-11-13 20:05:03 +00:00

233 lines
6.7 KiB
Plaintext

Consider compiling test.c, with this content:
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
#include "test.h"
int
main (int argc, char **argv)
{
int a = PLUS (1,2);
int b = PLUS (3,4);
return 0;
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...where test.h has this content:
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
extern int foo ();
#define PLUS(A, B) A + B
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The undocumented -fdump-internal-locations option outputs this information
to stderr, showing what each location_t value means. Source code
lines are quoted, showing both per-line location_t values and
per-line&column location_t values (written vertically under the
corresponding character of source code).
VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
RESERVED LOCATIONS
location_t interval: 0 <= loc < 2
ORDINARY MAP: 0
location_t interval: 32 <= loc < 64
file: test.c
starting at line: 1
column bits: 12
range bits: 5
test.c: 1|loc: 32|#include "test.h"
|69269258258148147
|46802468024680246
ORDINARY MAP: 1
location_t interval: 64 <= loc < 96
file: <built-in>
starting at line: 0
column bits: 0
range bits: 0
ORDINARY MAP: 2
location_t interval: 96 <= loc < 128
file: <command-line>
starting at line: 0
column bits: 0
range bits: 0
ORDINARY MAP: 3
location_t interval: 128 <= loc < 160128
file: /usr/include/stdc-predef.h
starting at line: 1
column bits: 12
range bits: 5
(contents of /usr/include/stdc-predef.h snipped for brevity)
ORDINARY MAP: 4
location_t interval: 160128 <= loc < 160160
file: <command-line>
starting at line: 32
column bits: 12
range bits: 5
ORDINARY MAP: 5
location_t interval: 160160 <= loc < 164256
file: test.c
starting at line: 1
column bits: 12
range bits: 5
test.c: 1|loc:160160|#include "test.h"
|00000000000000000
|12223334445556667
|92582581481470470
|24680246802468024
ORDINARY MAP: 6
location_t interval: 164256 <= loc < 173280
file: test.h
starting at line: 1
column bits: 12
range bits: 5
test.h: 1|loc:164256|extern int foo ();
|444444444444444444
|233344455566677788
|825814814704703603
|802468024680246802
test.h: 2|loc:168352|
|
|
|
|
test.h: 3|loc:172448|#define PLUS(A, B) A + B
|222222222222222223333333
|455566677788889990001112
|814704703603692692582581
|024680246802468024680246
ORDINARY MAP: 7
location_t interval: 173280 <= loc < 202016
file: test.c
starting at line: 2
column bits: 12
range bits: 5
test.c: 2|loc:173280|
|
|
|
|
test.c: 3|loc:177376|int
|777
|444
|047
|802
test.c: 4|loc:181472|main (int argc, char **argv)
|1111111111111111222222222222
|5556666777888999000111222333
|0360369269258258148147047036
|4680246802468024680246802468
test.c: 5|loc:185568|{
|5
|6
|0
|0
test.c: 6|loc:189664| int a = PLUS (1,2);
|999999999900000000000
|677788899900011122233
|926925825814814704703
|680246802468024680246
test.c: 7|loc:193760| int b = PLUS (3,4);
|333333344444444444444
|788899900011122233344
|925825814814704703603
|246802468024680246802
test.c: 8|loc:197856| return 0;
|77778888888
|89990001112
|82581481470
|80246802468
test.c: 9|loc:201952|}
|1
|9
|8
|4
UNALLOCATED LOCATIONS
location_t interval: 202016 <= loc < 2147483633
MACRO 1: PLUS (7 tokens)
location_t interval: 2147483633 <= loc < 2147483640
test.c:7:11: note: expansion point is location 194115
int b = PLUS (3,4);
^~~~
map->start_location: 2147483633
macro_locations:
0: 194304, 173088
test.c:7:17: note: token 0 has x-location == 194304
int b = PLUS (3,4);
^
test.c:7:17: note: token 0 has y-location == 173088
1: 173152, 173152
In file included from test.c:1:0:
test.h:3:22: note: token 1 has x-location == y-location == 173152
#define PLUS(A, B) A + B
^
2: 194368, 173216
test.c:7:19: note: token 2 has x-location == 194368
int b = PLUS (3,4);
^
test.c:7:19: note: token 2 has y-location == 173216
3: 0, 2947526575
cc1: note: token 3 has x-location == 0
cc1: note: token 3 has y-location == 2947526575
4: 2947526575, 2947526575
x-location == y-location == 2947526575 encodes token # 800042942
5: 2947526575, 2947526575
x-location == y-location == 2947526575 encodes token # 800042942
6: 2947526575, 2947526575
x-location == y-location == 2947526575 encodes token # 800042942
MACRO 0: PLUS (7 tokens)
location_t interval: 2147483640 <= loc < 2147483647
test.c:6:11: note: expansion point is location 190019
int a = PLUS (1,2);
^~~~
map->start_location: 2147483640
macro_locations:
0: 190208, 173088
test.c:6:17: note: token 0 has x-location == 190208
int a = PLUS (1,2);
^
test.c:6:17: note: token 0 has y-location == 173088
1: 173152, 173152
In file included from test.c:1:0:
test.h:3:22: note: token 1 has x-location == y-location == 173152
#define PLUS(A, B) A + B
^
2: 190272, 173216
test.c:6:19: note: token 2 has x-location == 190272
int a = PLUS (1,2);
^
test.c:6:19: note: token 2 has y-location == 173216
3: 0, 2947526575
cc1: note: token 3 has x-location == 0
cc1: note: token 3 has y-location == 2947526575
4: 2947526575, 2947526575
x-location == y-location == 2947526575 encodes token # 800042935
5: 2947526575, 2947526575
x-location == y-location == 2947526575 encodes token # 800042935
6: 2947526575, 2947526575
x-location == y-location == 2947526575 encodes token # 800042935
MAX_LOCATION_T
location_t interval: 2147483647 <= loc < 2147483648
AD-HOC LOCATIONS
location_t interval: 2147483648 <= loc < 4294967295
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^