[libcxxabi] [llvm] [ItaniumDemangle] Add customizable printLeft/printRight APIs to OutputBuffer (PR #133249)

Michael Buch via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 16 22:05:25 PDT 2025


================
@@ -79,10 +81,24 @@ class OutputBuffer {
   OutputBuffer(const OutputBuffer &) = delete;
   OutputBuffer &operator=(const OutputBuffer &) = delete;
 
+  virtual ~OutputBuffer() {}
+
   operator std::string_view() const {
     return std::string_view(Buffer, CurrentPosition);
   }
 
+  /// Called by the demangler when printing the demangle tree. By
+  /// default calls into \c Node::print{Left|Right} but can be overriden
+  /// by clients to track additional state when printing the demangled name.
+  virtual void printLeft(const Node &N);
+  virtual void printRight(const Node &N);
+
+  /// Called when we write to this object anywhere other than the end.
+  virtual void notifyInsertion(size_t /*Position*/, size_t /*Count*/) {}
+
+  /// Called when we reset the \c CurrentPosition of this object.
+  virtual void notifyPositionChanged(size_t /*OldPos*/, size_t /*NewPos*/) {}
----------------
Michael137 wrote:

I'll go with `notifyDeletion` for now since "resize" might get confused with resizing of the underlying buffer

https://github.com/llvm/llvm-project/pull/133249


More information about the llvm-commits mailing list