summaryrefslogtreecommitdiffstats
path: root/lld/Common/Strings.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2018-09-15 18:27:09 +0000
committerNico Weber <nicolasweber@gmx.de>2018-09-15 18:27:09 +0000
commitda15acbd68cb9c60aef5a4e51a5383641c65147d (patch)
tree1b11539cb85b25f4bef0396faa8715f420892f05 /lld/Common/Strings.cpp
parentda01b342b255e6e99580313d7b74753ccb4f6716 (diff)
downloadbcm5719-llvm-da15acbd68cb9c60aef5a4e51a5383641c65147d.tar.gz
bcm5719-llvm-da15acbd68cb9c60aef5a4e51a5383641c65147d.zip
lld-link: print demangled symbol names for "undefined symbol" diagnostics
For this, add a few toString() calls when printing the "undefined symbol" diagnostics; toString() already does demangling on Windows hosts. Also make lld::demangleMSVC() (called by toString(Symbol*)) call LLVM's microsoftDemangle() instead of UnDecorateSymbolName() so that it works on non-Windows hosts – this makes both updating tests easier and provides a better user experience for people doing cross-links. This doesn't yet do the right thing for symbols starting with __imp_, but that can be improved in a follow-up. Differential Revision: https://reviews.llvm.org/D52104 llvm-svn: 342332
Diffstat (limited to 'lld/Common/Strings.cpp')
-rw-r--r--lld/Common/Strings.cpp29
1 files changed, 9 insertions, 20 deletions
diff --git a/lld/Common/Strings.cpp b/lld/Common/Strings.cpp
index 36f4f77d847..581a0795482 100644
--- a/lld/Common/Strings.cpp
+++ b/lld/Common/Strings.cpp
@@ -16,14 +16,6 @@
#include <mutex>
#include <vector>
-#if defined(_MSC_VER)
-#include <Windows.h>
-
-// DbgHelp.h must be included after Windows.h.
-#include <DbgHelp.h>
-#pragma comment(lib, "dbghelp.lib")
-#endif
-
using namespace llvm;
using namespace lld;
@@ -45,18 +37,15 @@ Optional<std::string> lld::demangleItanium(StringRef Name) {
return S;
}
-Optional<std::string> lld::demangleMSVC(StringRef S) {
-#if defined(_MSC_VER)
- // UnDecorateSymbolName is not thread-safe, so we need a mutex.
- static std::mutex Mu;
- std::lock_guard<std::mutex> Lock(Mu);
-
- char Buf[4096];
- if (S.startswith("?"))
- if (size_t Len = UnDecorateSymbolName(S.str().c_str(), Buf, sizeof(Buf), 0))
- return std::string(Buf, Len);
-#endif
- return None;
+Optional<std::string> lld::demangleMSVC(StringRef Name) {
+ if (!Name.startswith("?"))
+ return None;
+ char *Buf = microsoftDemangle(Name.str().c_str(), nullptr, nullptr, nullptr);
+ if (!Buf)
+ return None;
+ std::string S(Buf);
+ free(Buf);
+ return S;
}
StringMatcher::StringMatcher(ArrayRef<StringRef> Pat) {
OpenPOWER on IntegriCloud