mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2026-01-31 01:35:20 +01:00
This is a follow-up to r351448. It adds support for other _*Z extensions of the Itanium demanling, to the newly available demangle function heuristic. Reviewed by: erik.pilkington, rupprecht, grimar Differential Revision: https://reviews.llvm.org/D56855 llvm-svn: 351551
37 lines
1.2 KiB
C++
37 lines
1.2 KiB
C++
//===-- Demangle.cpp - Common demangling functions ------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// \file This file contains definitions of common demangling functions.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Demangle/Demangle.h"
|
|
|
|
static bool isItaniumEncoding(const std::string &MangledName) {
|
|
size_t Pos = MangledName.find_first_not_of('_');
|
|
// A valid Itanium encoding requires 1-4 leading underscores, followed by 'Z'.
|
|
return Pos > 0 && Pos <= 4 && MangledName[Pos] == 'Z';
|
|
}
|
|
|
|
std::string llvm::demangle(const std::string &MangledName) {
|
|
char *Demangled;
|
|
if (isItaniumEncoding(MangledName))
|
|
Demangled = itaniumDemangle(MangledName.c_str(), nullptr, nullptr, nullptr);
|
|
else
|
|
Demangled =
|
|
microsoftDemangle(MangledName.c_str(), nullptr, nullptr, nullptr);
|
|
|
|
if (!Demangled)
|
|
return MangledName;
|
|
|
|
std::string Ret = Demangled;
|
|
free(Demangled);
|
|
return Ret;
|
|
}
|