//===--- Demangle.h ---------------------------------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_DEMANGLE_DEMANGLE_H #define LLVM_DEMANGLE_DEMANGLE_H #include <cstddef> #include <string> #include <string_view> namespace llvm { /// This is a llvm local version of __cxa_demangle. Other than the name and /// being in the llvm namespace it is identical. /// /// The mangled_name is demangled into buf and returned. If the buffer is not /// large enough, realloc is used to expand it. /// /// The *status will be set to a value from the following enumeration enum : int { … }; /// Returns a non-NULL pointer to a NUL-terminated C style string /// that should be explicitly freed, if successful. Otherwise, may return /// nullptr if mangled_name is not a valid mangling or is nullptr. char *itaniumDemangle(std::string_view mangled_name, bool ParseParams = true); enum MSDemangleFlags { … }; /// Demangles the Microsoft symbol pointed at by mangled_name and returns it. /// Returns a pointer to the start of a null-terminated demangled string on /// success, or nullptr on error. /// If n_read is non-null and demangling was successful, it receives how many /// bytes of the input string were consumed. /// status receives one of the demangle_ enum entries above if it's not nullptr. /// Flags controls various details of the demangled representation. char *microsoftDemangle(std::string_view mangled_name, size_t *n_read, int *status, MSDemangleFlags Flags = MSDF_None); // Demangles a Rust v0 mangled symbol. char *rustDemangle(std::string_view MangledName); // Demangles a D mangled symbol. char *dlangDemangle(std::string_view MangledName); /// Attempt to demangle a string using different demangling schemes. /// The function uses heuristics to determine which demangling scheme to use. /// \param MangledName - reference to string to demangle. /// \returns - the demangled string, or a copy of the input string if no /// demangling occurred. std::string demangle(std::string_view MangledName); bool nonMicrosoftDemangle(std::string_view MangledName, std::string &Result, bool CanHaveLeadingDot = true, bool ParseParams = true); /// "Partial" demangler. This supports demangling a string into an AST /// (typically an intermediate stage in itaniumDemangle) and querying certain /// properties or partially printing the demangled name. struct ItaniumPartialDemangler { … }; } // namespace llvm #endif