1 //===-- Demangle.cpp - Common demangling functions ------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 /// \file This file contains definitions of common demangling functions.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/Demangle/Demangle.h"
16 static bool isItaniumEncoding(const std::string
&MangledName
) {
17 size_t Pos
= MangledName
.find_first_not_of('_');
18 // A valid Itanium encoding requires 1-4 leading underscores, followed by 'Z'.
19 return Pos
> 0 && Pos
<= 4 && MangledName
[Pos
] == 'Z';
22 std::string
llvm::demangle(const std::string
&MangledName
) {
24 if (isItaniumEncoding(MangledName
))
25 Demangled
= itaniumDemangle(MangledName
.c_str(), nullptr, nullptr, nullptr);
28 microsoftDemangle(MangledName
.c_str(), nullptr, nullptr, nullptr);
33 std::string Ret
= Demangled
;