aboutsummaryrefslogtreecommitdiffstats
path: root/source/Core/Mangled.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Core/Mangled.cpp')
-rw-r--r--source/Core/Mangled.cpp72
1 files changed, 10 insertions, 62 deletions
diff --git a/source/Core/Mangled.cpp b/source/Core/Mangled.cpp
index c6759cc944ca..b06656aa3fb7 100644
--- a/source/Core/Mangled.cpp
+++ b/source/Core/Mangled.cpp
@@ -8,13 +8,6 @@
#include "lldb/Core/Mangled.h"
-#if defined(_WIN32)
-#include "lldb/Host/windows/windows.h"
-
-#include <dbghelp.h>
-#pragma comment(lib, "dbghelp.lib")
-#endif
-
#include "lldb/Core/RichManglingContext.h"
#include "lldb/Utility/ConstString.h"
#include "lldb/Utility/Log.h"
@@ -39,25 +32,6 @@
#include <string.h>
using namespace lldb_private;
-#if defined(_MSC_VER)
-static DWORD safeUndecorateName(const char *Mangled, char *Demangled,
- DWORD DemangledLength) {
- static std::mutex M;
- std::lock_guard<std::mutex> Lock(M);
- return ::UnDecorateSymbolName(
- Mangled, Demangled, DemangledLength,
- UNDNAME_NO_ACCESS_SPECIFIERS | // Strip public, private, protected
- // keywords
- UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall,
- // etc keywords
- UNDNAME_NO_THROW_SIGNATURES | // Strip throw() specifications
- UNDNAME_NO_MEMBER_TYPE | // Strip virtual, static, etc
- // specifiers
- UNDNAME_NO_MS_KEYWORDS // Strip all MS extension keywords
- );
-}
-#endif
-
static inline Mangled::ManglingScheme cstring_mangling_scheme(const char *s) {
if (s) {
if (s[0] == '?')
@@ -124,21 +98,6 @@ get_demangled_name_without_arguments(ConstString mangled,
}
#pragma mark Mangled
-// Default constructor
-Mangled::Mangled() : m_mangled(), m_demangled() {}
-
-// Constructor with an optional string and a boolean indicating if it is the
-// mangled version.
-Mangled::Mangled(ConstString s, bool mangled)
- : m_mangled(), m_demangled() {
- if (s)
- SetValue(s, mangled);
-}
-
-Mangled::Mangled(llvm::StringRef name, bool is_mangled) {
- if (!name.empty())
- SetValue(ConstString(name), is_mangled);
-}
Mangled::Mangled(ConstString s) : m_mangled(), m_demangled() {
if (s)
@@ -150,9 +109,6 @@ Mangled::Mangled(llvm::StringRef name) {
SetValue(ConstString(name));
}
-// Destructor
-Mangled::~Mangled() {}
-
// Convert to pointer operator. This allows code to check any Mangled objects
// to see if they contain anything valid using code such as:
//
@@ -218,28 +174,20 @@ void Mangled::SetValue(ConstString name) {
// Local helpers for different demangling implementations.
static char *GetMSVCDemangledStr(const char *M) {
-#if defined(_MSC_VER)
- const size_t demangled_length = 2048;
- char *demangled_cstr = static_cast<char *>(::malloc(demangled_length));
- ::ZeroMemory(demangled_cstr, demangled_length);
- DWORD result = safeUndecorateName(M, demangled_cstr, demangled_length);
+ char *demangled_cstr = llvm::microsoftDemangle(
+ M, nullptr, nullptr, nullptr,
+ llvm::MSDemangleFlags(llvm::MSDF_NoAccessSpecifier |
+ llvm::MSDF_NoCallingConvention |
+ llvm::MSDF_NoMemberType));
if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) {
if (demangled_cstr && demangled_cstr[0])
- log->Printf("demangled msvc: %s -> \"%s\"", M, demangled_cstr);
+ LLDB_LOGF(log, "demangled msvc: %s -> \"%s\"", M, demangled_cstr);
else
- log->Printf("demangled msvc: %s -> error: 0x%lu", M, result);
+ LLDB_LOGF(log, "demangled msvc: %s -> error", M);
}
- if (result != 0) {
- return demangled_cstr;
- } else {
- ::free(demangled_cstr);
- return nullptr;
- }
-#else
- return nullptr;
-#endif
+ return demangled_cstr;
}
static char *GetItaniumDemangledStr(const char *M) {
@@ -261,9 +209,9 @@ static char *GetItaniumDemangledStr(const char *M) {
if (Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_DEMANGLE)) {
if (demangled_cstr)
- log->Printf("demangled itanium: %s -> \"%s\"", M, demangled_cstr);
+ LLDB_LOGF(log, "demangled itanium: %s -> \"%s\"", M, demangled_cstr);
else
- log->Printf("demangled itanium: %s -> error: failed to demangle", M);
+ LLDB_LOGF(log, "demangled itanium: %s -> error: failed to demangle", M);
}
return demangled_cstr;