Add debug routines to dump locations to a stream
authorDodji Seketeli <dodji@redhat.com>
Fri, 6 Jan 2017 00:47:05 +0000 (01:47 +0100)
committerDodji Seketeli <dodji@redhat.com>
Fri, 6 Jan 2017 00:48:33 +0000 (01:48 +0100)
* src/abg-writer.cc (dump_location): Define new function and one
overload.
(dump_decl_location): Re-write in terms of the new dump_location.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-writer.cc

index 32bff45737f0eb9e4ca522c3bb2449e352190ed9..803e26d3c45bb7d08e17b2928dd3d2938a79bc6b 100644 (file)
@@ -3754,23 +3754,41 @@ dump(const translation_unit_sptr t)
     dump(*t);
 }
 
-/// Serialize the source location of a decl to an output stream for
-/// debugging purposes.
+/// Serialize a source location to an output stream.
 ///
-/// @param d the declaration to consider.
+/// @param l the declaration to consider.
 ///
-/// @param o the output stream to serizalize the location to.
+/// @param o the output stream to serialize to.
 void
-dump_decl_location(const decl_base& d, ostream& o)
+dump_location(const location& l, ostream& o)
 {
   string path;
   unsigned line = 0, col = 0;
 
-  const location& l = d.get_location();
   l.expand(path, line, col);
   o << path << ":" << line << "," << col << "\n";
 }
 
+/// Serialize a source location for debugging purposes.
+///
+/// The location is serialized to the standard error output stream.
+///
+/// @param l the declaration to consider.
+///
+void
+dump_location(const location& l)
+{dump_location(l, cerr);}
+
+/// Serialize the source location of a decl to an output stream for
+/// debugging purposes.
+///
+/// @param d the declaration to consider.
+///
+/// @param o the output stream to serizalize the location to.
+void
+dump_decl_location(const decl_base& d, ostream& o)
+{dump_location(d.get_location(), o);}
+
 /// Serialize the source location of a decl to stderr for debugging
 /// purposes.
 ///