[PATCH] D68014: [LLD] Convert demangleItanium to use the higher level llvm::demangle function. NFC.

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 27 05:24:37 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL373076: [LLD] Convert demangleItanium to use the higher level llvm::demangle function. (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D68014?vs=221708&id=222143#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68014/new/

https://reviews.llvm.org/D68014

Files:
  lld/trunk/Common/Strings.cpp
  lld/trunk/test/ELF/undef.s


Index: lld/trunk/Common/Strings.cpp
===================================================================
--- lld/trunk/Common/Strings.cpp
+++ lld/trunk/Common/Strings.cpp
@@ -22,18 +22,16 @@
 Optional<std::string> lld::demangleItanium(StringRef name) {
   // itaniumDemangle can be used to demangle strings other than symbol
   // names which do not necessarily start with "_Z". Name can be
-  // either a C or C++ symbol. Don't call itaniumDemangle if the name
+  // either a C or C++ symbol. Don't call demangle if the name
   // does not look like a C++ symbol name to avoid getting unexpected
   // result for a C symbol that happens to match a mangled type name.
   if (!name.startswith("_Z"))
     return None;
 
-  char *buf = itaniumDemangle(name.str().c_str(), nullptr, nullptr, nullptr);
-  if (!buf)
+  std::string demangled = demangle(name);
+  if (demangled == name)
     return None;
-  std::string s(buf);
-  free(buf);
-  return s;
+  return demangled;
 }
 
 StringMatcher::StringMatcher(ArrayRef<StringRef> pat) {
Index: lld/trunk/test/ELF/undef.s
===================================================================
--- lld/trunk/test/ELF/undef.s
+++ lld/trunk/test/ELF/undef.s
@@ -23,6 +23,10 @@
 # CHECK: error: undefined symbol: vtable for Foo
 # CHECK: the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)
 
+# CHECK: error: undefined symbol: __Z3fooi
+# CHECK: >>> referenced by undef.s
+# CHECK: >>>               {{.*}}:(.text+0x1A)
+
 # CHECK: error: undefined symbol: zed2
 # CHECK: >>> referenced by {{.*}}.o:(.text+0x0) in archive {{.*}}2.a
 
@@ -64,3 +68,4 @@
   call zed1
   call _Z3fooi
   call _ZTV3Foo
+  call __Z3fooi


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68014.222143.patch
Type: text/x-patch
Size: 1725 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190927/afc944dc/attachment.bin>


More information about the llvm-commits mailing list