gcc/libcpp
Tom Tromey 46427374e1 Linemap infrastructure for virtual locations
This is the first instalment of a set which goal is to track locations
of tokens across macro expansions.  Tom Tromey did the original work
and attached the patch to PR preprocessor/7263.  This opus is a
derivative of that original work.

This patch modifies the linemap module of libcpp to add virtual
locations support.

A virtual location is a mapped location that can resolve to several
different physical locations.  It can always resolve to the spelling
location of a token.  For tokens resulting from macro expansion it can
resolve to:
  - either the location of the expansion point of the macro.
  - or the location of the token in the definition of the
  macro
  - or, if the token is an argument of a function-like macro,
  the location of the use of the matching macro parameter in
  the definition of the macro

The patch creates a new type of line map called a macro map.  For every
single macro expansion, there is a macro map that generates a virtual
location for every single resulting token of the expansion.

The good old type of line map we all know is now called an ordinary
map.  That one still encodes spelling locations as it has always had.

As a result linemap_lookup as been extended to return a macro map when
given a virtual location resulting from a macro expansion.  The layout
of structs line_map has changed to support this new type of map.  So
did the layout of struct line_maps.  Accessor macros have been
introduced to avoid messing with the implementation details of these
datastructures directly.  This helped already as we have been testing
different ways of arranging these datastructure.  Having to constantly
adjust client code that is too tied with the internals of line_map and
line_maps would have been even more painful.

Of course, many new public functions have been added to the linemap
module to handle the resolution of virtual locations.

This patch introduces the infrastructure but no part of the compiler
uses virtual locations yet.

However the client code of the linemap data structures has been
adjusted as per the changes.  E.g, it's not anymore reliable for a
client code to manipulate struct line_map directly if it just wants to
deal with spelling locations, because struct line_map can now
represent a macro map as well.  In that case, it's better to use the
convenient API to resolve the initial (possibly virtual) location to a
spelling location (or to an ordinary map) and use that.

This is the reason why the patch adjusts the Java, Ada and Fortran
front ends.

Also, note that virtual locations are not supposed to be ordered for
relations '<' and '>' anymore.  To test if a virtual location appears
"before" another one, one has to use a new operator exposed by the
line map interface.  The patch updates the only spot (in the
diagnostics module) I have found that was making the assumption that
locations were ordered for these relations.  This is the only change
that introduces a use of the new line map API in this patch, so I am
adding a regression test for it only.

From-SVN: r180081
2011-10-17 11:58:56 +02:00
..
include Linemap infrastructure for virtual locations 2011-10-17 11:58:56 +02:00
po be.po, [...]: Update. 2011-07-08 20:29:04 +01:00
aclocal.m4
ChangeLog Linemap infrastructure for virtual locations 2011-10-17 11:58:56 +02:00
charset.c Update Copyright years for files modified in 2010. 2011-01-03 21:52:22 +01:00
config.in
configure Set need_64bit_hwint to yes for x86 targets. 2011-07-28 07:29:38 -07:00
configure.ac Set need_64bit_hwint to yes for x86 targets. 2011-07-28 07:29:38 -07:00
directives-only.c LINEMAP_POSITION_FOR_COLUMN had the exact same effect as linemap_position_for_column... 2011-08-15 20:35:58 +00:00
directives.c Linemap infrastructure for virtual locations 2011-10-17 11:58:56 +02:00
errors.c Update Copyright years for files modified in 2010. 2011-01-03 21:52:22 +01:00
expr.c Make UNSPEC/UNSPECV constants use the enum; Fix 48192; Add test case for 48053 2011-03-21 16:21:30 +00:00
files.c Linemap infrastructure for virtual locations 2011-10-17 11:58:56 +02:00
identifiers.c
init.c Linemap infrastructure for virtual locations 2011-10-17 11:58:56 +02:00
internal.h Linemap infrastructure for virtual locations 2011-10-17 11:58:56 +02:00
lex.c Add ability to force lexed tokens' source_locations. 2011-08-22 20:41:07 +00:00
line-map.c Linemap infrastructure for virtual locations 2011-10-17 11:58:56 +02:00
macro.c Linemap infrastructure for virtual locations 2011-10-17 11:58:56 +02:00
Makefile.in Update Copyright years for files modified in 2010. 2011-01-03 21:52:22 +01:00
makeucnid.c
mkdeps.c files.c (file_hash_eq): Use filename_cmp instead of strcmp. 2011-03-25 20:11:26 +01:00
pch.c remove useless if-before-free tests 2011-04-20 18:19:03 +00:00
symtab.c
system.h system.h [...]: Wrap C function declarations in extern "C". 2011-07-25 14:26:58 +00:00
traditional.c
ucnid.h
ucnid.tab