Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / libcpp / include / line-map.h
index 4e30742..a0d6da1 100644 (file)
@@ -1,6 +1,5 @@
 /* Map logical line numbers to (source file, line number) pairs.
-   Copyright (C) 2001, 2003, 2004, 2007, 2008, 2009, 2010, 2011
-   Free Software Foundation, Inc.
+   Copyright (C) 2001-2013 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
@@ -89,7 +88,7 @@ struct GTY(()) line_map_ordinary {
 
 /* This is the highest possible source location encoded within an
    ordinary or macro map.  */
-#define MAX_SOURCE_LOCATION 0xFFFFFFFF
+#define MAX_SOURCE_LOCATION 0x7FFFFFFF
 
 struct cpp_hashnode;
 
@@ -159,13 +158,13 @@ struct GTY(()) line_map_macro {
 
      Note that a virtual location is a location returned by
      linemap_add_macro_token.  It encodes the relevant locations (x,y
-     pairs) of that token accross the macro expansions from which it
+     pairs) of that token across the macro expansions from which it
      (the token) might come from.
 
      In the example above x1 (for token "+") is going to be the same
      as y1.  x0 is the spelling location for the argument token "1",
      and x2 is the spelling location for the argument token "2".  */
-  source_location * GTY((length ("2 * %h.n_tokens"))) macro_locations;
+  source_location * GTY((atomic)) macro_locations;
 
   /* This is the location of the expansion point of the current macro
      map.  It's the location of the macro name.  That location is held
@@ -259,6 +258,31 @@ struct GTY(()) maps_info {
   unsigned int cache;
 };
 
+/* Data structure to associate an arbitrary data to a source location.  */
+struct GTY(()) location_adhoc_data {
+  source_location locus;
+  void * GTY((skip)) data;
+};
+
+struct htab;
+
+/* The following data structure encodes a location with some adhoc data
+   and maps it to a new unsigned integer (called an adhoc location)
+   that replaces the original location to represent the mapping.
+
+   The new adhoc_loc uses the highest bit as the enabling bit, i.e. if the
+   highest bit is 1, then the number is adhoc_loc. Otherwise, it serves as
+   the original location. Once identified as the adhoc_loc, the lower 31
+   bits of the integer is used to index the location_adhoc_data array,
+   in which the locus and associated data is stored.  */
+
+struct GTY(()) location_adhoc_data_map {
+  struct htab * GTY((skip)) htab;
+  source_location curr_loc;
+  unsigned int allocated;
+  struct location_adhoc_data GTY((length ("%h.allocated"))) *data;
+};
+
 /* A set of chronological line_map structures.  */
 struct GTY(()) line_maps {
   
@@ -289,6 +313,8 @@ struct GTY(()) line_maps {
   /* The allocators' function used to know the actual size it
      allocated, for a certain allocation size requested.  */
   line_map_round_alloc_size_func round_alloc_size;
+
+  struct location_adhoc_data_map location_adhoc_data_map;
 };
 
 /* Returns the pointer to the memory region where information about
@@ -370,7 +396,7 @@ struct GTY(()) line_maps {
 #define LINEMAPS_LAST_ALLOCATED_ORDINARY_MAP(SET) \
   LINEMAPS_LAST_ALLOCATED_MAP(SET, false)
 
-/* Returns a pointer to the begining of the region where macro maps
+/* Returns a pointer to the beginning of the region where macro maps
    are allcoated.  */
 #define LINEMAPS_MACRO_MAPS(SET) \
   LINEMAPS_MAPS(SET, true)
@@ -408,6 +434,19 @@ struct GTY(()) line_maps {
 #define LINEMAPS_LAST_ALLOCATED_MACRO_MAP(SET) \
   LINEMAPS_LAST_ALLOCATED_MAP (SET, true)
 
+extern void location_adhoc_data_fini (struct line_maps *);
+extern source_location get_combined_adhoc_loc (struct line_maps *,
+                                              source_location, void *);
+extern void *get_data_from_adhoc_loc (struct line_maps *, source_location);
+extern source_location get_location_from_adhoc_loc (struct line_maps *,
+                                                   source_location);
+
+#define IS_ADHOC_LOC(LOC) (((LOC) & MAX_SOURCE_LOCATION) != (LOC))
+#define COMBINE_LOCATION_DATA(SET, LOC, BLOCK) \
+  get_combined_adhoc_loc ((SET), (LOC), (BLOCK))
+
+extern void rebuild_location_adhoc_htab (struct line_maps *);
+
 /* Initialize a line map set.  */
 extern void linemap_init (struct line_maps *);
 
@@ -450,7 +489,7 @@ extern const struct line_map *linemap_add
 extern const struct line_map *linemap_lookup
   (struct line_maps *, source_location);
 
-/* Returns TRUE if the line table set tracks token locations accross
+/* Returns TRUE if the line table set tracks token locations across
    macro expansion, FALSE otherwise.  */
 bool linemap_tracks_macro_expansion_locs_p (struct line_maps *);
 
@@ -594,6 +633,8 @@ typedef struct
 
   int column;
 
+  void *data;
+
   /* In a system header?. */
   bool sysp;
 } expanded_location;
@@ -651,7 +692,7 @@ enum location_resolution_kind
    LRK_SPELLING_LOCATION.
 
    If LOC_MAP is not NULL, *LOC_MAP is set to the map encoding the
-   returned location.  Note that if the resturned location wasn't originally
+   returned location.  Note that if the returned location wasn't originally
    encoded by a map, the *MAP is set to NULL.  This can happen if LOC
    resolves to a location reserved for the client code, like
    UNKNOWN_LOCATION or BUILTINS_LOCATION in GCC.  */
@@ -666,12 +707,30 @@ source_location linemap_resolve_location (struct line_maps *,
    location L of the point where M got expanded.  If L is a spelling
    location inside a macro expansion M', then this function returns
    the point where M' was expanded.  LOC_MAP is an output parameter.
-   When non-NULL, *LOC_MAP is set the the map of the returned
+   When non-NULL, *LOC_MAP is set to the map of the returned
    location.  */
 source_location linemap_unwind_toward_expansion (struct line_maps *,
                                                 source_location loc,
                                                 const struct line_map **loc_map);
 
+/* If LOC is the virtual location of a token coming from the expansion
+   of a macro M and if its spelling location is reserved (e.g, a
+   location for a built-in token), then this function unwinds (using
+   linemap_unwind_toward_expansion) the location until a location that
+   is not reserved and is not in a system header is reached.  In other
+   words, this unwinds the reserved location until a location that is
+   in real source code is reached.
+
+   Otherwise, if the spelling location for LOC is not reserved or if
+   LOC doesn't come from the expansion of a macro, the function
+   returns LOC as is and *MAP is not touched.
+
+   *MAP is set to the map of the returned location if the later is
+   different from LOC.  */
+source_location linemap_unwind_to_first_non_reserved_loc (struct line_maps *,
+                                                         source_location loc,
+                                                         const struct line_map **map);
+
 /* Expand source code location LOC and return a user readable source
    code location.  LOC must be a spelling (non-virtual) location.  If
    it's a location < RESERVED_LOCATION_COUNT a zeroed expanded source