diff options
-rw-r--r-- | libcxxabi/src/cxa_demangle.cpp | 102 | ||||
-rw-r--r-- | libcxxabi/test/test_demangle.cpp | 2 |
2 files changed, 103 insertions, 1 deletions
diff --git a/libcxxabi/src/cxa_demangle.cpp b/libcxxabi/src/cxa_demangle.cpp index 2890006552e..68e8c45aa6a 100644 --- a/libcxxabi/src/cxa_demangle.cpp +++ b/libcxxabi/src/cxa_demangle.cpp @@ -7364,6 +7364,108 @@ public: return n + sz1 + sz2; } + virtual char* get_demangled_name(char* buf) const + { + if (__size_) + { + const char* t = buf; + buf = __right_->first_demangled_name(buf); + if (buf != t && (__left_ == NULL || + !__right_->__left_->is_reference_or_pointer_to_function_or_array())) + *buf++ = ' '; + } + else + { + strncpy(buf, "auto ", 5); + buf += 5; + } + if (__left_) + buf = __left_->first_demangled_name(buf); + buf = __right_->second_demangled_name(buf); + if (!__size_) + { + *buf++ = '-'; + *buf++ = '>'; + buf = __right_->first_demangled_name(buf); + } + return buf; + } + + virtual size_t size() const + { + if (__cached_size_ == -1) + { + size_t off = 0; + if (__size_) + { + off = __right_->first_size(); + if (off > 0 && (__left_ == NULL || + !__right_->__left_->is_reference_or_pointer_to_function_or_array())) + ++off; + } + else + off = 5; + if (__left_) + off += __left_->first_size(); + off += __right_->second_size(); + if (!__size_) + { + off += 2; + off += __right_->first_size(); + } + const_cast<long&>(__cached_size_) = off; + } + return __cached_size_; + } + + virtual ptrdiff_t print(char* f, char* l) const + { + const ptrdiff_t r = l - f; + ptrdiff_t n = 0; + ptrdiff_t sz1 = 0; + ptrdiff_t sz2 = 0; + if (__size_) + { + sz1 = __right_->print_first(f, l); + if (sz1 != 0 && (__left_ == NULL || + !__right_->__left_->is_reference_or_pointer_to_function_or_array())) + { + ++n; + if (r >= sz1 + 1) + f[sz1] = ' '; + } + } + else + { + n = 5; + if (r >= 5) + { + char* t = f; + *t++ = 'a'; + *t++ = 'u'; + *t++ = 't'; + *t++ = 'o'; + *t++ = ' '; + } + } + if (__left_) + sz2 = __left_->print_first(f + std::min(n + sz1, r), l); + n += sz1 + sz2; + sz2 = 0; + sz1 = __right_->print_second(f+std::min(r, n), l); + if (!__size_) + { + if (r > n+sz1+1) + { + f[n+sz1] = '-'; + f[n+sz1+1] = '>'; + } + n += 2; + sz2 = __right_->print_first(f+std::min(r, n+sz1), l); + } + return n + sz1 + sz2; + } + virtual bool is_function() const { return true; diff --git a/libcxxabi/test/test_demangle.cpp b/libcxxabi/test/test_demangle.cpp index 48025441435..f79ffbbd34a 100644 --- a/libcxxabi/test/test_demangle.cpp +++ b/libcxxabi/test/test_demangle.cpp @@ -29552,7 +29552,7 @@ const char* cases[][2] = {"_Z2f3IJiEEvDpPKT_", "void f3<int>(int const*)"}, {"_Z2f3IJifEEvDpPKT_", "void f3<int, float>(int const*, float const*)"}, {"_Z2f4IJifdEE5tupleIJDpT_EEv", "tuple<int, float, double> f4<int, float, double>()"}, - {"_Z2f5IiJifdEE8identityIFT_DpT0_EEv", "identity<int ()(int, float, double)> f5<int, int, float, double>()"}, + {"_Z2f5IiJifdEE8identityIFT_DpT0_EEv", "identity<int (int, float, double)> f5<int, int, float, double>()"}, {"_Z2f6IJLi1ELi2ELi3EEE9int_tupleIJXspT_EEEv", "int_tuple<1, 2, 3> f6<1, 2, 3>()"}, {"_Z2f7IJ8identity13add_referenceEE14template_tupleIJDpT_EEv", "template_tuple<identity, add_reference> f7<identity, add_reference>()"}, {"_ZNK10__cxxabiv111__libcxxabi5__sub20first_demangled_nameEPc.eh", "__cxxabiv1::__libcxxabi::__sub::first_demangled_name(char*) const (.eh)"}, |