Make all raw_ostreams support the tell() function.
[oota-llvm.git] / lib / Support / raw_ostream.cpp
index f62a31d199028fc982d9678c22f7bc18a7599534..6ac37bc840c6a534a45d863aeccfa129ff45af0d 100644 (file)
@@ -339,6 +339,12 @@ void raw_os_ostream::write_impl(const char *Ptr, unsigned Size) {
   OS.write(Ptr, Size);
 }
 
+uint64_t raw_os_ostream::current_pos() { return OS.tellp(); }
+
+uint64_t raw_os_ostream::tell() { 
+  return (uint64_t)OS.tellp() + GetNumBytesInBuffer(); 
+}
+
 //===----------------------------------------------------------------------===//
 //  raw_string_ostream
 //===----------------------------------------------------------------------===//
@@ -363,3 +369,8 @@ void raw_svector_ostream::write_impl(const char *Ptr, unsigned Size) {
   OS.append(Ptr, Ptr + Size);
 }
 
+uint64_t raw_svector_ostream::current_pos() { return OS.size(); }
+
+uint64_t raw_svector_ostream::tell() { 
+  return OS.size() + GetNumBytesInBuffer(); 
+}