thakis created this revision.
thakis added a reviewer: mclow.lists.
thakis added a subscriber: cfe-commits.
I wanted a demangler that can demangle both Itanium-style and Microsoft-style
mangled symbols, and that runs on all of Windows, Linux, and Mac OS X. I used
libcxxabi's cxa_demangle for the Itanium demangling, but that required to get
it to build with gcc on Linux and with clang-cl/MSVC on Windows. It required
only small changes, and imho they look reasonable enough to send them upstream.
libstdc++ needs a few typedefs in malloc_alloc. MSVC's STL needs rebind(),
construct(), destroy().
MSVC2013 also has no snprintf, but it allegedly exists in 2015. (I haven't
tried building with 2015, though.)
http://reviews.llvm.org/D12895
Files:
src/cxa_demangle.cpp
Index: src/cxa_demangle.cpp
===================================================================
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -18,6 +18,13 @@
#include <cstring>
#include <cctype>
+#ifdef _MSC_VER
+// snprintf is implemented in VS 2015
+#if _MSC_VER < 1900
+#define snprintf _snprintf_s
+#endif
+#endif
+
namespace __cxxabiv1
{
@@ -4818,6 +4825,12 @@
{
public:
typedef T value_type;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
malloc_alloc() = default;
template <class U> malloc_alloc(const malloc_alloc<U>&) noexcept {}
@@ -4830,6 +4843,17 @@
{
std::free(p);
}
+
+ template <class U> struct rebind { using other = malloc_alloc<U>; };
+ template <class U, class... Args>
+ void construct(U* p, Args&&... args)
+ {
+ ::new ((void*)p) U(std::forward<Args>(args)...);
+ }
+ void destroy(T* p)
+ {
+ p->~T();
+ }
};
template <class T, class U>
Index: src/cxa_demangle.cpp
===================================================================
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -18,6 +18,13 @@
#include <cstring>
#include <cctype>
+#ifdef _MSC_VER
+// snprintf is implemented in VS 2015
+#if _MSC_VER < 1900
+#define snprintf _snprintf_s
+#endif
+#endif
+
namespace __cxxabiv1
{
@@ -4818,6 +4825,12 @@
{
public:
typedef T value_type;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
malloc_alloc() = default;
template <class U> malloc_alloc(const malloc_alloc<U>&) noexcept {}
@@ -4830,6 +4843,17 @@
{
std::free(p);
}
+
+ template <class U> struct rebind { using other = malloc_alloc<U>; };
+ template <class U, class... Args>
+ void construct(U* p, Args&&... args)
+ {
+ ::new ((void*)p) U(std::forward<Args>(args)...);
+ }
+ void destroy(T* p)
+ {
+ p->~T();
+ }
};
template <class T, class U>
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits