LLVM  8.0.1
Classes | Functions
MicrosoftDemangle.cpp File Reference
#include "llvm/Demangle/MicrosoftDemangle.h"
#include "llvm/Demangle/Demangle.h"
#include "llvm/Demangle/MicrosoftDemangleNodes.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
 

Functions

static bool startsWithDigit (StringView S)
 
static bool isMemberPointer (StringView MangledName, bool &Error)
 
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)
 

Function Documentation

◆ consumeSpecialIntrinsicKind()

static SpecialIntrinsicKind consumeSpecialIntrinsicKind ( StringView MangledName)
static

◆ countEmbeddedNulls()

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

Definition at line 1093 of file MicrosoftDemangle.cpp.

References I, and llvm::ms_demangle::Result.

Referenced by guessCharByteSize().

◆ countTrailingNullBytes()

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

Definition at line 1082 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 1103 of file MicrosoftDemangle.cpp.

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

Referenced by decodeMultiByteChar().

◆ isArrayType()

static bool isArrayType ( StringView  S)
static

Definition at line 205 of file MicrosoftDemangle.cpp.

Referenced by nodeListToNodeArray().

◆ isCustomType()

static bool isCustomType ( StringView  S)
static

Definition at line 188 of file MicrosoftDemangle.cpp.

Referenced by nodeListToNodeArray().

◆ isFunctionType()

static bool isFunctionType ( StringView  S)
static

Definition at line 207 of file MicrosoftDemangle.cpp.

References StringView::startsWith().

Referenced by nodeListToNodeArray().

◆ isMemberPointer()

static bool isMemberPointer ( StringView  MangledName,
bool Error 
)
static

◆ isPointerType()

static bool isPointerType ( StringView  S)
static

Definition at line 190 of file MicrosoftDemangle.cpp.

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

Referenced by nodeListToNodeArray().

◆ isRebasedHexDigit()

static bool isRebasedHexDigit ( char  C)
static

Definition at line 926 of file MicrosoftDemangle.cpp.

Referenced by rebasedHexDigitToNumber().

◆ isTagType()

static bool isTagType ( StringView  S)
static

Definition at line 177 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 1437 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, llvm::ms_demangle::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, llvm::ms_demangle::QualifiedNameNode::getUnqualifiedIdentifier(), llvm::ms_demangle::Global, I, llvm::ms_demangle::CustomTypeNode::Identifier, llvm::ms_demangle::Int, llvm::ms_demangle::Int64, isArrayType(), isCustomType(), isFunctionType(), isMemberPointer(), llvm::ms_demangle::TemplateParameterReferenceNode::IsMemberPointer, llvm::ms_demangle::FunctionSignatureNode::IsNoexcept, isPointerType(), isTagType(), llvm::ms_demangle::Ldouble, LLVM_FALLTHROUGH, llvm::ms_demangle::Long, llvm::ms_demangle::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::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, llvm::ms_demangle::Result, llvm::ms_demangle::FunctionSignatureNode::ReturnType, llvm::ms_demangle::Schar, 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 1037 of file MicrosoftDemangle.cpp.

References outputHex().

Referenced by decodeMultiByteChar().

◆ outputHex()

static void outputHex ( OutputStream OS,
unsigned  C 
)
static

Definition at line 1009 of file MicrosoftDemangle.cpp.

References assert(), I, llvm::Intrinsic::memset, 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 136 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 332 of file MicrosoftDemangle.cpp.

References llvm::ms_demangle::ArenaAllocator::alloc(), assert(), llvm::ms_demangle::Basic, StringView::consumeFront(), consumeSpecialIntrinsicKind(), llvm::ms_demangle::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, llvm::ms_demangle::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, llvm::ms_demangle::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 505 of file MicrosoftDemangle.cpp.

References llvm::ms_demangle::ArenaAllocator::alloc(), llvm::ms_demangle::ArrayDelete, llvm::ms_demangle::ArrayNew, llvm::ms_demangle::ArraySubscript, llvm::ms_demangle::Assign, llvm::ms_demangle::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, llvm::ms_demangle::CoAwait, llvm::ms_demangle::Comma, 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, llvm::ms_demangle::DoubleUnder, 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(), llvm::ms_demangle::QualifiedNameNode::getUnqualifiedIdentifier(), llvm::ms_demangle::GreaterThan, llvm::ms_demangle::GreaterThanEqual, llvm::ms_demangle::Increment, 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::MemberPointer, llvm::ms_demangle::Minus, llvm::ms_demangle::MinusEqual, llvm::ms_demangle::ModEqual, llvm::ms_demangle::Modulus, Name, llvm::ms_demangle::New, llvm::ms_demangle::None, llvm::ms_demangle::NotEquals, llvm::ms_demangle::Parens, llvm::ms_demangle::Plus, llvm::ms_demangle::PlusEqual, llvm::ms_demangle::Pointer, StringView::popFront(), llvm::ms_demangle::FunctionSignatureNode::ReturnType, llvm::ms_demangle::RightShift, llvm::ms_demangle::RshEqual, llvm::PPCISD::SC, llvm::ms_demangle::ScalarDelDtor, llvm::ms_demangle::FunctionSymbolNode::Signature, llvm::ms_demangle::ConversionOperatorIdentifierNode::TargetType, llvm::ms_demangle::TimesEqual, llvm::ms_demangle::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 1004 of file MicrosoftDemangle.cpp.

References assert().

Referenced by outputHex().