[libcxxabi] r248129 - Let cxa_demangle.cpp compile with gcc/libstdc++ 4.8 and clang-cl/MSVC2013's STL.

Yaron Keren via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 24 01:20:54 PDT 2015


Visual C++ 2013 update 5 (latest) does not appear to compile this, mainly
due to missing support for constexpr.

  https://msdn.microsoft.com/en-us/library/vstudio/hh567368.aspx

Visual C++ 2013 CTP has constexpr, but MS did not further update this
branch since Nov 2013.
The "regular" branch of 2013 update 5 is from Jul 2015.

Worth mentioning that either 2013 CTP or 2015 is required.


2015-09-20 21:10 GMT+03:00 Nico Weber via cfe-commits <
cfe-commits at lists.llvm.org>:

> Author: nico
> Date: Sun Sep 20 13:10:46 2015
> New Revision: 248129
>
> URL: http://llvm.org/viewvc/llvm-project?rev=248129&view=rev
> Log:
> Let cxa_demangle.cpp compile with gcc/libstdc++ 4.8 and
> clang-cl/MSVC2013's STL.
>
> libstdc++ needs a few typedefs in malloc_alloc. MSVC's STL needs rebind(),
> construct(), destroy().  MSVC2013 also has no snprintf, but it exists in
> 2015.
>
> Modified:
>     libcxxabi/trunk/src/cxa_demangle.cpp
>
> Modified: libcxxabi/trunk/src/cxa_demangle.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=248129&r1=248128&r2=248129&view=diff
>
> ==============================================================================
> --- libcxxabi/trunk/src/cxa_demangle.cpp (original)
> +++ libcxxabi/trunk/src/cxa_demangle.cpp Sun Sep 20 13:10:46 2015
> @@ -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 @@ class malloc_alloc
>  {
>  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 @@ public:
>      {
>          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
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150924/e0c4a058/attachment.html>


More information about the cfe-commits mailing list