LLVM  8.0.0svn
Classes | Enumerations | Functions
MicrosoftDemangle.cpp File Reference
#include "MicrosoftDemangleNodes.h"
#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  NodeList
 

Enumerations

enum  QualifierMangleMode { QualifierMangleMode::Drop, QualifierMangleMode::Mangle, QualifierMangleMode::Result }
 
enum  FunctionIdentifierCodeGroup { FunctionIdentifierCodeGroup::Basic, FunctionIdentifierCodeGroup::Under, FunctionIdentifierCodeGroup::DoubleUnder }
 
enum  NameBackrefBehavior : uint8_t { NBB_None = 0, NBB_Template = 1 << 0, NBB_Simple = 1 << 1 }
 

Functions

static bool startsWithDigit (StringView S)
 
static bool isMemberPointer (StringView MangledName)
 
static SpecialIntrinsicKind consumeSpecialIntrinsicKind (StringView &MangledName)
 
static bool startsWithLocalScopePattern (StringView S)
 
static bool isTagType (StringView S)
 
static bool isCustomType (StringView S)
 
static bool isPointerType (StringView S)
 
static bool isArrayType (StringView S)
 
static bool isFunctionType (StringView S)
 
static FunctionRefQualifier demangleFunctionRefQualifier (StringView &MangledName)
 
static std::pair< Qualifiers, PointerAffinitydemanglePointerCVQualifiers (StringView &MangledName)
 
static NamedIdentifierNodesynthesizeNamedIdentifier (ArenaAllocator &Arena, StringView Name)
 
static QualifiedNameNodesynthesizeQualifiedName (ArenaAllocator &Arena, IdentifierNode *Identifier)
 
static QualifiedNameNodesynthesizeQualifiedName (ArenaAllocator &Arena, StringView Name)
 
static VariableSymbolNodesynthesizeVariable (ArenaAllocator &Arena, TypeNode *Type, StringView VariableName)
 
static IntrinsicFunctionKind translateIntrinsicFunctionCode (char CH, FunctionIdentifierCodeGroup Group)
 
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)
 
static unsigned countTrailingNullBytes (const uint8_t *StringBytes, int Length)
 
static unsigned countEmbeddedNulls (const uint8_t *StringBytes, unsigned Length)
 
static unsigned guessCharByteSize (const uint8_t *StringBytes, unsigned NumChars, unsigned NumBytes)
 
static unsigned decodeMultiByteChar (const uint8_t *StringBytes, unsigned CharIndex, unsigned CharBytes)
 
static NodeArrayNodenodeListToNodeArray (ArenaAllocator &Arena, NodeList *Head, size_t Count)
 

Enumeration Type Documentation

◆ FunctionIdentifierCodeGroup

Enumerator
Basic 
Under 
DoubleUnder 

Definition at line 43 of file MicrosoftDemangle.cpp.

◆ NameBackrefBehavior

enum NameBackrefBehavior : uint8_t
Enumerator
NBB_None 
NBB_Template 
NBB_Simple 

Definition at line 45 of file MicrosoftDemangle.cpp.

◆ QualifierMangleMode

enum QualifierMangleMode
strong
Enumerator
Drop 
Mangle 
Result 

Definition at line 36 of file MicrosoftDemangle.cpp.

Function Documentation

◆ consumeSpecialIntrinsicKind()

static SpecialIntrinsicKind consumeSpecialIntrinsicKind ( StringView MangledName)
static

◆ countEmbeddedNulls()

static unsigned countEmbeddedNulls ( const uint8_t *  StringBytes,
unsigned  Length 
)
static

Definition at line 1234 of file MicrosoftDemangle.cpp.

References I, and Result.

Referenced by guessCharByteSize().

◆ countTrailingNullBytes()

static unsigned countTrailingNullBytes ( const uint8_t *  StringBytes,
int  Length 
)
static

Definition at line 1223 of file MicrosoftDemangle.cpp.

Referenced by guessCharByteSize().

◆ decodeMultiByteChar()

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

◆ demangleFunctionRefQualifier()

static FunctionRefQualifier demangleFunctionRefQualifier ( StringView MangledName)
static

◆ demanglePointerCVQualifiers()

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

◆ guessCharByteSize()

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

Definition at line 1244 of file MicrosoftDemangle.cpp.

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

Referenced by decodeMultiByteChar().

◆ isArrayType()

static bool isArrayType ( StringView  S)
static

Definition at line 211 of file MicrosoftDemangle.cpp.

Referenced by nodeListToNodeArray().

◆ isCustomType()

static bool isCustomType ( StringView  S)
static

Definition at line 194 of file MicrosoftDemangle.cpp.

Referenced by nodeListToNodeArray().

◆ isFunctionType()

static bool isFunctionType ( StringView  S)
static

Definition at line 213 of file MicrosoftDemangle.cpp.

References StringView::startsWith().

Referenced by nodeListToNodeArray().

◆ isMemberPointer()

static bool isMemberPointer ( StringView  MangledName)
static

◆ isPointerType()

static bool isPointerType ( StringView  S)
static

Definition at line 196 of file MicrosoftDemangle.cpp.

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

Referenced by nodeListToNodeArray().

◆ isRebasedHexDigit()

static bool isRebasedHexDigit ( char  C)
static

Definition at line 1067 of file MicrosoftDemangle.cpp.

Referenced by rebasedHexDigitToNumber().

◆ isTagType()

static bool isTagType ( StringView  S)
static

Definition at line 183 of file MicrosoftDemangle.cpp.

References StringView::front().

Referenced by nodeListToNodeArray().

◆ nodeListToNodeArray()

static NodeArrayNode* nodeListToNodeArray ( ArenaAllocator Arena,
NodeList Head,
size_t  Count 
)
static

Definition at line 1578 of file MicrosoftDemangle.cpp.

References llvm::ms_demangle::PointerTypeNode::Affinity, llvm::ms_demangle::TemplateParameterReferenceNode::Affinity, llvm::ms_demangle::ArenaAllocator::alloc(), llvm::ms_demangle::ArenaAllocator::allocArray(), assert(), llvm::ms_demangle::Bool, llvm::ms_demangle::FunctionSignatureNode::CallConvention, llvm::ms_demangle::Cdecl, llvm::ms_demangle::Char, llvm::ms_demangle::Char16, llvm::ms_demangle::Char32, llvm::ms_demangle::Class, llvm::ms_demangle::PointerTypeNode::ClassParent, llvm::ms_demangle::Clrcall, llvm::ms_demangle::QualifiedNameNode::Components, StringView::consumeFront(), llvm::ms_demangle::NodeArrayNode::Count, D, demangleFunctionRefQualifier(), demanglePointerCVQualifiers(), llvm::ms_demangle::ArrayTypeNode::Dimensions, llvm::ms_demangle::Double, Drop, StringView::dropFront(), llvm::ms_demangle::Eabi, llvm::ms_demangle::ArrayTypeNode::ElementType, StringView::empty(), llvm::ms_demangle::Enum, llvm::ms_demangle::Fastcall, R600_InstFlag::FC, llvm::ms_demangle::FC_ExternC, llvm::ms_demangle::FC_Far, llvm::ms_demangle::FC_Global, llvm::ms_demangle::FC_None, llvm::ms_demangle::FC_NoParameterList, llvm::ms_demangle::FC_Private, llvm::ms_demangle::FC_Protected, llvm::ms_demangle::FC_Public, llvm::ms_demangle::FC_Static, llvm::ms_demangle::FC_StaticThisAdjust, llvm::ms_demangle::FC_Virtual, llvm::ms_demangle::FC_VirtualThisAdjust, llvm::ms_demangle::FC_VirtualThisAdjustEx, first, llvm::ms_demangle::Float, StringView::front(), llvm::ms_demangle::FunctionSignatureNode::FunctionClass, llvm::ms_demangle::FunctionLocalStatic, OutputStream::getBuffer(), OutputStream::getCurrentPosition(), llvm::ms_demangle::QualifiedNameNode::getUnqualifiedIdentifier(), llvm::ms_demangle::Global, I, llvm::ms_demangle::CustomTypeNode::Identifier, initializeOutputStream(), llvm::ms_demangle::Int, llvm::ms_demangle::Int64, isArrayType(), isCustomType(), isFunctionType(), isMemberPointer(), llvm::ms_demangle::TemplateParameterReferenceNode::IsMemberPointer, isPointerType(), isTagType(), llvm::ms_demangle::Ldouble, LLVM_FALLTHROUGH, llvm::ms_demangle::Long, Mangle, NodeList::N, N, llvm::ms_demangle::SymbolNode::Name, NodeList::Next, llvm::ms_demangle::NodeArrayNode::Nodes, llvm::ms_demangle::None, llvm::ms_demangle::Nullptr, llvm::ms_demangle::OF_Default, llvm::ms_demangle::TypeNode::output(), llvm::ms_demangle::FunctionSignatureNode::Params, llvm::json::parse(), llvm::ms_demangle::Pascal, llvm::ms_demangle::PointerTypeNode::Pointee, llvm::ms_demangle::Pointer, StringView::popFront(), llvm::ms_demangle::PrivateStatic, llvm::ms_demangle::ProtectedStatic, llvm::ms_demangle::PublicStatic, llvm::ms_demangle::Q_Const, llvm::ms_demangle::Q_None, llvm::ms_demangle::Q_Pointer64, llvm::ms_demangle::Q_Restrict, llvm::ms_demangle::Q_Unaligned, llvm::ms_demangle::Q_Volatile, llvm::ms_demangle::TagTypeNode::QualifiedName, llvm::ms_demangle::TypeNode::Quals, llvm::ms_demangle::Reference, llvm::ms_demangle::FunctionSignatureNode::RefQualifier, Result, llvm::ms_demangle::FunctionSignatureNode::ReturnType, llvm::ms_demangle::Schar, OutputStream::setCurrentPosition(), llvm::ms_demangle::Short, llvm::ms_demangle::FunctionSymbolNode::Signature, StringView::size(), StringView::startsWith(), startsWithDigit(), llvm::ms_demangle::ThunkSignatureNode::ThisAdjustor::StaticOffset, llvm::ms_demangle::Stdcall, llvm::ms_demangle::Struct, llvm::ARMBuildAttrs::Symbol, llvm::ms_demangle::TemplateParameterReferenceNode::Symbol, llvm::ms_demangle::ThunkSignatureNode::ThisAdjust, llvm::ms_demangle::Thiscall, llvm::ms_demangle::TemplateParameterReferenceNode::ThunkOffsetCount, llvm::ms_demangle::TemplateParameterReferenceNode::ThunkOffsets, llvm::ms_demangle::Uchar, llvm::ms_demangle::Uint, llvm::ms_demangle::Uint64, llvm::ms_demangle::Ulong, llvm::ms_demangle::Union, llvm::ms_demangle::Ushort, llvm::ms_demangle::ThunkSignatureNode::ThisAdjustor::VBOffsetOffset, llvm::ms_demangle::ThunkSignatureNode::ThisAdjustor::VBPtrOffset, llvm::ms_demangle::Vectorcall, llvm::ms_demangle::Void, llvm::ms_demangle::ThunkSignatureNode::ThisAdjustor::VtordispOffset, and llvm::ms_demangle::Wchar.

◆ outputEscapedChar()

static void outputEscapedChar ( OutputStream OS,
unsigned  C 
)
static

Definition at line 1178 of file MicrosoftDemangle.cpp.

References outputHex().

Referenced by decodeMultiByteChar().

◆ outputHex()

static void outputHex ( OutputStream OS,
unsigned  C 
)
static

Definition at line 1150 of file MicrosoftDemangle.cpp.

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

Referenced by outputEscapedChar().

◆ 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 142 of file MicrosoftDemangle.cpp.

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

◆ synthesizeNamedIdentifier()

static NamedIdentifierNode* synthesizeNamedIdentifier ( ArenaAllocator Arena,
StringView  Name 
)
static

◆ synthesizeQualifiedName() [1/2]

static QualifiedNameNode* synthesizeQualifiedName ( ArenaAllocator Arena,
IdentifierNode Identifier 
)
static

◆ synthesizeQualifiedName() [2/2]

static QualifiedNameNode* synthesizeQualifiedName ( ArenaAllocator Arena,
StringView  Name 
)
static

◆ synthesizeVariable()

static VariableSymbolNode* synthesizeVariable ( ArenaAllocator Arena,
TypeNode Type,
StringView  VariableName 
)
static

Definition at line 483 of file MicrosoftDemangle.cpp.

References llvm::ms_demangle::ArenaAllocator::alloc(), assert(), Basic, StringView::consumeFront(), consumeSpecialIntrinsicKind(), DoubleUnder, StringView::dropFront(), llvm::ms_demangle::DynamicAtexitDestructor, llvm::ms_demangle::DynamicInitializer, StringView::empty(), llvm::ms_demangle::RttiBaseClassDescriptorNode::Flags, I, llvm::ms_demangle::DynamicStructorIdentifierNode::IsDestructor, llvm::ms_demangle::StructorIdentifierNode::IsDestructor, llvm::ms_demangle::Node::kind(), llvm::ms_demangle::LocalStaticGuard, llvm::ms_demangle::LocalVftable, N, llvm::ms_demangle::DynamicStructorIdentifierNode::Name, llvm::ms_demangle::LiteralOperatorIdentifierNode::Name, llvm::ms_demangle::SymbolNode::Name, llvm::ms_demangle::None, llvm::ms_demangle::RttiBaseClassDescriptorNode::NVOffset, Result, llvm::ms_demangle::RttiBaseClassArray, llvm::ms_demangle::RttiBaseClassDescriptor, llvm::ms_demangle::RttiClassHierarchyDescriptor, llvm::ms_demangle::RttiCompleteObjLocator, llvm::ms_demangle::RttiTypeDescriptor, StringView::startsWith(), llvm::ms_demangle::StringLiteralSymbol, llvm::ARMBuildAttrs::Symbol, synthesizeNamedIdentifier(), synthesizeQualifiedName(), llvm::ms_demangle::VariableSymbolNode::Type, Under, llvm::ms_demangle::DynamicStructorIdentifierNode::Variable, llvm::ms_demangle::VariableSymbol, llvm::ms_demangle::RttiBaseClassDescriptorNode::VBPtrOffset, llvm::ms_demangle::Vbtable, llvm::ms_demangle::RttiBaseClassDescriptorNode::VBTableOffset, llvm::ms_demangle::VcallThunk, and llvm::ms_demangle::Vftable.

◆ translateIntrinsicFunctionCode()

static IntrinsicFunctionKind translateIntrinsicFunctionCode ( char  CH,
FunctionIdentifierCodeGroup  Group 
)
static

Definition at line 656 of file MicrosoftDemangle.cpp.

References llvm::ms_demangle::ArenaAllocator::alloc(), llvm::ms_demangle::ArrayDelete, llvm::ms_demangle::ArrayNew, llvm::ms_demangle::ArraySubscript, assert(), llvm::ms_demangle::Assign, Basic, llvm::ms_demangle::BitwiseAnd, llvm::ms_demangle::BitwiseAndEqual, llvm::ms_demangle::BitwiseNot, llvm::ms_demangle::BitwiseOr, llvm::ms_demangle::BitwiseOrEqual, llvm::ms_demangle::BitwiseXor, llvm::ms_demangle::BitwiseXorEqual, C, llvm::ms_demangle::PointerTypeNode::ClassParent, llvm::ms_demangle::CoAwait, llvm::ms_demangle::Comma, StringView::consumeFront(), llvm::ms_demangle::ConversionOperatorIdentifier, llvm::ms_demangle::CopyCtorClosure, llvm::ms_demangle::Decrement, llvm::ms_demangle::DefaultCtorClosure, llvm::ms_demangle::Delete, llvm::ms_demangle::Dereference, llvm::ms_demangle::DivEqual, llvm::ms_demangle::Divide, DoubleUnder, Drop, StringView::dropFront(), llvm::ms_demangle::EHVecCtorIter, llvm::ms_demangle::EHVecDtorIter, llvm::ms_demangle::EHVectorCopyCtorIter, llvm::ms_demangle::EHVectorVbaseCopyCtorIter, llvm::ms_demangle::EHVecVbaseCtorIter, llvm::ms_demangle::Equals, StringView::front(), OutputStream::getBuffer(), llvm::ms_demangle::QualifiedNameNode::getUnqualifiedIdentifier(), llvm::ms_demangle::GreaterThan, llvm::ms_demangle::GreaterThanEqual, I, llvm::ms_demangle::Identifier, llvm::ms_demangle::Increment, initializeOutputStream(), INT64_MAX, llvm::ms_demangle::Node::kind(), llvm::ms_demangle::LeftShift, llvm::ms_demangle::LessThan, llvm::ms_demangle::LessThanEqual, llvm::ms_demangle::LocalVftableCtorClosure, llvm::ms_demangle::LogicalAnd, llvm::ms_demangle::LogicalNot, llvm::ms_demangle::LogicalOr, llvm::ms_demangle::LshEqual, llvm::ms_demangle::ManVectorCtorIter, llvm::ms_demangle::ManVectorDtorIter, llvm::ms_demangle::ManVectorVbaseCopyCtorIter, llvm::ms_demangle::Md5Symbol, llvm::ms_demangle::MemberPointer, llvm::ms_demangle::Minus, llvm::ms_demangle::MinusEqual, llvm::ms_demangle::ModEqual, llvm::ms_demangle::Modulus, N, Name, llvm::ms_demangle::NamedIdentifierNode::Name, llvm::ms_demangle::SymbolNode::Name, NBB_Simple, NBB_Template, llvm::ms_demangle::New, llvm::ms_demangle::None, llvm::ms_demangle::NotEquals, Number, llvm::ms_demangle::OF_Default, llvm::ms_demangle::Node::output(), llvm::ms_demangle::Parens, llvm::json::parse(), llvm::ms_demangle::Plus, llvm::ms_demangle::PlusEqual, llvm::ms_demangle::PointerTypeNode::Pointee, llvm::ms_demangle::Pointer, llvm::ms_demangle::PointerType, StringView::popFront(), llvm::ms_demangle::Q_None, llvm::ms_demangle::TypeNode::Quals, llvm::MipsISD::Ret, llvm::ms_demangle::FunctionSignatureNode::ReturnType, llvm::ms_demangle::RightShift, llvm::ms_demangle::RshEqual, llvm::PPCISD::SC, llvm::ms_demangle::VariableSymbolNode::SC, llvm::ms_demangle::ScalarDelDtor, SI, llvm::ms_demangle::FunctionSymbolNode::Signature, StringView::size(), StringView::startsWith(), startsWithDigit(), std::swap(), llvm::ARMBuildAttrs::Symbol, synthesizeQualifiedName(), llvm::ms_demangle::ConversionOperatorIdentifierNode::TargetType, llvm::ms_demangle::IdentifierNode::TemplateParams, llvm::ms_demangle::TimesEqual, llvm::ms_demangle::VariableSymbolNode::Type, Under, llvm::ms_demangle::VbaseDtor, llvm::ms_demangle::VdispMap, llvm::ms_demangle::VecCtorIter, llvm::ms_demangle::VecDelDtor, llvm::ms_demangle::VecDtorIter, llvm::ms_demangle::VectorCopyCtorIter, llvm::ms_demangle::VectorVbaseCopyCtorIter, and llvm::ms_demangle::VecVbaseCtorIter.

◆ writeHexDigit()

static void writeHexDigit ( char Buffer,
uint8_t  Digit 
)
static

Definition at line 1145 of file MicrosoftDemangle.cpp.

References assert().

Referenced by outputHex().