[lld] r280733 - Use the demangler in llvm.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 6 12:17:14 PDT 2016
Author: rafael
Date: Tue Sep 6 14:17:14 2016
New Revision: 280733
URL: http://llvm.org/viewvc/llvm-project?rev=280733&view=rev
Log:
Use the demangler in llvm.
Modified:
lld/trunk/ELF/Strings.cpp
lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
Modified: lld/trunk/ELF/Strings.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Strings.cpp?rev=280733&r1=280732&r2=280733&view=diff
==============================================================================
--- lld/trunk/ELF/Strings.cpp (original)
+++ lld/trunk/ELF/Strings.cpp Tue Sep 6 14:17:14 2016
@@ -13,12 +13,9 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/config.h"
+#include "llvm/Demangle/Demangle.h"
#include <algorithm>
-#ifdef HAVE_CXXABI_H
-#include <cxxabi.h>
-#endif
-
using namespace llvm;
using namespace lld;
using namespace lld::elf;
@@ -86,9 +83,6 @@ bool elf::isValidCIdentifier(StringRef S
// Returns the demangled C++ symbol name for Name.
std::string elf::demangle(StringRef Name) {
-#if !defined(HAVE_CXXABI_H)
- return Name;
-#else
// __cxa_demangle 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 __cxa_demangle if the name
@@ -97,12 +91,10 @@ std::string elf::demangle(StringRef Name
if (!Name.startswith("_Z"))
return Name;
- char *Buf =
- abi::__cxa_demangle(Name.str().c_str(), nullptr, nullptr, nullptr);
+ char *Buf = itaniumDemangle(Name.str().c_str(), nullptr, nullptr, nullptr);
if (!Buf)
return Name;
std::string S(Buf);
free(Buf);
return S;
-#endif
}
Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=280733&r1=280732&r2=280733&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Tue Sep 6 14:17:14 2016
@@ -23,6 +23,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Config/config.h"
+#include "llvm/Demangle/Demangle.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Host.h"
@@ -30,10 +31,6 @@
#include "llvm/Support/Path.h"
#include <algorithm>
-#if defined(HAVE_CXXABI_H)
-#include <cxxabi.h>
-#endif
-
using lld::mach_o::ArchHandler;
using lld::mach_o::MachOFile;
using lld::mach_o::MachODylibFile;
@@ -876,20 +873,18 @@ std::string MachOLinkingContext::demangl
if (!symbolName.startswith("__Z"))
return symbolName;
-#if defined(HAVE_CXXABI_H)
SmallString<256> symBuff;
StringRef nullTermSym = Twine(symbolName).toNullTerminatedStringRef(symBuff);
// Mach-O has extra leading underscore that needs to be removed.
const char *cstr = nullTermSym.data() + 1;
int status;
- char *demangled = abi::__cxa_demangle(cstr, nullptr, nullptr, &status);
+ char *demangled = llvm::itaniumDemangle(cstr, nullptr, nullptr, &status);
if (demangled) {
std::string result(demangled);
// __cxa_demangle() always uses a malloc'ed buffer to return the result.
free(demangled);
return result;
}
-#endif
return symbolName;
}
More information about the llvm-commits
mailing list