Skip to content

Instantly share code, notes, and snippets.

@tritao
Created November 5, 2013 01:17
Show Gist options
  • Save tritao/7312257 to your computer and use it in GitHub Desktop.
Save tritao/7312257 to your computer and use it in GitHub Desktop.
LLVM & Clang Natvis
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="clang::Stmt">
<Expand>
<Item Name="Statement Class">(Stmt::StmtClass)StmtBits.sClass</Item>
</Expand>
</Type>
<Type Name="clang::Expr">
<Expand>
<Item Name="Type">TR</Item>
<ExpandedItem>*(clang::Stmt*)this,nd</ExpandedItem>
<Item Name="Object Kind">(ExprObjectKind)ExprBits.ObjectKind</Item>
<Item Name="Type Dependent">(bool)ExprBits.TypeDependent</Item>
<Item Name="Value Dependent">(bool)ExprBits.ValueDependent</Item>
<Item Name="Instantiation Dependent">(bool)ExprBits.InstantiationDependent</Item>
<Item Name="Unexpanded Parameter Pack">(bool)ExprBits.ContainsUnexpandedParameterPack</Item>
</Expand>
</Type>
<Type Name="clang::MemberExpr">
<Expand>
<ExpandedItem>*(clang::Expr*)this,nd</ExpandedItem>
<Item Name="Base">Base</Item>
<Item Name="Member Declaration">MemberDecl</Item>
<Item Name="Member Declaration Name">MemberDNLoc</Item>
<Item Name="IsArrow">IsArrow</Item>
<Item Name="HasQualifierOrFoundDecl">HasQualifierOrFoundDecl</Item>
<Item Name="HasTemplateKWAndArgsInfo">HasTemplateKWAndArgsInfo</Item>
<Item Name="HadMultipleCandidates">HadMultipleCandidates</Item>
<Item Name="MemberNameQualifier" Condition="HasQualifierOrFoundDecl">(MemberNameQualifier *)(this+1)</Item>
</Expand>
</Type>
<Type Name="clang::InitListExpr">
<Expand>
<ExpandedItem>*(clang::Expr*)this,nd</ExpandedItem>
<Item Name="Inits">InitExprs</Item>
</Expand>
</Type>
<Type Name="clang::ASTVector&lt;*&gt;">
<DisplayString>{{ size={($T1*)End - ($T1*)Begin}, capacity={($T1*)Capacity - ($T1*)Begin} }}</DisplayString>
<Expand>
<Item Name="[size]">($T1*)End - ($T1*)Begin</Item>
<Item Name="[capacity]">($T1*)Capacity - ($T1*)Begin</Item>
<ArrayItems>
<Size>($T1*)End - ($T1*)Begin</Size>
<ValuePointer>($T1*)Begin</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="clang::ActionResult&lt;*,0&gt;">
<Expand>
<Item Name="Invalid">Invalid</Item>
<Item Name="Value" Condition="!Invalid">($T1)Val</Item>
</Expand>
</Type>
<Type Name="clang::ActionResult&lt;*,*&gt;">
<Expand>
<Item Name="Invalid">(bool)(PtrWithInvalid &amp; 0x01)</Item>
<Item Name="Value" Condition="PtrWithInvalid > 0x01">($T1)(PtrWithInvalid &amp; ~0x01)</Item>
</Expand>
</Type>
<Type Name="clang::QualType">
<Expand>
<ExpandedItem>Value</ExpandedItem>
</Expand>
</Type>
<Type Name="clang::CanQualType">
<Expand>
<ExpandedItem>Stored</ExpandedItem>
</Expand>
</Type>
<Type Name="clang::CanQual&lt;*&gt;">
<Expand>
<ExpandedItem>Stored</ExpandedItem>
</Expand>
</Type>
<Type Name="clang::Type">
<Expand>
<Item Name="Type Class">(Type::TypeClass)TypeBits.TC</Item>
<Item Name="Dependent">(bool)TypeBits.Dependent</Item>
<Item Name="Instantiation Dependent">(bool)TypeBits.InstantiationDependent</Item>
<Item Name="Variably Modified">(bool)TypeBits.VariablyModified</Item>
<Item Name="Unexpanded Parameter Pack">(bool)TypeBits.ContainsUnexpandedParameterPack</Item>
<Item Name="Cache Valid">TypeBits.CacheValidAndVisibility != 0</Item>
<Item Name="Visibility" Condition="TypeBits.CacheValidAndVisibility != 0">(Visibility)(TypeBits.CacheValidAndVisibility-1)</Item>
<Item Name="Explicit Visibility" Condition="TypeBits.CacheValidAndVisibility != 0">(bool)TypeBits.CachedExplicitVisibility</Item>
<Item Name="Linkage" Condition="TypeBits.CacheValidAndVisibility != 0">(Linkage)TypeBits.CachedLinkage</Item>
<Item Name="Local or Unnamed Type" Condition="TypeBits.CacheValidAndVisibility != 0">TypeBits.CachedLocalOrUnnamed</Item>
<Item Name="From AST">TypeBits.FromAST</Item>
<ExpandedItem Condition="TypeBits.TC == 0">*(clang::BuiltinType*)this,nd</ExpandedItem>
<Item Name="Pointee" Condition="TypeBits.TC == 40">(*(clang::HandleType*)this).PointeeType,nd</Item>
<Item Name="Record" Condition="TypeBits.TC == 23">*(clang::RecordType*)this,nd</Item>
</Expand>
</Type>
<Type Name="clang::RecordType">
<Expand>
<Item Name="Decl">(RecordDecl*)decl</Item>
</Expand>
</Type>
<Type Name="clang::BuiltinType">
<Expand>
<!--<ExpandedItem>*(clang::Type*)this,nd</ExpandedItem>-->
<Item Name="Builtin Kind">(BuiltinType::Kind)BuiltinTypeBits.Kind</Item>
</Expand>
</Type>
<Type Name="clang::IdentifierInfo">
<DisplayString>{(clang::tok::TokenKind)TokenID}</DisplayString>
<Expand>
<Item Name="Token Kind">(clang::tok::TokenKind)TokenID</Item>
<!--<Item Name="ObjC Kind" Condition="ObjCOrBuiltinID &lt; clang::tok::NUM_OBJC_KEYWORDS">(clang::tok::ObjCKeywordKind)ObjCOrBuiltinID</Item>
<Item Name="Builtin Kind" Condition="ObjCOrBuiltinID &gt;= clang::tok::NUM_OBJC_KEYWORDS">ObjCOrBuiltinID - clang::tok::NUM_OBJC_KEYWORDS</Item>-->
</Expand>
</Type>
<Type Name="clang::DeclarationName">
<Expand>
<Item Name="Stored Name Kind">(StoredNameKind)(Ptr &amp; PtrMask)</Item>
<Item Name="Ptr" Condition="(StoredNameKind)(Ptr &amp; PtrMask) == StoredIdentifier">(IdentifierInfo*)Ptrd</Item>
</Expand>
</Type>
<Type Name="clang::Token">
<Expand>
<Item Name="Kind">(clang::tok::TokenKind)Kind</Item>
</Expand>
</Type>
<Type Name="clang::TemplateArgument">
<Expand>
<Item Name="Kind">(clang::TemplateArgument::ArgKind)Kind</Item>
</Expand>
</Type>
<Type Name="clang::TemplateArgument">
<Expand>
<Item Name="Kind">(clang::TemplateArgument::ArgKind)Kind</Item>
</Expand>
</Type>
</AutoVisualizer>
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="llvm::StringRef">
<DisplayString>{Data,s}</DisplayString>
<StringView>Data,s</StringView>
<Expand>
<Item Name="[size]">Length</Item>
<Item Name="[data]">Data,s</Item>
</Expand>
</Type>
<Type Name="llvm::SmallVector&lt;*&gt;">
<AlternativeType Name="llvm::SmallVectorImpl&lt;*&gt;" />
<AlternativeType Name="llvm::SmallVectorTemplateBase&lt;*,*&gt;" />
<AlternativeType Name="llvm::SmallVectorTemplateCommon&lt;*,*&gt;" />
<!-- <AlternativeType Name="llvm::SmallString&lt;*&gt;" /> -->
<!-- <AlternativeType Name="llvm::SmallVectorBase" /> -->
<DisplayString>{{ size={($T1*)EndX - ($T1*)BeginX}, capacity={($T1*)CapacityX - ($T1*)BeginX} }}</DisplayString>
<Expand>
<Item Name="[size]">($T1*)EndX - ($T1*)BeginX</Item>
<Item Name="[capacity]">($T1*)CapacityX - ($T1*)BeginX</Item>
<!--<Item Condition="$T2 != 0" Name="[inline-storage]">{$T2}</Item>-->
<ArrayItems>
<Size>($T1*)EndX - ($T1*)BeginX</Size>
<ValuePointer>($T1*)BeginX</ValuePointer>
</ArrayItems>
</Expand>
</Type>
<Type Name="llvm::SmallString&lt;*&gt;">
<DisplayString>{(char*)BeginX,$T1s}</DisplayString>
<Expand>
<Item Name="[size]">(char*)EndX - (char*)BeginX</Item>
<Item Name="[capacity]">(char*)CapacityX - (char*)BeginX</Item>
<Item Name="[data]">(char*)BeginX,$T1s</Item>
</Expand>
</Type>
<Type Name="llvm::PointerIntPair&lt;*,*,*,*&gt;">
<DisplayString>ptr={($T1*)&amp;Value} value={($T3)((Value >> IntShift) &amp; IntMask)}</DisplayString>
<Expand>
<Item Name="[ptr]">($T1*)&amp;Value</Item>
<Item Name="[value]">($T3)((Value >> IntShift) &amp; IntMask)</Item>
</Expand>
</Type>
<Type Name="llvm::PointerUnion&lt;*,*&gt;">
<DisplayString Condition="((Val.Value >> Val.IntShift) &amp; Val.IntMask) == 0">P1</DisplayString>
<DisplayString Condition="((Val.Value >> Val.IntShift) &amp; Val.IntMask) != 0">P2</DisplayString>
<Expand>
<ExpandedItem Condition="((Val.Value >> Val.IntShift) &amp; Val.IntMask) == 0">($T1)(Val.Value &amp; Val.PointerBitMask)</ExpandedItem>
<ExpandedItem Condition="((Val.Value >> Val.IntShift) &amp; Val.IntMask) != 0">($T2)(Val.Value &amp; Val.PointerBitMask)</ExpandedItem>
</Expand>
</Type>
<Type Name="llvm::PointerUnion4&lt;*,*,*,*&gt;">
<Expand>
<ExpandedItem>Val</ExpandedItem>
</Expand>
</Type>
<Type Name="llvm::Type">
<Expand>
<Item Name="Type ID">(TypeID)(IDAndSubclassData &amp; 0xFF)</Item>
<Item Name="[ptr]" Condition="((TypeID)(IDAndSubclassData &amp; 0xFF)) == Type::PointerTyID" >ContainedTys[0]</Item>
</Expand>
</Type>
</AutoVisualizer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment