Coverage Report

Created: 2018-01-17 17:22

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/Common/Strings.cpp
Line
Count
Source (jump to first uncovered line)
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 "lld/Common/Strings.h"
11
#include "llvm/Demangle/Demangle.h"
12
13
using namespace llvm;
14
using namespace lld;
15
16
// Returns the demangled C++ symbol name for Name.
17
224
Optional<std::string> lld::demangleItanium(StringRef Name) {
18
224
  // itaniumDemangle can be used to demangle strings other than symbol
19
224
  // names which do not necessarily start with "_Z". Name can be
20
224
  // either a C or C++ symbol. Don't call itaniumDemangle if the name
21
224
  // does not look like a C++ symbol name to avoid getting unexpected
22
224
  // result for a C symbol that happens to match a mangled type name.
23
224
  if (!Name.startswith("_Z"))
24
173
    return None;
25
51
26
51
  char *Buf = itaniumDemangle(Name.str().c_str(), nullptr, nullptr, nullptr);
27
51
  if (!Buf)
28
0
    return None;
29
51
  std::string S(Buf);
30
51
  free(Buf);
31
51
  return S;
32
51
}