[all-commits] [llvm/llvm-project] 201c4b: [demangler] Rust demangler buffer return

Nathan Sidwell via All-commits all-commits at lists.llvm.org
Wed Apr 13 08:50:56 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 201c4b9cc4a649e4a54b418749ab5b8bd227e4f0
  Author: Nathan Sidwell <nathan at acm.org>
  Date:   2022-04-13 (Wed, 13 Apr 2022)

  Changed paths:
    M lldb/source/Core/Mangled.cpp
    M llvm/include/llvm/Demangle/Demangle.h
    M llvm/lib/Demangle/Demangle.cpp
    M llvm/lib/Demangle/RustDemangle.cpp
    M llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp
    M llvm/unittests/Demangle/RustDemangleTest.cpp

  Log Message:
  [demangler] Rust demangler buffer return

The rust demangler has some odd buffer handling code, which will copy
the demangled string into the provided buffer, if it will fit.
Otherwise it uses the allocated buffer it made.  But the length of the
incoming buffer will have come from a previous call, which was the
length of the demangled string -- not the buffer size.  And of course,
we're unconditionally allocating a temporary buffer in the first
place.  So we don't actually get buffer reuse, and we get a memcpy in

However, nothing in LLVM ever passes in a non-null pointer.  Neither
does anything pass in a status pointer that is then made use of.  The
only exercise these have is in the test suite.

So let's just make the rust demangler have the same API as the dlang

Reviewed By: tmiasko

Differential Revision: https://reviews.llvm.org/D123420

More information about the All-commits mailing list