mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-23 20:46:06 +00:00

The demangling terminate handler uses a function `demangle()` to perform the demangling. This function returns an `std::unique_ptr`, relying on custom deleter and `const_cast` hacks to deal with the facts that only one branch actually allocates, and that the pointer type needs to be `const char*`. However, the destructor of the returned `std::unique_ptr` will never actually run, because the sole place this function is ever called is right before the terminate handler aborts the program. So all this is unnecessary, and creates a dependency onto `<memory>`. This change removes the `demangle()` function and replaces the call with an immediately invoked lambda expression that simply returns a raw pointer in both cases, which should be fine because the memory can never be freed here anyways.