1 //===-- Demangle.cpp - Common demangling functions ------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file This file contains definitions of common demangling functions.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/Demangle/Demangle.h"
15 
16 std::string llvm::demangle(const std::string &MangledName) {
17   char *Demangled;
18   if (MangledName.compare(0, 2, "_Z") == 0)
19     Demangled = itaniumDemangle(MangledName.c_str(), nullptr, nullptr, nullptr);
20   else
21     Demangled =
22         microsoftDemangle(MangledName.c_str(), nullptr, nullptr, nullptr);
23 
24   if (!Demangled)
25     return MangledName;
26 
27   std::string Ret = Demangled;
28   free(Demangled);
29   return Ret;
30 }
31