diff options
author | Ying Chen <chying@google.com> | 2015-05-28 21:06:33 +0000 |
---|---|---|
committer | Ying Chen <chying@google.com> | 2015-05-28 21:06:33 +0000 |
commit | fd6c7ad3cefb12ce02f756262a2d5c95bbf6e3c3 (patch) | |
tree | fe95beec9b7838823e94d895d4802f09716deb69 | |
parent | 1135e709c0b5073ca9fb54eebbb852c2a697033d (diff) | |
download | bcm5719-llvm-fd6c7ad3cefb12ce02f756262a2d5c95bbf6e3c3.tar.gz bcm5719-llvm-fd6c7ad3cefb12ce02f756262a2d5c95bbf6e3c3.zip |
Revert "Allow both MSVC and Itanium mangling schemes."
Cause build break.
This reverts commit 6d986061393f2863fec739e04412281148acc1f3.
llvm-svn: 238496
-rw-r--r-- | lldb/include/lldb/Core/Mangled.h | 7 | ||||
-rw-r--r-- | lldb/source/Core/CxaDemangle.cpp | 74 | ||||
-rw-r--r-- | lldb/source/Core/Mangled.cpp | 101 |
3 files changed, 64 insertions, 118 deletions
diff --git a/lldb/include/lldb/Core/Mangled.h b/lldb/include/lldb/Core/Mangled.h index a307bac470d..87b23799882 100644 --- a/lldb/include/lldb/Core/Mangled.h +++ b/lldb/include/lldb/Core/Mangled.h @@ -41,13 +41,6 @@ public: ePreferDemangledWithoutArguments }; - enum ManglingScheme - { - eManglingSchemeNone = 0, - eManglingSchemeMSVC, - eManglingSchemeItanium - }; - //---------------------------------------------------------------------- /// Default constructor. /// diff --git a/lldb/source/Core/CxaDemangle.cpp b/lldb/source/Core/CxaDemangle.cpp index 16cdb0211a1..5c05db97927 100644 --- a/lldb/source/Core/CxaDemangle.cpp +++ b/lldb/source/Core/CxaDemangle.cpp @@ -8,18 +8,9 @@ // - Stripped GCC attributes() // - Removed extern "C" from the cxa_demangle function // - Added "#undef _LIBCPP_EXTERN_TEMPLATE" to avoid warning -// - Implemented missing rebind, construct, destroy in malloc_alloc -// - Replaced noexcept, constexpr, alignas with their LLVM_* equivalents -// - Included win32.h for snprintf implementation for MSVC -// - Removed constexpr member initialization for MSVC -// - Changed argument to alignas() to a literal for MSVC //---------------------------------------------------------------------- -#if defined(_MSC_VER) -#include "lldb/Host/windows/win32.h" // snprintf -#endif -#include "llvm/Support/Compiler.h" // LLVM_{NOEXCEPT, CONSTEXPR, ALIGNAS} -#undef _LIBCPP_EXTERN_TEMPLATE // Avoid warning below +#undef _LIBCPP_EXTERN_TEMPLATE // Avoid warning below //===-------------------------- cxa_demangle.cpp --------------------------===// // @@ -161,20 +152,20 @@ struct float_data<float> { static const size_t mangled_size = 8; static const size_t max_demangled_size = 24; - static const char* spec; + static constexpr const char* spec = "%af"; }; -const char* float_data<float>::spec = "%af"; +constexpr const char* float_data<float>::spec; template <> struct float_data<double> { static const size_t mangled_size = 16; static const size_t max_demangled_size = 32; - static const char* spec; + static constexpr const char* spec = "%a"; }; -const char* float_data<double>::spec = "%a"; +constexpr const char* float_data<double>::spec; template <> struct float_data<long double> @@ -185,10 +176,10 @@ struct float_data<long double> static const size_t mangled_size = 20; // May need to be adjusted to 16 or 24 on other platforms #endif static const size_t max_demangled_size = 40; - static const char* spec; + static constexpr const char* spec = "%LaL"; }; -const char* float_data<long double>::spec = "%LaL"; +constexpr const char* float_data<long double>::spec; template <class Float, class C> const char* @@ -4731,27 +4722,27 @@ template <std::size_t N> class arena { static const std::size_t alignment = 16; - LLVM_ALIGNAS(16) char buf_[N]; + alignas(alignment) char buf_[N]; char* ptr_; std::size_t - align_up(std::size_t n) LLVM_NOEXCEPT + align_up(std::size_t n) noexcept {return (n + (alignment-1)) & ~(alignment-1);} bool - pointer_in_buffer(char* p) LLVM_NOEXCEPT + pointer_in_buffer(char* p) noexcept {return buf_ <= p && p <= buf_ + N;} public: - arena() LLVM_NOEXCEPT : ptr_(buf_) {} + arena() noexcept : ptr_(buf_) {} ~arena() {ptr_ = nullptr;} arena(const arena&) = delete; arena& operator=(const arena&) = delete; char* allocate(std::size_t n); - void deallocate(char* p, std::size_t n) LLVM_NOEXCEPT; + void deallocate(char* p, std::size_t n) noexcept; - static LLVM_CONSTEXPR std::size_t size() {return N;} + static constexpr std::size_t size() {return N;} std::size_t used() const {return static_cast<std::size_t>(ptr_ - buf_);} void reset() {ptr_ = buf_;} }; @@ -4772,7 +4763,7 @@ arena<N>::allocate(std::size_t n) template <std::size_t N> void -arena<N>::deallocate(char* p, std::size_t n) LLVM_NOEXCEPT +arena<N>::deallocate(char* p, std::size_t n) noexcept { if (pointer_in_buffer(p)) { @@ -4794,9 +4785,9 @@ public: public: template <class _Up> struct rebind {typedef short_alloc<_Up, N> other;}; - short_alloc(arena<N>& a) LLVM_NOEXCEPT : a_(a) {} + short_alloc(arena<N>& a) noexcept : a_(a) {} template <class U> - short_alloc(const short_alloc<U, N>& a) LLVM_NOEXCEPT + short_alloc(const short_alloc<U, N>& a) noexcept : a_(a.a_) {} short_alloc(const short_alloc&) = default; short_alloc& operator=(const short_alloc&) = delete; @@ -4805,7 +4796,7 @@ public: { return reinterpret_cast<T*>(a_.allocate(n*sizeof(T))); } - void deallocate(T* p, std::size_t n) LLVM_NOEXCEPT + void deallocate(T* p, std::size_t n) noexcept { a_.deallocate(reinterpret_cast<char*>(p), n*sizeof(T)); } @@ -4813,7 +4804,7 @@ public: template <class T1, std::size_t N1, class U, std::size_t M> friend bool - operator==(const short_alloc<T1, N1>& x, const short_alloc<U, M>& y) LLVM_NOEXCEPT; + operator==(const short_alloc<T1, N1>& x, const short_alloc<U, M>& y) noexcept; template <class U, std::size_t M> friend class short_alloc; }; @@ -4821,7 +4812,7 @@ public: template <class T, std::size_t N, class U, std::size_t M> inline bool -operator==(const short_alloc<T, N>& x, const short_alloc<U, M>& y) LLVM_NOEXCEPT +operator==(const short_alloc<T, N>& x, const short_alloc<U, M>& y) noexcept { return N == M && &x.a_ == &y.a_; } @@ -4829,7 +4820,7 @@ operator==(const short_alloc<T, N>& x, const short_alloc<U, M>& y) LLVM_NOEXCEPT template <class T, std::size_t N, class U, std::size_t M> inline bool -operator!=(const short_alloc<T, N>& x, const short_alloc<U, M>& y) LLVM_NOEXCEPT +operator!=(const short_alloc<T, N>& x, const short_alloc<U, M>& y) noexcept { return !(x == y); } @@ -4841,39 +4832,22 @@ public: typedef T value_type; malloc_alloc() = default; - template <class U> malloc_alloc(const malloc_alloc<U>&) LLVM_NOEXCEPT {} + template <class U> malloc_alloc(const malloc_alloc<U>&) noexcept {} T* allocate(std::size_t n) { return static_cast<T*>(std::malloc(n*sizeof(T))); } - void deallocate(T* p, std::size_t) LLVM_NOEXCEPT + void deallocate(T* p, std::size_t) noexcept { std::free(p); } - template<class Other> - struct rebind - { - typedef malloc_alloc<Other> other; - }; - void construct(T *p) - { - ::new (p) T(); - } - void construct(T *p, const T& t) - { - ::new (p) T(t); - } - void destroy(T *p) - { - p->~T(); - } }; template <class T, class U> inline bool -operator==(const malloc_alloc<T>&, const malloc_alloc<U>&) LLVM_NOEXCEPT +operator==(const malloc_alloc<T>&, const malloc_alloc<U>&) noexcept { return true; } @@ -4881,7 +4855,7 @@ operator==(const malloc_alloc<T>&, const malloc_alloc<U>&) LLVM_NOEXCEPT template <class T, class U> inline bool -operator!=(const malloc_alloc<T>& x, const malloc_alloc<U>& y) LLVM_NOEXCEPT +operator!=(const malloc_alloc<T>& x, const malloc_alloc<U>& y) noexcept { return !(x == y); } diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index d277db7e053..48d118236a3 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -13,7 +13,6 @@ #if defined(_MSC_VER) #include "lldb/Host/windows/windows.h" #include <Dbghelp.h> -#define LLDB_USE_BUILTIN_DEMANGLER #elif defined (__FreeBSD__) #define LLDB_USE_BUILTIN_DEMANGLER #else @@ -45,23 +44,16 @@ using namespace lldb_private; -static inline Mangled::ManglingScheme -cstring_mangling_scheme(const char *s) -{ - if (s) - { - if (s[0] == '?') - return Mangled::eManglingSchemeMSVC; - if (s[0] == '_' && s[1] == 'Z') - return Mangled::eManglingSchemeItanium; - } - return Mangled::eManglingSchemeNone; -} - static inline bool -cstring_is_mangled(const char *s) +cstring_is_mangled (const char *s) { - return cstring_mangling_scheme(s) != Mangled::eManglingSchemeNone; + if (s) +#if defined(_MSC_VER) + return (s[0] == '?'); +#else + return (s[0] == '_' && s[1] == 'Z'); +#endif + return false; } static const ConstString & @@ -272,58 +264,45 @@ Mangled::GetDemangledName () const m_mangled.GetCString()); // Don't bother running anything that isn't mangled - const char *mangled_name = m_mangled.GetCString(); - ManglingScheme mangling_scheme{cstring_mangling_scheme(mangled_name)}; - if (mangling_scheme != eManglingSchemeNone && - !m_mangled.GetMangledCounterpart(m_demangled)) + const char *mangled_cstr = m_mangled.GetCString(); + if (cstring_is_mangled(mangled_cstr)) { - // We didn't already mangle this name, demangle it and if all goes well - // add it to our map. - char *demangled_name = nullptr; - switch (mangling_scheme) + if (!m_mangled.GetMangledCounterpart(m_demangled)) { - case eManglingSchemeMSVC: + // We didn't already mangle this name, demangle it and if all goes well + // add it to our map. +#ifdef LLDB_USE_BUILTIN_DEMANGLER + // Try to use the fast-path demangler first for the + // performance win, falling back to the full demangler only + // when necessary + char *demangled_name = FastDemangle (mangled_cstr, + m_mangled.GetLength()); + if (!demangled_name) + demangled_name = __cxa_demangle (mangled_cstr, NULL, NULL, NULL); +#elif defined(_MSC_VER) + char *demangled_name = (char *)::malloc(1024); + ::ZeroMemory(demangled_name, 1024); + DWORD result = ::UnDecorateSymbolName(mangled_cstr, demangled_name, 1023, + 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 + ); + if (result == 0) { -#if defined(_MSC_VER) - const size_t demangled_length = 2048; - demangled_name = static_cast<char *>(::malloc(demangled_length)); - ::ZeroMemory(demangled_name, demangled_length); - DWORD result = ::UnDecorateSymbolName(mangled_name, demangled_name, demangled_length, - 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 - ); - if (result == 0) - { - free(demangled_name); - demangled_name = nullptr; - } -#endif - break; + free (demangled_name); + demangled_name = nullptr; } - case eManglingSchemeItanium: - { -#ifdef LLDB_USE_BUILTIN_DEMANGLER - // Try to use the fast-path demangler first for the - // performance win, falling back to the full demangler only - // when necessary - demangled_name = FastDemangle(mangled_name, m_mangled.GetLength()); - if (!demangled_name) - demangled_name = __cxa_demangle(mangled_name, NULL, NULL, NULL); #else - demangled_name = abi::__cxa_demangle(mangled_name, NULL, NULL, NULL); + char *demangled_name = abi::__cxa_demangle (mangled_cstr, NULL, NULL, NULL); #endif - break; + + if (demangled_name) + { + m_demangled.SetCStringWithMangledCounterpart(demangled_name, m_mangled); + free (demangled_name); } - case eManglingSchemeNone: - break; - } - if (demangled_name) - { - m_demangled.SetCStringWithMangledCounterpart(demangled_name, m_mangled); - free(demangled_name); } } if (!m_demangled) |