[libcxxabi] r292524 - Merging r292418:

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 19 13:57:57 PST 2017


Author: hans
Date: Thu Jan 19 15:57:56 2017
New Revision: 292524

URL: http://llvm.org/viewvc/llvm-project?rev=292524&view=rev
Log:
Merging r292418:
------------------------------------------------------------------------
r292418 | jroelofs | 2017-01-18 10:12:39 -0800 (Wed, 18 Jan 2017) | 15 lines

Revert r286788

The Itanium ABI [1] specifies that __cxa_demangle accept either:

   1) symbol names, which start with "_Z"
   2) type manglings, which do not start with "_Z"

r286788 erroneously assumes that it should only handle symbols, so this patch
reverts it and adds a counterexample to the testcase.

1: https://mentorembedded.github.io/cxx-abi/abi.html#demangler


Reviewers: zygoloid, EricWF

------------------------------------------------------------------------

Modified:
    libcxxabi/branches/release_40/   (props changed)
    libcxxabi/branches/release_40/src/cxa_demangle.cpp
    libcxxabi/branches/release_40/test/test_demangle.pass.cpp

Propchange: libcxxabi/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jan 19 15:57:56 2017
@@ -1 +1 @@
-/libcxxabi/trunk:292135
+/libcxxabi/trunk:292135,292418

Modified: libcxxabi/branches/release_40/src/cxa_demangle.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/branches/release_40/src/cxa_demangle.cpp?rev=292524&r1=292523&r2=292524&view=diff
==============================================================================
--- libcxxabi/branches/release_40/src/cxa_demangle.cpp (original)
+++ libcxxabi/branches/release_40/src/cxa_demangle.cpp Thu Jan 19 15:57:56 2017
@@ -4979,22 +4979,12 @@ __cxa_demangle(const char *mangled_name,
         return nullptr;
     }
 
-    size_t len = std::strlen(mangled_name);
-    if (len < 2 || strncmp(mangled_name, "_Z", 2))
-    {
-        if (len < 4 || strncmp(mangled_name, "___Z", 4))
-        {
-            if (status)
-                *status = invalid_mangled_name;
-            return nullptr;
-        }
-    }
-
     size_t internal_size = buf != nullptr ? *n : 0;
     arena<bs> a;
     Db db(a);
     db.template_param.emplace_back(a);
     int internal_status = success;
+    size_t len = std::strlen(mangled_name);
     demangle(mangled_name, mangled_name + len, db,
              internal_status);
     if (internal_status == success && db.fix_forward_references &&

Modified: libcxxabi/branches/release_40/test/test_demangle.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/branches/release_40/test/test_demangle.pass.cpp?rev=292524&r1=292523&r2=292524&view=diff
==============================================================================
--- libcxxabi/branches/release_40/test/test_demangle.pass.cpp (original)
+++ libcxxabi/branches/release_40/test/test_demangle.pass.cpp Thu Jan 19 15:57:56 2017
@@ -29594,6 +29594,9 @@ const char* cases[][2] =
     // NOTE: disable this test since it is a negative test case, you cannot demangle a non-mangled symbol
     // {"\x6D", nullptr}, 	// This use to crash with ASAN
     {"_ZTIU4_farrVKPi", "typeinfo for int* const volatile restrict _far"},
+
+    // mangled names can include type manglings too, which don't start with _Z:
+    {"i", "int"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);




More information about the cfe-commits mailing list