[GOOGLE] Updates highest_location when updating next_discriminator_location
Dehao Chen
dehao@google.com
Tue May 13 18:45:00 GMT 2014
Attached patch passes regression tests and benchmark test. OK for google-4_9?
Thanks,
Dehao
On Tue, May 13, 2014 at 10:43 AM, Dehao Chen <dehao@google.com> wrote:
> As discussed offline, this is actually due to missing parts of the
> previous patch (some changes does not appear in the change log of
> r199154). I've updated the patch to include those missing pieces.
> Testing on going.
>
> Dehao
>
> On Tue, May 13, 2014 at 10:04 AM, Cary Coutant <ccoutant@google.com> wrote:
>>> The problem is that linemap_location_from_macro_expansion_p will
>>> always return true if locus has discriminator. And in linemap_lookup,
>>> this will lead to call linemap_macro_map_lookup, in which there is an
>>> assertion:
>>>
>>> linemap_assert (line >= LINEMAPS_MACRO_LOWEST_LOCATION (set));
>>>
>>> However, line is actually not a macro location.
>>
>> That sounds like we're leaking a discriminator location into the
>> linemap code. Before you can call
>> linemap_location_from_macro_expansion_p, you need to do this (as in
>> expand_location_1):
>>
>> /* If LOC describes a location with a discriminator, extract the
>> discriminator and map it to the real location. */
>> if (min_discriminator_location != UNKNOWN_LOCATION
>> && loc >= min_discriminator_location
>> && loc < next_discriminator_location)
>> loc = map_discriminator_location (loc);
>>
>> -cary
-------------- next part --------------
Index: gcc/diagnostic.c
===================================================================
--- gcc/diagnostic.c (revision 210386)
+++ gcc/diagnostic.c (working copy)
@@ -188,6 +188,7 @@ diagnostic_set_info_translated (diagnostic_info *d
va_list *args, location_t location,
diagnostic_t kind)
{
+ location = map_discriminator_location (location);
diagnostic->message.err_no = errno;
diagnostic->message.args_ptr = args;
diagnostic->message.format_spec = msg;
@@ -514,6 +515,9 @@ diagnostic_report_current_module (diagnostic_conte
if (where <= BUILTINS_LOCATION)
return;
+ if (has_discriminator (where))
+ where = map_discriminator_location (where);
+
linemap_resolve_location (line_table, where,
LRK_MACRO_DEFINITION_LOCATION,
&map);
Index: gcc/tree-ssa-uninit.c
===================================================================
--- gcc/tree-ssa-uninit.c (revision 210386)
+++ gcc/tree-ssa-uninit.c (working copy)
@@ -149,6 +149,7 @@ warn_uninit (enum opt_code wc, tree t,
location = (context != NULL && gimple_has_location (context))
? gimple_location (context)
: DECL_SOURCE_LOCATION (var);
+ location = map_discriminator_location (location);
location = linemap_resolve_location (line_table, location,
LRK_SPELLING_LOCATION,
NULL);
Index: gcc/tree-diagnostic.c
===================================================================
--- gcc/tree-diagnostic.c (revision 210386)
+++ gcc/tree-diagnostic.c (working copy)
@@ -108,6 +108,8 @@ maybe_unwind_expanded_macro_loc (diagnostic_contex
unsigned ix;
loc_map_pair loc, *iter;
+ if (has_discriminator (where))
+ where = map_discriminator_location (where);
map = linemap_lookup (line_table, where);
if (!linemap_macro_expansion_map_p (map))
return;
Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c (revision 210386)
+++ gcc/builtins.c (working copy)
@@ -59,6 +59,7 @@ along with GCC; see the file COPYING3. If not see
#include "builtins.h"
#include "ubsan.h"
#include "cilk.h"
+#include "input.h"
static tree do_mpc_arg1 (tree, tree, int (*)(mpc_ptr, mpc_srcptr, mpc_rnd_t));
@@ -12064,13 +12065,16 @@ fold_builtin_next_arg (tree exp, bool va_start_p)
tree fntype = TREE_TYPE (current_function_decl);
int nargs = call_expr_nargs (exp);
tree arg;
+ location_t loc = LOCATION_LOCUS (input_location);
+ if (has_discriminator (loc))
+ loc = map_discriminator_location (loc);
+
/* There is good chance the current input_location points inside the
definition of the va_start macro (perhaps on the token for
builtin) in a system header, so warnings will not be emitted.
Use the location in real source code. */
source_location current_location =
- linemap_unwind_to_first_non_reserved_loc (line_table, input_location,
- NULL);
+ linemap_unwind_to_first_non_reserved_loc (line_table, loc, NULL);
if (!stdarg_p (fntype))
{
More information about the Gcc-patches
mailing list