LLVM  8.0.0svn
Classes | Enumerations | Functions | Variables
MicrosoftDemangle.cpp File Reference
#include "llvm/Demangle/Demangle.h"
#include "llvm/Demangle/Compiler.h"
#include "llvm/Demangle/StringView.h"
#include "llvm/Demangle/Utility.h"
#include <array>
#include <cctype>
#include <cstdio>
#include <tuple>
Include dependency graph for MicrosoftDemangle.cpp:

Go to the source code of this file.

Classes

struct  OperatorMapEntry
 

Enumerations

enum  Qualifiers : uint8_t {
  Q_None = 0, Q_Const = 1 << 0, Q_Volatile = 1 << 1, Q_Far = 1 << 2,
  Q_Huge = 1 << 3, Q_Unaligned = 1 << 4, Q_Restrict = 1 << 5, Q_Pointer64 = 1 << 6
}
 
enum  StorageClass : uint8_t {
  None, StorageClass::PrivateStatic, StorageClass::ProtectedStatic, StorageClass::PublicStatic,
  Global, StorageClass::FunctionLocalStatic
}
 
enum  QualifierMangleMode { QualifierMangleMode::Drop, QualifierMangleMode::Mangle, QualifierMangleMode::Result }
 
enum  PointerAffinity { PointerAffinity::Pointer, PointerAffinity::Reference, PointerAffinity::RValueReference }
 
enum  CallingConv : uint8_t {
  None, CallingConv::Cdecl, CallingConv::Pascal, CallingConv::Thiscall,
  CallingConv::Stdcall, CallingConv::Fastcall, CallingConv::Clrcall, CallingConv::Eabi,
  CallingConv::Vectorcall, CallingConv::Regcall
}
 
enum  ReferenceKind : uint8_t { None, ReferenceKind::LValueRef, ReferenceKind::RValueRef }
 
enum  PrimTy : uint8_t {
  PrimTy::Unknown, None, PrimTy::Function, PrimTy::Ptr,
  PrimTy::MemberPtr, PrimTy::Array, PrimTy::Struct, PrimTy::Union,
  PrimTy::Class, PrimTy::Enum, PrimTy::Void, PrimTy::Bool,
  PrimTy::Char, PrimTy::Schar, PrimTy::Uchar, PrimTy::Char16,
  PrimTy::Char32, PrimTy::Short, PrimTy::Ushort, PrimTy::Int,
  PrimTy::Uint, PrimTy::Long, PrimTy::Ulong, PrimTy::Int64,
  PrimTy::Uint64, PrimTy::Wchar, PrimTy::Float, PrimTy::Double,
  PrimTy::Ldouble, PrimTy::Nullptr, PrimTy::Vftable, PrimTy::Vbtable,
  PrimTy::LocalStaticGuard
}
 
enum  OperatorTy : uint8_t {
  OperatorTy::Ctor, OperatorTy::Dtor, OperatorTy::New, OperatorTy::Delete,
  OperatorTy::Assign, OperatorTy::RightShift, OperatorTy::LeftShift, OperatorTy::LogicalNot,
  OperatorTy::Equals, OperatorTy::NotEquals, OperatorTy::ArraySubscript, OperatorTy::Conversion,
  OperatorTy::Pointer, OperatorTy::Dereference, OperatorTy::Increment, OperatorTy::Decrement,
  OperatorTy::Minus, OperatorTy::Plus, OperatorTy::BitwiseAnd, OperatorTy::MemberPointer,
  OperatorTy::Divide, OperatorTy::Modulus, OperatorTy::LessThan, OperatorTy::LessThanEqual,
  OperatorTy::GreaterThan, OperatorTy::GreaterThanEqual, OperatorTy::Comma, OperatorTy::Parens,
  OperatorTy::BitwiseNot, OperatorTy::BitwiseXor, OperatorTy::BitwiseOr, OperatorTy::LogicalAnd,
  OperatorTy::LogicalOr, OperatorTy::TimesEqual, OperatorTy::PlusEqual, OperatorTy::MinusEqual,
  OperatorTy::DivEqual, OperatorTy::ModEqual, OperatorTy::RshEqual, OperatorTy::LshEqual,
  OperatorTy::BitwiseAndEqual, OperatorTy::BitwiseOrEqual, OperatorTy::BitwiseXorEqual, OperatorTy::Vftable,
  OperatorTy::Vbtable, OperatorTy::Vcall, OperatorTy::Typeof, OperatorTy::LocalStaticGuard,
  OperatorTy::StringLiteral, OperatorTy::VbaseDtor, OperatorTy::VecDelDtor, OperatorTy::DefaultCtorClosure,
  OperatorTy::ScalarDelDtor, OperatorTy::VecCtorIter, OperatorTy::VecDtorIter, OperatorTy::VecVbaseCtorIter,
  OperatorTy::VdispMap, OperatorTy::EHVecCtorIter, OperatorTy::EHVecDtorIter, OperatorTy::EHVecVbaseCtorIter,
  OperatorTy::CopyCtorClosure, OperatorTy::UdtReturning, OperatorTy::Unknown, OperatorTy::RttiTypeDescriptor,
  OperatorTy::RttiBaseClassDescriptor, OperatorTy::RttiBaseClassArray, OperatorTy::RttiClassHierarchyDescriptor, OperatorTy::RttiCompleteObjLocator,
  OperatorTy::LocalVftable, OperatorTy::LocalVftableCtorClosure, OperatorTy::ArrayNew, OperatorTy::ArrayDelete,
  OperatorTy::DynamicInitializer, OperatorTy::DynamicAtexitDestructor, OperatorTy::LiteralOperator, OperatorTy::CoAwait,
  OperatorTy::Spaceship
}
 
enum  FuncClass : uint16_t {
  None = 0, None, None, None,
  None, Public = 1 << 0, Protected = 1 << 1, Private = 1 << 2,
  Global = 1 << 3, Global, Static = 1 << 4, Virtual = 1 << 5,
  Far = 1 << 6, ExternC = 1 << 7, NoPrototype = 1 << 8, VirtualThisAdjust = 1 << 9,
  VirtualThisAdjustEx = 1 << 10, StaticThisAdjust = 1 << 11
}
 
enum  NameBackrefBehavior : uint8_t { NBB_None = 0, NBB_Template = 1 << 0, NBB_Simple = 1 << 1 }
 
enum  SymbolCategory {
  SymbolCategory::Unknown, SymbolCategory::NamedFunction, SymbolCategory::NamedVariable, SymbolCategory::UnnamedFunction,
  SymbolCategory::UnnamedVariable, SymbolCategory::SpecialOperator
}
 

Functions

static bool startsWithDigit (StringView S)
 
static void outputSpaceIfNecessary (OutputStream &OS)
 
static bool isMemberPointer (StringView MangledName)
 
static void outputCallingConvention (OutputStream &OS, CallingConv CC)
 
static bool startsWithLocalScopePattern (StringView S)
 
static void outputParameterList (OutputStream &OS, const FunctionParams &Params)
 
static void outputStringLiteral (OutputStream &OS, const StringLiteral &Str)
 
static void outputName (OutputStream &OS, const Name *TheName, const Type *Ty)
 
static void outputParameterList (OutputStream &OS, const TemplateParams &Params)
 
static void outputQualifiers (OutputStream &OS, Qualifiers Q)
 
static void outputNameComponent (OutputStream &OS, const Name &N)
 
static const OperatorInfo * lastComponentAsOperator (const Name *TheName)
 
static void outputSpecialOperator (OutputStream &OS, const Name *OuterName)
 
static bool isRebasedHexDigit (char C)
 
static uint8_t rebasedHexDigitToNumber (char C)
 
static void writeHexDigit (char *Buffer, uint8_t Digit)
 
static void outputHex (OutputStream &OS, unsigned C)
 
static void outputEscapedChar (OutputStream &OS, unsigned C)
 
unsigned countTrailingNullBytes (const uint8_t *StringBytes, int Length)
 
unsigned countEmbeddedNulls (const uint8_t *StringBytes, unsigned Length)
 
unsigned guessCharByteSize (const uint8_t *StringBytes, unsigned NumChars, unsigned NumBytes)
 
static unsigned decodeMultiByteChar (const uint8_t *StringBytes, unsigned CharIndex, unsigned CharBytes)
 
static bool isTagType (StringView S)
 
static bool isPointerType (StringView S)
 
static bool isArrayType (StringView S)
 
static bool isFunctionType (StringView S)
 
static std::pair< Qualifiers, PointerAffinitydemanglePointerCVQualifiers (StringView &MangledName)
 

Variables

OperatorMapEntry OperatorMap []
 

Enumeration Type Documentation

◆ CallingConv

enum CallingConv : uint8_t
strong
Enumerator
None 
Cdecl 
Pascal 
Thiscall 
Stdcall 
Fastcall 
Clrcall 
Eabi 
Vectorcall 
Regcall 

Definition at line 147 of file MicrosoftDemangle.cpp.

◆ FuncClass

enum FuncClass : uint16_t
Enumerator
None 
None 
None 
None 
None 
Public 
Protected 
Private 
Global 
Global 
Static 
Virtual 
Far 
ExternC 
NoPrototype 
VirtualThisAdjust 
VirtualThisAdjustEx 
StaticThisAdjust 

Definition at line 372 of file MicrosoftDemangle.cpp.

◆ NameBackrefBehavior

enum NameBackrefBehavior : uint8_t
Enumerator
NBB_None 
NBB_Template 
NBB_Simple 

Definition at line 388 of file MicrosoftDemangle.cpp.

◆ OperatorTy

enum OperatorTy : uint8_t
strong
Enumerator
Ctor 
Dtor 
New 
Delete 
Assign 
RightShift 
LeftShift 
LogicalNot 
Equals 
NotEquals 
ArraySubscript 
Conversion 
Pointer 
Dereference 
Increment 
Decrement 
Minus 
Plus 
BitwiseAnd 
MemberPointer 
Divide 
Modulus 
LessThan 
LessThanEqual 
GreaterThan 
GreaterThanEqual 
Comma 
Parens 
BitwiseNot 
BitwiseXor 
BitwiseOr 
LogicalAnd 
LogicalOr 
TimesEqual 
PlusEqual 
MinusEqual 
DivEqual 
ModEqual 
RshEqual 
LshEqual 
BitwiseAndEqual 
BitwiseOrEqual 
BitwiseXorEqual 
Vftable 
Vbtable 
Vcall 
Typeof 
LocalStaticGuard 
StringLiteral 
VbaseDtor 
VecDelDtor 
DefaultCtorClosure 
ScalarDelDtor 
VecCtorIter 
VecDtorIter 
VecVbaseCtorIter 
VdispMap 
EHVecCtorIter 
EHVecDtorIter 
EHVecVbaseCtorIter 
CopyCtorClosure 
UdtReturning 
Unknown 
RttiTypeDescriptor 
RttiBaseClassDescriptor 
RttiBaseClassArray 
RttiClassHierarchyDescriptor 
RttiCompleteObjLocator 
LocalVftable 
LocalVftableCtorClosure 
ArrayNew 
ArrayDelete 
DynamicInitializer 
DynamicAtexitDestructor 
LiteralOperator 
CoAwait 
Spaceship 

Definition at line 201 of file MicrosoftDemangle.cpp.

◆ PointerAffinity

enum PointerAffinity
strong
Enumerator
Pointer 
Reference 
RValueReference 

Definition at line 144 of file MicrosoftDemangle.cpp.

◆ PrimTy

enum PrimTy : uint8_t
strong
Enumerator
Unknown 
None 
Function 
Ptr 
MemberPtr 
Array 
Struct 
Union 
Class 
Enum 
Void 
Bool 
Char 
Schar 
Uchar 
Char16 
Char32 
Short 
Ushort 
Int 
Uint 
Long 
Ulong 
Int64 
Uint64 
Wchar 
Float 
Double 
Ldouble 
Nullptr 
Vftable 
Vbtable 
LocalStaticGuard 

Definition at line 163 of file MicrosoftDemangle.cpp.

◆ QualifierMangleMode

enum QualifierMangleMode
strong
Enumerator
Drop 
Mangle 
Result 

Definition at line 142 of file MicrosoftDemangle.cpp.

◆ Qualifiers

enum Qualifiers : uint8_t
Enumerator
Q_None 
Q_Const 
Q_Volatile 
Q_Far 
Q_Huge 
Q_Unaligned 
Q_Restrict 
Q_Pointer64 

Definition at line 122 of file MicrosoftDemangle.cpp.

◆ ReferenceKind

enum ReferenceKind : uint8_t
strong
Enumerator
None 
LValueRef 
RValueRef 

Definition at line 160 of file MicrosoftDemangle.cpp.

◆ StorageClass

enum StorageClass : uint8_t
strong
Enumerator
None 
PrivateStatic 
ProtectedStatic 
PublicStatic 
Global 
FunctionLocalStatic 

Definition at line 133 of file MicrosoftDemangle.cpp.

◆ SymbolCategory

enum SymbolCategory
strong
Enumerator
Unknown 
NamedFunction 
NamedVariable 
UnnamedFunction 
UnnamedVariable 
SpecialOperator 

Definition at line 394 of file MicrosoftDemangle.cpp.

Function Documentation

◆ countEmbeddedNulls()

unsigned countEmbeddedNulls ( const uint8_t *  StringBytes,
unsigned  Length 
)

Definition at line 1998 of file MicrosoftDemangle.cpp.

References I, and Result.

Referenced by guessCharByteSize().

◆ countTrailingNullBytes()

unsigned countTrailingNullBytes ( const uint8_t *  StringBytes,
int  Length 
)

Definition at line 1987 of file MicrosoftDemangle.cpp.

Referenced by guessCharByteSize().

◆ decodeMultiByteChar()

static unsigned decodeMultiByteChar ( const uint8_t *  StringBytes,
unsigned  CharIndex,
unsigned  CharBytes 
)
static

◆ demanglePointerCVQualifiers()

static std::pair<Qualifiers, PointerAffinity> demanglePointerCVQualifiers ( StringView MangledName)
static

◆ guessCharByteSize()

unsigned guessCharByteSize ( const uint8_t *  StringBytes,
unsigned  NumChars,
unsigned  NumBytes 
)

Definition at line 2007 of file MicrosoftDemangle.cpp.

References assert(), countEmbeddedNulls(), and countTrailingNullBytes().

Referenced by decodeMultiByteChar().

◆ isArrayType()

static bool isArrayType ( StringView  S)
static

Definition at line 2506 of file MicrosoftDemangle.cpp.

Referenced by isFunctionType().

◆ isFunctionType()

static bool isFunctionType ( StringView  S)
static

◆ isMemberPointer()

static bool isMemberPointer ( StringView  MangledName)
static

◆ isPointerType()

static bool isPointerType ( StringView  S)
static

Definition at line 2491 of file MicrosoftDemangle.cpp.

References StringView::front(), and StringView::startsWith().

Referenced by isFunctionType().

◆ isRebasedHexDigit()

static bool isRebasedHexDigit ( char  C)
static

Definition at line 1831 of file MicrosoftDemangle.cpp.

Referenced by rebasedHexDigitToNumber().

◆ isTagType()

static bool isTagType ( StringView  S)
static

Definition at line 2480 of file MicrosoftDemangle.cpp.

References StringView::front().

Referenced by isFunctionType().

◆ lastComponentAsOperator()

static const OperatorInfo* lastComponentAsOperator ( const Name TheName)
static

Definition at line 872 of file MicrosoftDemangle.cpp.

Referenced by outputName(), and outputSpecialOperator().

◆ outputCallingConvention()

static void outputCallingConvention ( OutputStream OS,
CallingConv  CC 
)
static

◆ outputEscapedChar()

static void outputEscapedChar ( OutputStream OS,
unsigned  C 
)
static

Definition at line 1942 of file MicrosoftDemangle.cpp.

References outputHex().

Referenced by decodeMultiByteChar().

◆ outputHex()

static void outputHex ( OutputStream OS,
unsigned  C 
)
static

Definition at line 1914 of file MicrosoftDemangle.cpp.

References assert(), I, and writeHexDigit().

Referenced by outputEscapedChar().

◆ outputName()

static void outputName ( OutputStream OS,
const Name TheName,
const Type Ty 
)
static

◆ outputNameComponent()

static void outputNameComponent ( OutputStream OS,
const Name N 
)
static

Definition at line 865 of file MicrosoftDemangle.cpp.

References outputParameterList().

Referenced by outputName(), and outputSpecialOperator().

◆ outputParameterList() [1/2]

static void outputParameterList ( OutputStream OS,
const FunctionParams &  Params 
)
static

Definition at line 745 of file MicrosoftDemangle.cpp.

Referenced by outputName(), outputNameComponent(), and outputSpecialOperator().

◆ outputParameterList() [2/2]

static void outputParameterList ( OutputStream OS,
const TemplateParams &  Params 
)
static

Definition at line 789 of file MicrosoftDemangle.cpp.

References I, and outputName().

◆ outputQualifiers()

static void outputQualifiers ( OutputStream OS,
Qualifiers  Q 
)
static

◆ outputSpaceIfNecessary()

static void outputSpaceIfNecessary ( OutputStream OS)
static

◆ outputSpecialOperator()

static void outputSpecialOperator ( OutputStream OS,
const Name OuterName 
)
static

Definition at line 983 of file MicrosoftDemangle.cpp.

References Array, assert(), StringView::begin(), Bool, C, Category, Char, Char16, Char32, Class, StringView::consumeFront(), OutputStream::create(), D, Double, Drop, StringView::dropFront(), StringView::empty(), Enum, llvm::lltok::Error, ExternC, Float, StringView::front(), Function, OutputStream::getBuffer(), Global, I, if(), Int, Int64, INT64_MAX, lastComponentAsOperator(), Ldouble, LiteralOperator, LocalStaticGuard, LocalVftable, Long, LValueRef, MemberPtr, N, NamedFunction, NamedVariable, NBB_Simple, NBB_Template, NoPrototype, Nullptr, llvm::RISCVFenceField::O, OperatorMapEntry::Operator, outputCallingConvention(), outputName(), outputNameComponent(), outputParameterList(), outputQualifiers(), outputSpaceIfNecessary(), outputStringLiteral(), llvm::json::parse(), Pointer, StringView::popFront(), PrivateStatic, ProtectedStatic, Ptr, PublicStatic, Q_Const, Q_None, Q_Restrict, Q_Unaligned, Q_Volatile, Reference, Result, llvm::MipsISD::Ret, RttiBaseClassDescriptor, RttiCompleteObjLocator, RttiTypeDescriptor, RValueRef, llvm::PPCISD::SC, Schar, Short, StringView::size(), SpecialOperator, StringView::startsWith(), startsWithDigit(), Static, StaticThisAdjust, StringLiteral, Struct, std::swap(), llvm::ARMBuildAttrs::Symbol, llvm::AMDGPU::HSAMD::Kernel::Key::SymbolName, Uchar, Uint, Uint64, Ulong, Union, Unknown, UnnamedFunction, UnnamedVariable, Ushort, Vbtable, Vcall, Vftable, Virtual, VirtualThisAdjust, VirtualThisAdjustEx, Void, and Wchar.

Referenced by demanglePointerCVQualifiers().

◆ outputStringLiteral()

static void outputStringLiteral ( OutputStream OS,
const StringLiteral &  Str 
)
static

Definition at line 764 of file MicrosoftDemangle.cpp.

References Char, Char16, Char32, outputName(), and Wchar.

Referenced by outputSpecialOperator().

◆ rebasedHexDigitToNumber()

static uint8_t rebasedHexDigitToNumber ( char  C)
static

◆ startsWithDigit()

static bool startsWithDigit ( StringView  S)
static

◆ startsWithLocalScopePattern()

static bool startsWithLocalScopePattern ( StringView  S)
static

Definition at line 703 of file MicrosoftDemangle.cpp.

References StringView::consumeFront(), and StringView::size().

Referenced by decodeMultiByteChar().

◆ writeHexDigit()

static void writeHexDigit ( char Buffer,
uint8_t  Digit 
)
static

Definition at line 1909 of file MicrosoftDemangle.cpp.

References assert().

Referenced by outputHex().

Variable Documentation

◆ OperatorMap

OperatorMapEntry OperatorMap[]

Definition at line 290 of file MicrosoftDemangle.cpp.