[libcxxabi] r209909 - Let libc++abi compile with gcc.

Nico Weber thakis at chromium.org
Fri May 30 11:13:59 PDT 2014


On Fri, May 30, 2014 at 7:50 PM, David Blaikie <dblaikie at gmail.com> wrote:

> On Fri, May 30, 2014 at 10:27 AM, Nico Weber <nicolasweber at gmx.de> wrote:
> > Author: nico
> > Date: Fri May 30 12:27:21 2014
> > New Revision: 209909
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=209909&view=rev
> > Log:
> > Let libc++abi compile with gcc.
> >
> > There was a single problem in cxa_demangle.cpp, where gcc would complain
> > `error: changes meaning of 'String'` about the line `typedef String
> String;`.
> > According to 3.3.7p2, this diagnostic is allowed (but not required, so
> clang
> > does not have to report this).
> >
> > As a fix, make string_pair a template and pass String as template
> parameter.
> > This fixes the error with gcc and also removes some repetition from the
> code.
>
> Seems like a ind of painful workaround to introduce a template with
> one instantiation...
>

I agree it looks a bit weird, but it seemed better to me than repeating the
type. If you can come up with something nice, feel free to improve on this
:-)


> What's the point of that typedef anyway?
>

Several template functions above do "C::String", so Db needs to have a
String typedef.


>
> >
> > No behavior change.
> >
> > 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=209909&r1=209908&r2=209909&view=diff
> >
> ==============================================================================
> > --- libcxxabi/trunk/src/cxa_demangle.cpp (original)
> > +++ libcxxabi/trunk/src/cxa_demangle.cpp Fri May 30 12:27:21 2014
> > @@ -4847,32 +4847,33 @@ operator!=(const malloc_alloc<T>& x, con
> >  const size_t bs = 4 * 1024;
> >  template <class T> using Alloc = short_alloc<T, bs>;
> >  template <class T> using Vector = std::vector<T, Alloc<T>>;
> > -using String = std::basic_string<char, std::char_traits<char>,
> malloc_alloc<char>>;
> >
> > +template <class StrT>
> >  struct string_pair
> >  {
> > -    String first;
> > -    String second;
> > +    StrT first;
> > +    StrT second;
> >
> >      string_pair() = default;
> > -    string_pair(String f) : first(std::move(f)) {}
> > -    string_pair(String f, String s)
> > +    string_pair(StrT f) : first(std::move(f)) {}
> > +    string_pair(StrT f, StrT s)
> >          : first(std::move(f)), second(std::move(s)) {}
> >      template <size_t N>
> >          string_pair(const char (&s)[N]) : first(s, N-1) {}
> >
> >      size_t size() const {return first.size() + second.size();}
> > -    String full() const {return first + second;}
> > -    String move_full() {return std::move(first) + std::move(second);}
> > +    StrT full() const {return first + second;}
> > +    StrT move_full() {return std::move(first) + std::move(second);}
> >  };
> >
> >  struct Db
> >  {
> > -    typedef String String;
> > -    typedef Vector<string_pair> sub_type;
> > +    typedef std::basic_string<char, std::char_traits<char>,
> > +                              malloc_alloc<char>> String;
> > +    typedef Vector<string_pair<String>> sub_type;
> >      typedef Vector<sub_type> template_param_type;
> > -    Vector<string_pair> names;
> > -    Vector<sub_type> subs;
> > +    sub_type names;
> > +    template_param_type subs;
> >      Vector<template_param_type> template_param;
> >      unsigned cv;
> >      unsigned ref;
> >
> >
> > _______________________________________________
> > cfe-commits mailing list
> > cfe-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140530/d7ba98f1/attachment.html>


More information about the cfe-commits mailing list