]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/COFF/Strings.cpp
Merge ^/head r312624 through r312719.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / COFF / Strings.cpp
1 //===- Strings.cpp -------------------------------------------------------===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "Strings.h"
11
12 #if defined(_MSC_VER)
13 #include <Windows.h>
14 #include <DbgHelp.h>
15 #pragma comment(lib, "dbghelp.lib")
16 #endif
17
18 using namespace lld;
19 using namespace lld::coff;
20 using namespace llvm;
21
22 Optional<std::string> coff::demangle(StringRef S) {
23 #if defined(_MSC_VER)
24   char Buf[4096];
25   if (S.startswith("?"))
26     if (size_t Len = UnDecorateSymbolName(S.str().c_str(), Buf, sizeof(Buf), 0))
27       return std::string(Buf, Len);
28 #endif
29   return None;
30 }