diff options
author | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-07-19 03:39:37 +0200 |
---|---|---|
committer | lat9nq <22451773+lat9nq@users.noreply.github.com> | 2023-07-19 04:39:26 +0200 |
commit | 1ab3bd5a5eb966ce3966688857c6fa516039c1c2 (patch) | |
tree | 0666011e6ddd40c71534c1827f86f7b297170edf /externals/demangle/llvm/Demangle/Demangle.h | |
parent | CMake: Require LLVM 17 or later (diff) | |
download | yuzu-1ab3bd5a5eb966ce3966688857c6fa516039c1c2.tar yuzu-1ab3bd5a5eb966ce3966688857c6fa516039c1c2.tar.gz yuzu-1ab3bd5a5eb966ce3966688857c6fa516039c1c2.tar.bz2 yuzu-1ab3bd5a5eb966ce3966688857c6fa516039c1c2.tar.lz yuzu-1ab3bd5a5eb966ce3966688857c6fa516039c1c2.tar.xz yuzu-1ab3bd5a5eb966ce3966688857c6fa516039c1c2.tar.zst yuzu-1ab3bd5a5eb966ce3966688857c6fa516039c1c2.zip |
Diffstat (limited to 'externals/demangle/llvm/Demangle/Demangle.h')
-rw-r--r-- | externals/demangle/llvm/Demangle/Demangle.h | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/externals/demangle/llvm/Demangle/Demangle.h b/externals/demangle/llvm/Demangle/Demangle.h index 5b673e4e1..1552a501a 100644 --- a/externals/demangle/llvm/Demangle/Demangle.h +++ b/externals/demangle/llvm/Demangle/Demangle.h @@ -12,6 +12,7 @@ #include <cstddef> #include <string> +#include <string_view> namespace llvm { /// This is a llvm local version of __cxa_demangle. Other than the name and @@ -29,9 +30,10 @@ enum : int { demangle_success = 0, }; -char *itaniumDemangle(const char *mangled_name, char *buf, size_t *n, - int *status); - +/// 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); enum MSDemangleFlags { MSDF_None = 0, @@ -40,10 +42,34 @@ enum MSDemangleFlags { MSDF_NoCallingConvention = 1 << 2, MSDF_NoReturnType = 1 << 3, MSDF_NoMemberType = 1 << 4, + MSDF_NoVariableType = 1 << 5, }; -char *microsoftDemangle(const char *mangled_name, char *buf, size_t *n, + +/// 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); + /// "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. @@ -59,7 +85,7 @@ struct ItaniumPartialDemangler { bool partialDemangle(const char *MangledName); /// Just print the entire mangled name into Buf. Buf and N behave like the - /// second and third parameters to itaniumDemangle. + /// second and third parameters to __cxa_demangle. char *finishDemangle(char *Buf, size_t *N) const; /// Get the base name of a function. This doesn't include trailing template @@ -95,6 +121,7 @@ struct ItaniumPartialDemangler { bool isSpecialName() const; ~ItaniumPartialDemangler(); + private: void *RootNode; void *Context; |