From: Nico Weber Date: Fri, 30 May 2014 17:27:21 +0000 (+0000) Subject: Let libc++abi compile with gcc. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=897f23dda82cae6e08c464509195be90015ed3c8;p=platform%2Fupstream%2Fllvm.git 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. No behavior change. llvm-svn: 209909 --- diff --git a/libcxxabi/src/cxa_demangle.cpp b/libcxxabi/src/cxa_demangle.cpp index ff28c79..c67e20f 100644 --- a/libcxxabi/src/cxa_demangle.cpp +++ b/libcxxabi/src/cxa_demangle.cpp @@ -4847,32 +4847,33 @@ operator!=(const malloc_alloc& x, const malloc_alloc& y) noexcept const size_t bs = 4 * 1024; template using Alloc = short_alloc; template using Vector = std::vector>; -using String = std::basic_string, malloc_alloc>; +template 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 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 sub_type; + typedef std::basic_string, + malloc_alloc> String; + typedef Vector> sub_type; typedef Vector template_param_type; - Vector names; - Vector subs; + sub_type names; + template_param_type subs; Vector template_param; unsigned cv; unsigned ref;