diff options
| author | Howard Hinnant <hhinnant@apple.com> | 2012-05-02 15:38:11 +0000 |
|---|---|---|
| committer | Howard Hinnant <hhinnant@apple.com> | 2012-05-02 15:38:11 +0000 |
| commit | ba2e8aeda5e1789abb5d4aabcfe61bdf380aa638 (patch) | |
| tree | 0c47506096d5ae60d2629588644be35654eb2583 | |
| parent | b170ed0bbe253088ff83dcb274e60d9205c5c8d9 (diff) | |
| download | bcm5719-llvm-ba2e8aeda5e1789abb5d4aabcfe61bdf380aa638.tar.gz bcm5719-llvm-ba2e8aeda5e1789abb5d4aabcfe61bdf380aa638.zip | |
Fix bug in cxa_demangle involving template substitution.
llvm-svn: 155994
| -rw-r--r-- | libcxxabi/src/cxa_demangle.cpp | 15 | ||||
| -rw-r--r-- | libcxxabi/test/test_demangle.cpp | 1 |
2 files changed, 10 insertions, 6 deletions
diff --git a/libcxxabi/src/cxa_demangle.cpp b/libcxxabi/src/cxa_demangle.cpp index 86c190f3561..6a8029f4f31 100644 --- a/libcxxabi/src/cxa_demangle.cpp +++ b/libcxxabi/src/cxa_demangle.cpp @@ -134,9 +134,10 @@ void display(__node* x, int indent = 0) { for (int i = 0; i < 2*indent; ++i) printf(" "); - std::string buf(x->size(), '\0'); - x->get_demangled_name(&buf.front()); - printf("%s %s, %p\n", typeid(*x).name(), buf.c_str(), x); + char* buf = (char*)malloc(x->size()); + x->get_demangled_name(buf); + printf("%s %s, %p\n", typeid(*x).name(), buf, x); + free(buf); display(x->__left_, indent+1); display(x->__right_, indent+1); } @@ -6524,6 +6525,7 @@ __demangle_tree::__parse_bare_function_type(const char* first, const char* last) { if (first != last) { + bool prev_tag_templates = __tag_templates_; __tag_templates_ = false; const char* t = __parse_type(first, last); if (t != first && __make<__list>(__root_)) @@ -6554,7 +6556,7 @@ __demangle_tree::__parse_bare_function_type(const char* first, const char* last) } } } - __tag_templates_ = true; + __tag_templates_ = prev_tag_templates; } return first; } @@ -10696,6 +10698,7 @@ __demangle_tree::__parse_encoding(const char* first, const char* last) !name->is_ctor_dtor_conv(); __node* ret = NULL; const char* t2; + bool prev_tag_templates = __tag_templates_; __tag_templates_ = false; if (has_return) { @@ -10728,7 +10731,7 @@ __demangle_tree::__parse_encoding(const char* first, const char* last) } } } - __tag_templates_ = true; + __tag_templates_ = prev_tag_templates; } else first = t; @@ -10864,7 +10867,7 @@ __cxa_demangle(const char* mangled_name, char* buf, size_t* n, int* status) *status = __libcxxabi::invalid_args; return NULL; } - const size_t bs = 64 * 1024; + const size_t bs = 4 * 1024; __attribute((aligned(16))) char static_buf[bs]; buf = __libcxxabi::__demangle(__libcxxabi::__demangle(mangled_name, diff --git a/libcxxabi/test/test_demangle.cpp b/libcxxabi/test/test_demangle.cpp index 44d3f6ba4ac..c53ba5838e4 100644 --- a/libcxxabi/test/test_demangle.cpp +++ b/libcxxabi/test/test_demangle.cpp @@ -29564,6 +29564,7 @@ const char* cases[][2] = {"_ZN3WTF15deleteAllValuesIPN7WebCore5XPath4Step8NodeTestEKNS_9HashTableIS5_S5_NS_17IdentityExtractorENS_7PtrHashIS5_EENS_10HashTraitsIS5_EESB_EEEEvRT0_", "void WTF::deleteAllValues<WebCore::XPath::Step::NodeTest*, WTF::HashTable<WebCore::XPath::Step::NodeTest*, WebCore::XPath::Step::NodeTest*, WTF::IdentityExtractor, WTF::PtrHash<WebCore::XPath::Step::NodeTest*>, WTF::HashTraits<WebCore::XPath::Step::NodeTest*>, WTF::HashTraits<WebCore::XPath::Step::NodeTest*> > const>(WTF::HashTable<WebCore::XPath::Step::NodeTest*, WebCore::XPath::Step::NodeTest*, WTF::IdentityExtractor, WTF::PtrHash<WebCore::XPath::Step::NodeTest*>, WTF::HashTraits<WebCore::XPath::Step::NodeTest*>, WTF::HashTraits<WebCore::XPath::Step::NodeTest*> > const&)"}, {"_Z13JVTLib_103270ILi1EEvPsDv2_xS1_", "void JVTLib_103270<1>(short*, long long vector[2], long long vector[2])"}, {"_ZN8platform20split_string_convertIcPFiRKSsEiSaIiESt6vectorEEjPKT_S9_S7_T0_RT3_IT1_T2_E", "unsigned int platform::split_string_convert<char, int (*)(std::string const&), int, std::allocator<int>, std::vector>(char const*, char const*, char, int (*)(std::string const&), std::vector<int, std::allocator<int> >&)"}, + {"_ZN2MF12_GLOBAL__N_114WeakCallHelperINS0_15DecodeQueueImplEEEvRKN5boost8functionIFvvEEERKNS3_8weak_ptrIT_EE", "void MF::(anonymous namespace)::WeakCallHelper<MF::(anonymous namespace)::DecodeQueueImpl>(boost::function<void ()> const&, boost::weak_ptr<MF::(anonymous namespace)::DecodeQueueImpl> const&)"}, }; const unsigned N = sizeof(cases) / sizeof(cases[0]); |

