From cb7d0695afa90b7515f1ce50916df9a28dd64597 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski Date: Fri, 14 Jul 2023 04:15:56 -0400 Subject: [PATCH] feat: improved clang and llvm natvis --- src/lib/clang.natvis | 694 +++++++++++++++++++++++++++++++++++-------- src/lib/llvm.natvis | 143 +++++---- 2 files changed, 653 insertions(+), 184 deletions(-) diff --git a/src/lib/clang.natvis b/src/lib/clang.natvis index d42f4c6b6..e53da8eab 100644 --- a/src/lib/clang.natvis +++ b/src/lib/clang.natvis @@ -9,6 +9,8 @@ For later versions of Visual Studio, no setup is required--> + + - {TTPDecl->Name,view(cpp)} - Non-canonical: {*TTPDecl} + {TTPDecl->Name,view(cpp)} + Non-canonical: {*TTPDecl} Canonical: {CanTTPTInfo} *(clang::Type *)this, view(cmn) @@ -542,8 +544,8 @@ For later versions of Visual Studio, no setup is required--> , {((clang::TemplateArgument *)(this+1))[1],view(cpp)}{*this,view(arg2)} , {((clang::TemplateArgument *)(this+1))[2],view(cpp)}{*this,view(arg3)} - - {*((clang::TemplateDecl *)(Template.Storage.Val.Value))->TemplatedDecl,view(cpp)}<{*this,view(arg0)}> + + {*((clang::TemplateDecl *)(Template.Storage.get_ptr()))->TemplatedDecl,view(cpp)}<{*this,view(arg0)}> Can't visualize this TemplateSpecializationType @@ -557,28 +559,21 @@ For later versions of Visual Studio, no setup is required--> - (CanonicalType.Value.Value != this) || TypeBits.Dependent + ! is_canonical() || TypeBits.Dependent *(clang::Type *)this,view(cmn) - {CanonicalType,view(cpp)} + {CanonicalType,view(cpp)} {Template,view(cpp)} {Template} Template - CanonicalType,view(cpp) + CanonicalType,view(cpp) (clang::DeducedType *)this Template - - {*(CXXRecordDecl *)this,nd}{*TemplateArgs} - - (CXXRecordDecl *)this,nd - TemplateArgs - - {((llvm::StringMapEntry<clang::IdentifierInfo *>*)Entry)+1,sb} @@ -748,49 +743,583 @@ For later versions of Visual Studio, no setup is required--> {Name,s} + + invalid + {ID} + + - - {(clang::Decl::Kind)DeclKind,en}Decl + + [IK_Identifier] {*Identifier} + [IK_OperatorFunctionId] {OperatorFunctionId} + [IK_ConversionFunctionId] {ConversionFunctionId} + [IK_ConstructorName] {ConstructorName} + [IK_DestructorName] {DestructorName} + [IK_DeductionGuideName] {TemplateName} + [IK_TemplateId] {TemplateId} + [IK_ConstructorTemplateId] {TemplateId} + Kind - (clang::Decl::Kind)DeclKind,en - (uintptr_t)this,x - Implicit - (AccessSpecifier)Access - *dynamic_cast<clang::DeclContext*>(this) + Identifier + OperatorFunctionId + ConversionFunctionId + ConstructorName + DestructorName + TemplateName + TemplateId + TemplateId - - {Name,view(cpp)} - {Name} + + {*($T1*)&Ptr} - *(clang::Decl*)this,nd - Name + ($T1*)&Ptr + + + + {($T1 *)Ptr} + + ($T1 *)Ptr + + + + {(clang::Stmt::StmtClass)StmtBits.sClass,en} + + (clang::Stmt::StmtClass)StmtBits.sClass,en + + + + Expression of class {(clang::Stmt::StmtClass)StmtBits.sClass,en} and type {TR,view(cpp)} + + + + {*((NamedDecl **)(this+1))[0],view(cpp)}{*this,view(parm1)} + + , {*((NamedDecl **)(this+1))[1],view(cpp)}{*this,view(parm2)} + + , {*((NamedDecl **)(this+1))[2],view(cpp)}{*this,view(parm3)} + + , {*((NamedDecl **)(this+1))[3],view(cpp)}{*this,view(parm4)} + + , {*((NamedDecl **)(this+1))[4],view(cpp)}{*this,view(parm5)} + + , /* Expand for more params */ + <{*this,view(parm0)}> + + + NumParams + (NamedDecl **)(this+1) + - + + + + + + + + + + + + + + get_int() + get_ptr() + + + + + + + + + + + + + + + get_first() + get_previous() + ($T1*)this + + + + + + + + + + + + {get_kind(),en}Decl (implicit) + {get_kind(),en}Decl + + + get_kind(),en + (uintptr_t)this,x + + public + protected + private + none + invalid + + + + - {(clang::Decl::Kind)DeclContextBits.DeclKind,en}Decl + - - + FirstDecl - (clang::Decl *)(*(intptr_t *)NextInContextAndBits.Value.Data & ~3) + (clang::Decl *)(*(intptr_t*)NextInContextAndBits.Value.Data & ~3) *this + + + + + {Name} + + *(Decl*)this,nd + Name + + + + + {Name} + + *(NamedDecl*)this,nd + DeclType + + + + + + {Name} + + *(NamedDecl*)this,nd + + {DeclType} + + DeclType + get_type_as_written(),na + + + + + + + + + + + + + + + + + + + *(DeclaratorDecl*)this,nd + + + (FunctionTemplateDecl*)TemplateOrSpecialization.get_ptr() + + + (FunctionDecl*)TemplateOrSpecialization.get_ptr() + + + + (MemberSpecializationInfo*)TemplateOrSpecialization.get_ptr() + + + + (FunctionTemplateSpecializationInfo*)TemplateOrSpecialization.get_ptr() + + + + *(redeclarable_base*)this,nd + *(DeclContext*)this,nd + + + + + + + *(NamedDecl*)this,nd + *(redeclarable_base*)this,nd + *(DeclContext*)this,nd + + + + + + + *(NamedDecl*)this,nd + TemplateParams,na + TemplatedDecl,na + + + + + + + + *(RedeclarableTemplateDecl::CommonBase*)this,nd + + InjectedClassNameType + + empty + {Specializations.Vector.Size} elements + + + Specializations.Vector.Size + (ClassTemplateSpecializationDecl**)Specializations.Vector.BeginX + + + + + empty + {PartialSpecializations.Vector.Size} elements + + + PartialSpecializations.Vector.Size + (ClassTemplatePartialSpecializationDecl**)PartialSpecializations.Vector.BeginX + + + + + + + + + *(RedeclarableTemplateDecl::CommonBase*)this,nd + + + empty + {Specializations.Vector.Size} elements + + + Specializations.Vector.Size + (VarTemplateSpecializationDecl**)Specializations.Vector.BeginX + + + + + empty + {PartialSpecializations.Vector.Size} elements + + + PartialSpecializations.Vector.Size + (VarTemplatePartialSpecializationDecl**)PartialSpecializations.Vector.BeginX + + + + + + + + + *(RedeclarableTemplateDecl::CommonBase*)this,nd + + + empty + {Specializations.Vector.Size} elements + + + Specializations.Vector.Size + (FunctionTemplateSpecializationInfo**)Specializations.Vector.BeginX + + + + + + + + + *(RedeclarableTemplateDecl::CommonBase*)this,nd + + + + + + InstantiatedFromMember.get_int() + InstantiatedFromMember.get_ptr() + LazySpecializations + InjectedArgs + + + + + - Field {{{*(clang::DeclaratorDecl *)this,view(cpp)nd}}} + + + *(DeclaratorDecl*)this,nd + + + + + + + {(Decl*)this,nand} + + *(Decl*)this,nd + + + + NumTPLists + (TemplateParameterList**)(this + 1) + + + + + (NamedDecl*)Friend.get_ptr() + (TypeSourceInfo*)Friend.get_ptr() + (bool)UnsupportedFriend + + + + + + + + + + + *(TemplateDecl*)this,nd + + + + *(ClassTemplateDecl::Common*)get_common_ptr() + + + *(VarTemplateDecl::Common*)get_common_ptr() + + + *(FunctionTemplateDecl::Common*)get_common_ptr() + + + *(TypeAliasTemplateDecl::Common*)get_common_ptr() + + + *(redeclarable_base*)this,nd + + + + + + + + *(RedeclarableTemplateDecl*)this,nd + + + + + + clang::TemplateSpecializationKind(Template.get_int() + 1),en + Function.get_int() + + *reinterpret_cast<MemberSpecializationInfo**>(this + 1) + + Function.get_ptr() + Template.get_ptr() + TemplateArguments + TemplateArgumentsAsWritten + PointOfInstantiation + + + + + + *(Decl*)this,nd + TemplateArgs,na + Specialization + + + + + + + clang::TemplateSpecializationKind(MemberAndTSK.get_int() + 1),en + + MemberAndTSK.get_ptr() + + PointOfInstantiation + + + + + + + {*(VarDecl*)this,nd} + + ParmVarDeclBits + *(VarDecl*)this,nd + + + + + + + + + + + + *(DeclaratorDecl*)this,nd + + as_vtpsd()->TemplateParams,na + as_vtsd()->TemplateArgs,na + + + clang::TemplateSpecializationKind(as_vtsd()->SpecializationKind),en + + + + + as_vtpsd()->InstantiatedFromMember.get_int() + + as_vtpsd()->InstantiatedFromMember.get_ptr() + + + + + (VarTemplateDecl*)as_vtsd()->SpecializedTemplate.get_ptr() + + + ((VarTemplateSpecializationDecl::SpecializedPartialSpecialization*)(as_vtsd()->SpecializedTemplate).get_ptr())->PartialSpecialization + + as_vtsd()->PointOfInstantiation + + *(redeclarable_base*)this,nd + + + + + + + + + + + + + + + *(NamedDecl*)this,nd + as_ctpsd()->TemplateParams,na + as_ctsd()->TemplateArgs,na + + + clang::TemplateSpecializationKind(as_ctsd()->SpecializationKind),en + + + clang::TemplateSpecializationKind( + ((MemberSpecializationInfo*)TemplateOrInstantiation.get_ptr())->MemberAndTSK.get_int() + 1),en + + + as_ctpsd()->InstantiatedFromMember.get_int() + + as_ctpsd()->InstantiatedFromMember.get_ptr() + + + + (ClassTemplateDecl*)TemplateOrInstantiation.get_ptr() + + + (MemberSpecializationInfo*)TemplateOrInstantiation.get_ptr() + + + + (ClassTemplateDecl*)as_ctsd()->SpecializedTemplate.get_ptr() + + + ((ClassTemplateSpecializationDecl::SpecializedPartialSpecialization*)(as_ctsd()->SpecializedTemplate).get_ptr())->PartialSpecialization + + as_ctsd()->PointOfInstantiation + + *(redeclarable_base*)this,nd + *(DeclContext*)this,nd + + + + + + TemplatedDecl,na - {(clang::TypeSourceInfo *)(*(uintptr_t *)MaybeModedTInfo.Value.Data & ~7LL),view(cpp)na} {(clang::TypedefNameDecl::ModedTInfo *)(*(uintptr_t *)MaybeModedTInfo.Value.Data & ~7LL),view(cpp)na} @@ -947,6 +1475,7 @@ For later versions of Visual Studio, no setup is required--> {this,view(retType)nand} {Name,view(cpp)nd}({*this,view(parm0)nd}) (clang::DeclaratorDecl *)this,nd + (clang::Redeclarable<clang::FunctionDecl> *)this,nd ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)((*(uintptr_t *)DeclType.Value.Value.Data) & ~15))->BaseType)->ResultType {*this,view(parm0)nd} @@ -960,48 +1489,12 @@ For later versions of Visual Studio, no setup is required--> TemplateOrSpecialization - - {*($T1*)&Ptr} - - ($T1*)&Ptr - - - - {($T1 *)Ptr} - - ($T1 *)Ptr - - - - - {*((NamedDecl **)(this+1))[0],view(cpp)}{*this,view(parm1)} - - , {*((NamedDecl **)(this+1))[1],view(cpp)}{*this,view(parm2)} - - , {*((NamedDecl **)(this+1))[2],view(cpp)}{*this,view(parm3)} - - , {*((NamedDecl **)(this+1))[3],view(cpp)}{*this,view(parm4)} - - , {*((NamedDecl **)(this+1))[4],view(cpp)}{*this,view(parm5)} - - , /* Expand for more params */ - <{*this,view(parm0)}> - - - NumParams - (NamedDecl **)(this+1) - - - - - {(clang::Stmt::StmtClass)StmtBits.sClass,en} - - (clang::Stmt::StmtClass)StmtBits.sClass,en - - - - Expression of class {(clang::Stmt::StmtClass)StmtBits.sClass,en} and type {TR,view(cpp)} - + --> + + + + + *(clang::NamedDecl *)(Ptr&~Mask) - - [IK_Identifier] {*Identifier} - [IK_OperatorFunctionId] {OperatorFunctionId} - [IK_ConversionFunctionId] {ConversionFunctionId} - [IK_ConstructorName] {ConstructorName} - [IK_DestructorName] {DestructorName} - [IK_DeductionGuideName] {TemplateName} - [IK_TemplateId] {TemplateId} - [IK_ConstructorTemplateId] {TemplateId} - Kind - - Identifier - OperatorFunctionId - ConversionFunctionId - ConstructorName - DestructorName - TemplateName - TemplateId - TemplateId - - + NumDecls={NumDecls} @@ -1052,31 +1525,6 @@ For later versions of Visual Studio, no setup is required--> (DeclGroup *)((uintptr_t)D&~1) - - {DS} {Name} - - - {Decls} - - Decls - - - - {Ambiguity,en}: {Decls} - {ResultKind,en}: {Decls} - - - Invalid - Unset - {Val} - - - Invalid - Unset - {($T1)(PtrWithInvalid&~1)} - - (bool)(PtrWithInvalid&1) - ($T1)(PtrWithInvalid&~1) - - + --> + diff --git a/src/lib/llvm.natvis b/src/lib/llvm.natvis index 532ee7b48..69402a237 100644 --- a/src/lib/llvm.natvis +++ b/src/lib/llvm.natvis @@ -68,76 +68,58 @@ For later versions of Visual Studio, no setup is required. - - {($T1)*(intptr_t *)Data} - - - - - - {($T1)(*(intptr_t *)Value.Data & $T6::PointerBitMask)} - {($T4)((*(intptr_t *)Value.Data >> $T6::IntShift) & $T6::IntMask)} - {$T6::IntMask}: {($T1)(*(intptr_t *)Value.Data & $T6::PointerBitMask)} [{($T4)((*(intptr_t *)Value.Data >> $T6::IntShift) & $T6::IntMask)}] + + - ($T1)(*(intptr_t *)Value.Data & $T6::PointerBitMask) - ($T4)((*(intptr_t *)Value.Data >> $T6::IntShift) & $T6::IntMask) + + {get_value(),nrx} + - {($T1)(*(intptr_t *)Value.Data & $T5::PointerBitMask)} - {($T3)((*(intptr_t *)Value.Data >> $T5::IntShift) & $T5::IntMask)} - {$T5::IntMask}: {($T1)(*(intptr_t *)Value.Data & $T5::PointerBitMask)} [{($T3)((*(intptr_t *)Value.Data >> $T5::IntShift) & $T5::IntMask)}] + + + + + + + {get_ptr()} + {get_int()} + {$T5::IntMask}: {get_ptr()} [{get_int()}] - ($T1)(*(intptr_t *)Value.Data & $T5::PointerBitMask) - ($T3)((*(intptr_t *)Value.Data >> $T5::IntShift) & $T5::IntMask) + get_ptr() + get_int() - - - - {($T4)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask)} - - - {($T5)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask)} - - - - {($T6)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask)} - - - {($T7)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask)} - - - Unexpected index in PointerUnion: {(*(intptr_t *)Val.Value.Data>>$T2::InfoTy::IntShift) & $T2::InfoTy::IntMask} - - "$T4",s8b - - ($T4)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask) - - "$T5",s8b - - ($T5)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask) - - - "$T6",s8b - - ($T6)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask) - - "$T7",s8b - - ($T7)(*(intptr_t *)Val.Value.Data & $T2::InfoTy::PointerBitMask) - + + + + + + + + {"$T1",sb} + {"$T2",sb} + {"$T3",sb} + {"$T4",sb} + {"$T5",sb} + {"$T6",sb} + {"$T7",sb} + {"$T8",sb} + + ($T1)get_ptr() + ($T2)get_ptr() + ($T3)get_ptr() + ($T4)get_ptr() + ($T5)get_ptr() + ($T6)get_ptr() + ($T7)get_ptr() + ($T8)get_ptr() - + {{ empty }} {{ head={Head} }} @@ -152,8 +134,13 @@ For later versions of Visual Studio, no setup is required. empty - RefPtr [1 ref] {*Obj} - RefPtr [{Obj->RefCount} refs] {*Obj} + + RefPtr [1 ref] {*Obj} + RefPtr [{Obj->RefCount} refs] {*Obj} + + RefPtr [1 ref] {*Obj} + RefPtr [{Obj->RefCount} refs] {*Obj} + Obj->RefCount Obj @@ -186,6 +173,40 @@ For later versions of Visual Studio, no setup is required. + + empty + {{ size={NumNodes}, buckets={NumBuckets} }} + + NumNodes + NumBuckets + + NumBuckets + ($T1**)Buckets + + + + + + empty + {{ size={NumNodes}, buckets={NumBuckets} }} + + Context + NumNodes + NumBuckets + + NumBuckets + ($T1**)Buckets + + + + + + + Set + Vector + + + {{ size={NumItems}, buckets={NumBuckets} }}