aboutsummaryrefslogtreecommitdiff
path: root/COFF/Strings.cpp
blob: d0558413f673304cd8adaa82807fab9ef478287d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//===- Strings.cpp -------------------------------------------------------===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "Strings.h"

#if defined(_MSC_VER)
#include <Windows.h>
#include <DbgHelp.h>
#pragma comment(lib, "dbghelp.lib")
#endif

using namespace lld;
using namespace lld::coff;
using namespace llvm;

Optional<std::string> coff::demangle(StringRef S) {
#if defined(_MSC_VER)
  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;
}