diff mbox series

[committed] d: Remove another dependency on the front-end OutBuffer type.

Message ID 20200625154124.2308216-1-ibuclaw@gdcproject.org
State New
Headers show
Series [committed] d: Remove another dependency on the front-end OutBuffer type. | expand

Commit Message

Iain Buclaw June 25, 2020, 3:41 p.m. UTC
Hi,

This patch removes another dependency on the front-end OutBuffer type.

As the DMD front-end never frees allocated memory, the glue layer
between the DMD front-end and GCC should generally avoid using DMD types
and interfaces if the purpose is internal only.

Bootstrapped and regression tested on x86_64-linux-gnu, and committed to
mainline.

Regards
Iain.

---
gcc/d/ChangeLog:

	* d-lang.cc (d_parse_file): Replace OutBuffer with obstack.
---
 gcc/d/d-lang.cc | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index e4d0a24c65c..2c474f8adea 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -1032,18 +1032,20 @@  d_parse_file (void)
       message ("binary    %s", global.params.argv0.ptr);
       message ("version   %s", global.version.ptr);
 
-      if (global.params.versionids)
+      if (global.versionids)
 	{
-	  OutBuffer buf;
-	  buf.writestring ("predefs  ");
-	  for (size_t i = 0; i < global.params.versionids->length; i++)
+	  obstack buffer;
+	  gcc_obstack_init (&buffer);
+	  obstack_grow (&buffer, "predefs  ", 9);
+	  for (size_t i = 0; i < global.versionids->length; i++)
 	    {
-	      const char *s = (*global.params.versionids)[i];
-	      buf.writestring (" ");
-	      buf.writestring (s);
+	      Identifier *id = (*global.versionids)[i];
+	      const char *str = id->toChars ();
+	      obstack_1grow (&buffer, ' ');
+	      obstack_grow (&buffer, str, strlen (str));
 	    }
 
-	  message ("%s", buf.peekChars ());
+	  message ("%s", (char *) obstack_finish (&buffer));
 	}
     }