From 330a968c0ad9c465993dda9f034475117039a893 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 6 Dec 2019 08:25:12 +0000 Subject: genmatch.c (c_expr::gen_transform): Emit newlines from line number changes rather than after every semicolon. 2019-12-06 Richard Biener * genmatch.c (c_expr::gen_transform): Emit newlines from line number changes rather than after every semicolon. From-SVN: r279034 --- gcc/ChangeLog | 5 +++++ gcc/genmatch.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3e747a6..e626e45 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2019-12-06 Richard Biener + * genmatch.c (c_expr::gen_transform): Emit newlines from line + number changes rather than after every semicolon. + +2019-12-06 Richard Biener + PR tree-optimization/92819 * match.pd (VEC_PERM_EXPR -> BIT_INSERT_EXPR): Handle inserts into the last lane. For two-element vectors try inserting diff --git a/gcc/genmatch.c b/gcc/genmatch.c index a822ce5..4a21bc9 100644 --- a/gcc/genmatch.c +++ b/gcc/genmatch.c @@ -2599,10 +2599,22 @@ c_expr::gen_transform (FILE *f, int indent, const char *dest, fprintf_indent (f, indent, "%s = ", dest); unsigned stmt_nr = 1; + int prev_line = -1; for (unsigned i = 0; i < code.length (); ++i) { const cpp_token *token = &code[i]; + /* We can't recover from all lexing losses but we can roughly restore line + breaks from location info. */ + const line_map_ordinary *map; + linemap_resolve_location (line_table, token->src_loc, + LRK_SPELLING_LOCATION, &map); + expanded_location loc = linemap_expand_location (line_table, map, + token->src_loc); + if (prev_line != -1 && loc.line != prev_line) + fputc ('\n', f); + prev_line = loc.line; + /* Replace captures for code-gen. */ if (token->type == CPP_ATSIGN) { @@ -2653,11 +2665,11 @@ c_expr::gen_transform (FILE *f, int indent, const char *dest, if (token->type == CPP_SEMICOLON) { stmt_nr++; - fputc ('\n', f); if (dest && stmt_nr == nr_stmts) fprintf_indent (f, indent, "%s = ", dest); } } + fputc ('\n', f); } /* Generate transform code for a capture. */ -- cgit v1.1