[PATCH] PR19091, libcxxabi fix of wrong demangling of "operator>(int)"

Stepan Dyatkovskiy stpworld at narod.ru
Wed May 7 06:41:18 PDT 2014

Problem is in cxa_demangle.cpp, "parse_encoding" method.

Method checks previously demangled characters to detect whether template arguments were parsed, and whether it can proceed to type parsing.
So, method misrecognises ">" as template closing tag. It wouldn't be good if we check that closing tag is not a tail of "operator>", since it won't solve whole problem. It still will conflict with constructions like "<despicable_operator>".
Current patch fixes this problem by adding extra space into demangling sequence for GT operator: "operator> ".
Though generally, it would be good if we will keep parsing stack information somewhere.



Index: src/cxa_demangle.cpp
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -2425,7 +2425,8 @@
                 first += 2;
             case 't':
-                db.names.push_back("operator>");
+                // Add extra space and avoid collisions with templates.
+                db.names.push_back("operator> ");
                 first += 2;
Index: test/test_demangle.cpp
--- test/test_demangle.cpp
+++ test/test_demangle.cpp
@@ -21,6 +21,7 @@
     {"_Z1A1B1C", "A(B, C)"},
     {"_Z4testI1A1BE1Cv", "C test<A, B>()"},
     {"_Z4testI1A1BET0_T_S3_", "B test<A, B>(A, A)"},
+    {"_ZN1SgtEi", "S::operator> (int)"},
     {"_ZN13dyldbootstrap5startEPK12macho_headeriPPKcl", "dyldbootstrap::start(macho_header const*, int, char const**, long)"},
     {"_ZN4dyld17getExecutablePathEv", "dyld::getExecutablePath()"},
     {"_ZN4dyld22mainExecutablePreboundEv", "dyld::mainExecutablePrebound()"},
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3646.9163.patch
Type: text/x-patch
Size: 1103 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140507/229e0041/attachment.bin>

More information about the llvm-commits mailing list