public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Diagnostic included-from loop
@ 2018-08-06 15:32 Nathan Sidwell
  2018-08-06 15:57 ` David Malcolm
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Sidwell @ 2018-08-06 15:32 UTC (permalink / raw)
  To: David Malcolm; +Cc: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 503 bytes --]

We currently emit the 'included from' information in a peeled-once loop. 
  This patch rerolls the loop.  It'll make some future changes simpler, 
and we're not at all worried about speed here -- it's a diagnostic!

In the long term, the include-at path will include modules (imported 
at).  Having single logic to figure that out is simpler.

In the near future, I have a patch to change the representation of the 
included-from information, which I'll get to shortly.

ok?

nathan

-- 
Nathan Sidwell

[-- Attachment #2: diag.diff --]
[-- Type: text/x-patch, Size: 1663 bytes --]

2018-08-06  Nathan Sidwell  <nathan@acm.org>

	* diagnostic.c (diagnostic_report_current_module): Reroll
	included-at loop.

Index: diagnostic.c
===================================================================
--- diagnostic.c	(revision 263332)
+++ diagnostic.c	(working copy)
@@ -587,22 +587,26 @@ diagnostic_report_current_module (diagno
       set_last_module (context, map);
       if (! MAIN_FILE_P (map))
 	{
-	  map = INCLUDED_FROM (line_table, map);
-	  const char *line_col
-	    = maybe_line_and_column (LAST_SOURCE_LINE (map),
-				     context->show_column
-				     ? LAST_SOURCE_COLUMN (map) : 0);
-	  pp_verbatim (context->printer,
-		       "In file included from %r%s%s%R", "locus",
-		       LINEMAP_FILE (map), line_col);
-	  while (! MAIN_FILE_P (map))
+	  bool first = true;
+	  do
 	    {
 	      map = INCLUDED_FROM (line_table, map);
-	      line_col = maybe_line_and_column (LAST_SOURCE_LINE (map), 0);
-	      pp_verbatim (context->printer,
-			   ",\n                 from %r%s%s%R", "locus",
-			   LINEMAP_FILE (map), line_col);
+	      const char *line_col
+		= maybe_line_and_column (LAST_SOURCE_LINE (map),
+					 first && context->show_column
+					 ? SOURCE_COLUMN (map, where) : 0);
+	      static const char *const msgs[] =
+		{
+		 N_("In file included from"),
+		 N_("                 from"),
+		};
+	      unsigned index = !first;
+	      pp_verbatim (context->printer, "%s%s %r%s%s%R",
+			   first ? "" : ",\n", _(msgs[index]),
+			   "locus", LINEMAP_FILE (map), line_col);
+	      first = false;
 	    }
+	  while (! MAIN_FILE_P (map));
 	  pp_verbatim (context->printer, ":");
 	  pp_newline (context->printer);
 	}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Diagnostic included-from loop
  2018-08-06 15:32 [PATCH] Diagnostic included-from loop Nathan Sidwell
@ 2018-08-06 15:57 ` David Malcolm
  0 siblings, 0 replies; 2+ messages in thread
From: David Malcolm @ 2018-08-06 15:57 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: GCC Patches

On Mon, 2018-08-06 at 11:32 -0400, Nathan Sidwell wrote:
> We currently emit the 'included from' information in a peeled-once
> loop. 
>   This patch rerolls the loop.  It'll make some future changes
> simpler, 
> and we're not at all worried about speed here -- it's a diagnostic!
> 
> In the long term, the include-at path will include modules (imported 
> at).  Having single logic to figure that out is simpler.
> 
> In the near future, I have a patch to change the representation of
> the 
> included-from information, which I'll get to shortly.
> 
> ok?
> 
> nathan

I believe the only functional change here is that the strings are now
marked for translation, and translated.

OK for trunk, assuming you performed the usual testing on this patch.

Dave

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-06 15:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-06 15:32 [PATCH] Diagnostic included-from loop Nathan Sidwell
2018-08-06 15:57 ` David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).