<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, May 30, 2014 at 7:50 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Fri, May 30, 2014 at 10:27 AM, Nico Weber <<a href="mailto:nicolasweber@gmx.de">nicolasweber@gmx.de</a>> wrote:<br>
> Author: nico<br>
> Date: Fri May 30 12:27:21 2014<br>
> New Revision: 209909<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=209909&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=209909&view=rev</a><br>
> Log:<br>
> Let libc++abi compile with gcc.<br>
><br>
> There was a single problem in cxa_demangle.cpp, where gcc would complain<br>
> `error: changes meaning of 'String'` about the line `typedef String String;`.<br>
> According to 3.3.7p2, this diagnostic is allowed (but not required, so clang<br>
> does not have to report this).<br>
><br>
> As a fix, make string_pair a template and pass String as template parameter.<br>
> This fixes the error with gcc and also removes some repetition from the code.<br>
<br>
</div>Seems like a ind of painful workaround to introduce a template with<br>
one instantiation...<br></blockquote><div><br></div><div>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 :-)</div><div>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">What's the point of that typedef anyway?<br></blockquote><div><br></div><div>Several template functions above do "C::String", so Db needs to have a String typedef.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
><br>
> No behavior change.<br>
><br>
> Modified:<br>
> libcxxabi/trunk/src/cxa_demangle.cpp<br>
><br>
> Modified: libcxxabi/trunk/src/cxa_demangle.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=209909&r1=209908&r2=209909&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=209909&r1=209908&r2=209909&view=diff</a><br>
> ==============================================================================<br>
> --- libcxxabi/trunk/src/cxa_demangle.cpp (original)<br>
> +++ libcxxabi/trunk/src/cxa_demangle.cpp Fri May 30 12:27:21 2014<br>
> @@ -4847,32 +4847,33 @@ operator!=(const malloc_alloc<T>& x, con<br>
> const size_t bs = 4 * 1024;<br>
> template <class T> using Alloc = short_alloc<T, bs>;<br>
> template <class T> using Vector = std::vector<T, Alloc<T>>;<br>
> -using String = std::basic_string<char, std::char_traits<char>, malloc_alloc<char>>;<br>
><br>
> +template <class StrT><br>
> struct string_pair<br>
> {<br>
> - String first;<br>
> - String second;<br>
> + StrT first;<br>
> + StrT second;<br>
><br>
> string_pair() = default;<br>
> - string_pair(String f) : first(std::move(f)) {}<br>
> - string_pair(String f, String s)<br>
> + string_pair(StrT f) : first(std::move(f)) {}<br>
> + string_pair(StrT f, StrT s)<br>
> : first(std::move(f)), second(std::move(s)) {}<br>
> template <size_t N><br>
> string_pair(const char (&s)[N]) : first(s, N-1) {}<br>
><br>
> size_t size() const {return first.size() + second.size();}<br>
> - String full() const {return first + second;}<br>
> - String move_full() {return std::move(first) + std::move(second);}<br>
> + StrT full() const {return first + second;}<br>
> + StrT move_full() {return std::move(first) + std::move(second);}<br>
> };<br>
><br>
> struct Db<br>
> {<br>
> - typedef String String;<br>
> - typedef Vector<string_pair> sub_type;<br>
> + typedef std::basic_string<char, std::char_traits<char>,<br>
> + malloc_alloc<char>> String;<br>
> + typedef Vector<string_pair<String>> sub_type;<br>
> typedef Vector<sub_type> template_param_type;<br>
> - Vector<string_pair> names;<br>
> - Vector<sub_type> subs;<br>
> + sub_type names;<br>
> + template_param_type subs;<br>
> Vector<template_param_type> template_param;<br>
> unsigned cv;<br>
> unsigned ref;<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div>