Emit DWARF info for all code section in an assembly file
[oota-llvm.git] / include / llvm / MC / MCLinkerOptimizationHint.h
index 3b0d933005ddcbef850fad97da30a8821f064c06..50fd527ffe2a5219cd7afbd7e199f6e82cb06bdb 100644 (file)
@@ -132,8 +132,19 @@ public:
   /// the given @p Layout.
   uint64_t getEmitSize(const MachObjectWriter &ObjWriter,
                        const MCAsmLayout &Layout) const {
-    std::string Buffer;
-    raw_string_ostream OutStream(Buffer);
+    class raw_counting_ostream : public raw_ostream {
+      uint64_t Count;
+
+      void write_impl(const char *, size_t size) override { Count += size; }
+
+      uint64_t current_pos() const override { return Count; }
+
+    public:
+      raw_counting_ostream() : Count(0) {}
+      ~raw_counting_ostream() { flush(); }
+    };
+
+    raw_counting_ostream OutStream;
     Emit_impl(OutStream, ObjWriter, Layout);
     return OutStream.tell();
   }