[PATCH] D22939: Only use __cxa_demangle on C++ mangled names

Dimitry Andric via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 28 14:51:43 PDT 2016


dim updated this revision to Diff 66024.
dim added a comment.

Scratch that initial version, if the name to be demangled does not start
with "_Z", we should not return nullptr, but the unmodified name
instead.


https://reviews.llvm.org/D22939

Files:
  lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc

Index: lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
+++ lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
@@ -50,6 +50,10 @@
 
 // Attempts to demangle the name via __cxa_demangle from __cxxabiv1.
 const char *DemangleCXXABI(const char *name) {
+  // Check if we are dealing with a C++ mangled name first.
+  if (name[0] != '_' || name[1] != 'Z')
+    return name;
+
   // FIXME: __cxa_demangle aggressively insists on allocating memory.
   // There's not much we can do about that, short of providing our
   // own demangler (libc++abi's implementation could be adapted so that


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22939.66024.patch
Type: text/x-patch
Size: 733 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160728/2660fc20/attachment.bin>


More information about the llvm-commits mailing list