blob: 0c5101215be5b13255f4e8ccd6bae893c91a15c5 [file] [log] [blame]
Aaron Ballman83f197b2014-01-24 19:46:45 +00001<?xml version="1.0" encoding="utf-8"?>
2<!--
Mike Spertus288daa52016-03-08 16:14:23 +00003Visual Studio Native Debugging Visualizers for LLVM
Aaron Ballman83f197b2014-01-24 19:46:45 +00004
Mike Spertus288daa52016-03-08 16:14:23 +00005Put this file into "%USERPROFILE%\Documents\Visual Studio 20xx\Visualizers"
Aaron Ballman83f197b2014-01-24 19:46:45 +00006or create a symbolic link so it updates automatically.
7-->
8<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
Mike Spertus01b14bf2016-03-16 14:27:50 +00009
Aaron Ballman9d214542015-09-29 17:32:36 +000010 <Type Name="clang::Type">
Mike Spertus01b14bf2016-03-16 14:27:50 +000011 <!-- To visualize clang::Types, we need to look at TypeBits.TC to determine the actual
12 type subclass and manually dispatch accordingly (Visual Studio can't identify the real type
13 because clang::Type has no virtual members hence no RTTI).
14
15 Views:
16 "cmn": Visualization that is common to all clang::Type subclasses
17 "poly": Visualization that is specific to the actual clang::Type subclass. The subtype-specific
18 <DisplayString> is typically as C++-like as possible (like in dump()) with <Expand>
19 containing all the gory details.
20 "cpp": Only occasionally used when we need to distinguish between an ordinary view and a C++-like view.
21 -->
22 <DisplayString IncludeView="cmn">{(clang::Type::TypeClass)TypeBits.TC, en}Type</DisplayString>
23 <!-- Dispatch to visualizers for the actual Type subclass -->
24 <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Builtin" IncludeView="poly">{*(clang::BuiltinType *)this}</DisplayString>
25 <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Pointer" IncludeView="poly">{*(clang::PointerType *)this}</DisplayString>
26 <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::LValueReference" IncludeView="poly">{*(clang::LValueReferenceType *)this}</DisplayString>
27 <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::RValueReference" IncludeView="poly">{*(clang::RValueReferenceType *)this}</DisplayString>
28 <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Attributed" IncludeView="poly">{*(clang::AttributedType *)this}</DisplayString>
29 <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::TemplateTypeParm" IncludeView="poly">{*(clang::TemplateTypeParmType *)this}</DisplayString>
30 <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::SubstTemplateTypeParm" IncludeView="poly">{*(clang::SubstTemplateTypeParmType *)this}</DisplayString>
31 <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Record" IncludeView="poly">{*(clang::RecordType *)this}</DisplayString>
Mike Spertus7f2de8e2016-03-20 00:20:43 +000032 <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::FunctionProto" IncludeView="poly">{*(clang::FunctionProtoType *)this}</DisplayString>
Mike Spertus01b14bf2016-03-16 14:27:50 +000033 <DisplayString IncludeView="cpp">{*this,view(poly)}</DisplayString>
34 <DisplayString IncludeView="poly">{*this,view(cmn)}"</DisplayString> <!-- Not yet implemented Type subclass -->
35 <DisplayString>{*this,view(cmn)} {{{*this,view(poly)}}}</DisplayString>
Mike Spertus288daa52016-03-08 16:14:23 +000036 <Expand>
Mike Spertus01b14bf2016-03-16 14:27:50 +000037 <Item Name="TypeClass" IncludeView="cmn">(clang::Type::TypeClass)TypeBits.TC</Item>
38 <Item Name="Flags" IncludeView="cmn">TypeBits</Item>
39 <Item Name="Canonical" IncludeView="cmn">CanonicalType</Item>
40 <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Builtin">*(clang::BuiltinType *)this</ExpandedItem>
41 <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Pointer">*(clang::PointerType *)this</ExpandedItem>
42 <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::LValueReference">*(clang::LValueReferenceType *)this</ExpandedItem>
43 <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::RValueReference">*(clang::RValueReferenceType *)this</ExpandedItem>
44 <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Attributed">*(clang::AttributedType *)this</ExpandedItem>
45 <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::TemplateTypeParm">(clang::TemplateTypeParmType *)this</ExpandedItem>
46 <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::SubstTemplateTypeParm">(clang::SubstTemplateTypeParmType *)this</ExpandedItem>
47 <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Record">(clang::RecordType *)this</ExpandedItem>
Mike Spertus7f2de8e2016-03-20 00:20:43 +000048 <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::FunctionProto">(clang::FunctionProtoType *)this</ExpandedItem>
Mike Spertus288daa52016-03-08 16:14:23 +000049 </Expand>
50 </Type>
Mike Spertus01b14bf2016-03-16 14:27:50 +000051 <Type Name="clang::PointerType">
52 <DisplayString>{PointeeType, view(poly)} *</DisplayString>
53 <Expand>
54 <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>
55 <Item Name="PointeeType">PointeeType</Item>
56 </Expand>
57 </Type>
58 <!-- We visualize all inner types for clang reference types. So a rvalue reference to an lvalue reference
59 to an int would visual as int &amp; &amp;&amp; This is a little different than GetPointeeType(),
60 but more clearly displays the data structure and seems natural -->
61 <Type Name="clang::LValueReferenceType">
62 <DisplayString>{((clang::ReferenceType *)this)-&gt;PointeeType,view(cpp)} &amp;</DisplayString>
63 <Expand>
64 <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>
65 <Item Name="PointeeType">PointeeType</Item>
66 </Expand>
67 </Type>
68 <Type Name="clang::RValueReferenceType">
69 <DisplayString>{((clang::ReferenceType *)this)-&gt;PointeeType,view(cpp)} &amp;&amp;</DisplayString>
70 <Expand>
71 <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>
72 <Item Name="PointeeType">PointeeType</Item>
73 </Expand>
74 </Type>
75 <Type Name="clang::AttributedType">
76 <DisplayString>{ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}</DisplayString>
77 </Type>
Mike Spertusa814d3d2016-03-18 16:38:34 +000078
79 <!-- Unfortunately, Visual Studio has trouble seeing the PointerBitMask member PointerIntUnion, so I hardwire it to 2 bits-->
80 <Type Name="clang::DeclContext">
81 <DisplayString>{(clang::Decl::Kind)DeclKind,en}Decl</DisplayString>
82 <Expand>
83 <Item Name="DeclKind">(clang::Decl::Kind)DeclKind,en</Item>
84 <LinkedListItems>
85 <HeadPointer>FirstDecl</HeadPointer>
86 <NextPointer>(clang::Decl *)(NextInContextAndBits.Value &amp; ~3)</NextPointer>
87 <ValueNode>*this</ValueNode>
88 </LinkedListItems>
89 </Expand>
90 </Type>
91 <Type Name="clang::FieldDecl">
92 <DisplayString>Field {{{*(clang::NamedDecl *)this,view(cpp)nd}}}</DisplayString>
93 </Type>
94 <Type Name="clang::CXXMethodDecl">
95 <DisplayString>Method {{{*(clang::NamedDecl *)this,view(cpp)nd}}}</DisplayString>
96 </Type>
97 <Type Name="clang::CXXConstructorDecl">
98 <DisplayString>Constructor {{{*(clang::NamedDecl *)this,view(cpp)nd}}}</DisplayString>
99 </Type>
100 <Type Name="clang::CXXDestructorDecl">
101 <DisplayString>Destructor {{{*(clang::NamedDecl *)this,view(cpp)nd}}}</DisplayString>
102 </Type>
Mike Spertus01b14bf2016-03-16 14:27:50 +0000103 <Type Name="clang::NamedDecl" >
104 <DisplayString IncludeView="cpp">{Name,view(cpp)}</DisplayString>
105 <DisplayString>{Name}</DisplayString>
106 </Type>
107 <Type Name="clang::TagDecl">
108 <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Struct">struct {Name,view(cpp)}</DisplayString>
109 <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Interface">interface {Name,view(cpp)}</DisplayString>
110 <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Union">union {Name,view(cpp)}</DisplayString>
111 <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Class">class {Name,view(cpp)}</DisplayString>
112 <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Enum">enum {Name,view(cpp)}</DisplayString>
Mike Spertusa814d3d2016-03-18 16:38:34 +0000113 <Expand>
114 <ExpandedItem>(clang::DeclContext *)this</ExpandedItem>
115 </Expand>
Mike Spertus01b14bf2016-03-16 14:27:50 +0000116 </Type>
Mike Spertus288daa52016-03-08 16:14:23 +0000117 <Type Name="clang::TagType">
118 <DisplayString>{*decl}</DisplayString>
119 <Expand>
Mike Spertus01b14bf2016-03-16 14:27:50 +0000120 <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>
Mike Spertus288daa52016-03-08 16:14:23 +0000121 <Item Name="decl">decl</Item>
122 </Expand>
123 </Type>
124 <Type Name="clang::RecordType">
Mike Spertus01b14bf2016-03-16 14:27:50 +0000125 <DisplayString>{*(clang::TagType *)this}</DisplayString>
Mike Spertus288daa52016-03-08 16:14:23 +0000126 <Expand>
127 <Item Name="TagType">*(clang::TagType *)this</Item>
128 </Expand>
129 </Type>
130 <Type Name="clang::SubstTemplateTypeParmType">
Mike Spertus01b14bf2016-03-16 14:27:50 +0000131 <DisplayString>{*Replaced,view(cpp)} &lt;= {CanonicalType,view(cpp)}</DisplayString>
Mike Spertus288daa52016-03-08 16:14:23 +0000132 <Expand>
Mike Spertus01b14bf2016-03-16 14:27:50 +0000133 <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>
Mike Spertus288daa52016-03-08 16:14:23 +0000134 <Item Name="Replaced">*Replaced</Item>
135 </Expand>
136 </Type>
Mike Spertus7f2de8e2016-03-20 00:20:43 +0000137 <!-- We only show the first 5 parameter types in the display string (can't figure out how to loop in DisplayString)
138 but the expansion has all parameters -->
139 <Type Name="clang::FunctionProtoType">
140 <DisplayString IncludeView="parm0" Condition="NumParams==0"></DisplayString>
141 <DisplayString IncludeView="parm0">{*(clang::QualType *)(this+1),view(cpp)}{*this,view(parm1)}</DisplayString>
142 <DisplayString IncludeView="parm1" Condition="NumParams==1"></DisplayString>
143 <DisplayString IncludeView="parm1">, {*((clang::QualType *)(this+1)+1),view(cpp)}{*this,view(parm2)}</DisplayString>
144 <DisplayString IncludeView="parm2" Condition="NumParams==2"></DisplayString>
145 <DisplayString IncludeView="parm2">, {*((clang::QualType *)(this+1)+2),view(cpp)}{*this,view(parm3)}</DisplayString>
146 <DisplayString IncludeView="parm3" Condition="NumParams==3"></DisplayString>
147 <DisplayString IncludeView="parm3">, {*((clang::QualType *)(this+1)+3),view(cpp)}{*this,view(parm4)}</DisplayString>
148 <DisplayString IncludeView="parm4" Condition="NumParams==4"></DisplayString>
149 <DisplayString IncludeView="parm4">, {*((clang::QualType *)(this+1)+4),view(cpp)}{*this,view(parm5)}</DisplayString>
150 <DisplayString IncludeView="parm5" Condition="NumParams==5"></DisplayString>
151 <DisplayString IncludeView="parm5">, /* expand for more params */</DisplayString>
152 <DisplayString>{ResultType,view(cpp)}({*this,view(parm0)})</DisplayString>
153 <Expand>
154 <Item Name="ReturnType">ResultType</Item>
155 <Synthetic Name="Parameter Types">
156 <DisplayString>{*this,view(parm0)}</DisplayString>
157 <Expand>
158 <ArrayItems>
159 <Size>NumParams</Size>
160 <ValuePointer>(clang::QualType *)(this+1)</ValuePointer>
161 </ArrayItems>
162 </Expand>
163 </Synthetic>
164 <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>
165 </Expand>
166 </Type>
Mike Spertus288daa52016-03-08 16:14:23 +0000167 <Type Name="clang::TemplateTypeParmType">
Mike Spertus01b14bf2016-03-16 14:27:50 +0000168 <DisplayString>typename {*TTPDecl,view(cpp)}</DisplayString>
Aaron Ballman9d214542015-09-29 17:32:36 +0000169 </Type>
170 <Type Name="clang::QualType">
Mike Spertus288daa52016-03-08 16:14:23 +0000171 <!-- TODO: Qualifiers. Also, when VS2013 support is deprecated, change 4 to clang::TypeAlignmentInBits (not properly recognized by VS2013) -->
Mike Spertus01b14bf2016-03-16 14:27:50 +0000172 <DisplayString IncludeView="poly">{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType,view(poly)}</DisplayString>
173 <DisplayString IncludeView="cpp">{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType,view(cpp)}</DisplayString>
Mike Spertus288daa52016-03-08 16:14:23 +0000174 <DisplayString>{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType}</DisplayString>
175 <Expand>
176 <Item Name="BaseType">*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType</Item>
177 </Expand>
178 </Type>
179 <Type Name="clang::TemplateArgumentLoc">
180 <DisplayString>{Argument}</DisplayString>
181 <Expand>
182 <ExpandedItem>Argument</ExpandedItem>
183 </Expand>
184 </Type>
185 <Type Name="clang::TemplateArgument">
186 <DisplayString>{(clang::TemplateArgument::ArgKind)TypeOrValue.Kind,en} template parameter: {*(clang::QualType *)&amp;TypeOrValue.V}</DisplayString>
187 <Expand>
188 <Item Name="QualType" Condition="Integer.Kind == clang::TemplateArgument::ArgKind::Type">*(clang::QualType *)&amp;TypeOrValue.V</Item>
189 <!-- TODO: Other kinds-->
190 </Expand>
191 </Type>
192 <Type Name="clang::BuiltinType">
193 <DisplayString>{(clang::BuiltinType::Kind)BuiltinTypeBits.Kind, en}</DisplayString>
194 <Expand>
195 <Item Name="Kind">(clang::BuiltinType::Kind)BuiltinTypeBits.Kind</Item>
196 </Expand>
197 </Type>
Mike Spertus01b14bf2016-03-16 14:27:50 +0000198
Mike Spertus288daa52016-03-08 16:14:23 +0000199 <Type Name="clang::TemplateSpecializationType">
200 <DisplayString Condition="(Template.Storage.Val.Val.Value &amp; 3) != 3 &amp;&amp; (Template.Storage.Val.Val.Value &amp; 2) != 2 &amp;&amp; (Template.Storage.Val.Val.Value &amp; 1) != 1">{(clang::TemplateDecl *)((Template.Storage.Val.Val.Value &gt;&gt; 2) &lt;&lt; 2)}</DisplayString>
201 <DisplayString>{Template.Storage}</DisplayString>
Aaron Ballman9d214542015-09-29 17:32:36 +0000202 </Type>
Aaron Ballman83f197b2014-01-24 19:46:45 +0000203 <Type Name="clang::IdentifierInfo">
Mike Spertus01b14bf2016-03-16 14:27:50 +0000204 <DisplayString Condition="Entry != 0">{((llvm::StringMapEntry&lt;clang::IdentifierInfo *&gt;*)Entry)+1,sb}</DisplayString>
Aaron Ballman83f197b2014-01-24 19:46:45 +0000205 <Expand>
206 <Item Condition="Entry != 0" Name="[Identifier]">((llvm::StringMapEntry&lt;clang::IdentifierInfo *&gt;*)Entry)+1,s</Item>
207 <Item Name="Token Kind">(clang::tok::TokenKind)TokenID</Item>
208 </Expand>
209 </Type>
210 <Type Name="clang::DeclarationName">
211 <DisplayString Condition="Ptr == 0">Empty</DisplayString>
Mike Spertus01b14bf2016-03-16 14:27:50 +0000212 <DisplayString Condition="(Ptr &amp; PtrMask) == StoredIdentifier" IncludeView="cpp">{*(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)}</DisplayString>
Zachary Turnerdfa871b2014-06-26 16:26:42 +0000213 <DisplayString Condition="(Ptr &amp; PtrMask) == StoredIdentifier">{{Identifier ({*(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)})}}</DisplayString>
214 <DisplayString Condition="(Ptr &amp; PtrMask) == StoredObjCZeroArgSelector">{{ObjC Zero Arg Selector (*{(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)})}}</DisplayString>
215 <DisplayString Condition="(Ptr &amp; PtrMask) == StoredObjCOneArgSelector">{{ObjC One Arg Selector (*{(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)})}}</DisplayString>
Aaron Ballman83f197b2014-01-24 19:46:45 +0000216 <DisplayString Condition="(Ptr &amp; PtrMask) == StoredDeclarationNameExtra">{{Extra ({(clang::DeclarationNameExtra::ExtraKind)((clang::DeclarationNameExtra *)(Ptr &amp; ~PtrMask))-&gt;ExtraKindOrNumArgs})}}</DisplayString>
217 <Expand>
Zachary Turnerdfa871b2014-06-26 16:26:42 +0000218 <Item Condition="(Ptr &amp; PtrMask) == StoredIdentifier" Name="[Identifier]">*(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)</Item>
219 <Item Condition="(Ptr &amp; PtrMask) == StoredObjCZeroArgSelector" Name="[ObjC Zero Arg Selector]">*(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)</Item>
220 <Item Condition="(Ptr &amp; PtrMask) == StoredObjCOneArgSelector" Name="[ObjC One Arg Selector]">*(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)</Item>
Aaron Ballman83f197b2014-01-24 19:46:45 +0000221 <Item Condition="(Ptr &amp; PtrMask) == StoredDeclarationNameExtra" Name="[Extra]">(clang::DeclarationNameExtra::ExtraKind)((clang::DeclarationNameExtra *)(Ptr &amp; ~PtrMask))-&gt;ExtraKindOrNumArgs</Item>
Mike Spertus288daa52016-03-08 16:14:23 +0000222 </Expand>
223 </Type>
224 <Type Name="clang::Token">
225 <DisplayString Condition="Kind != clang::tok::identifier">{(clang::tok::TokenKind)Kind,en}</DisplayString>
226 <DisplayString Condition="Kind == clang::tok::identifier">{{Identifier ({*(clang::IdentifierInfo *)(PtrData)})}}</DisplayString>
227 </Type>
228 <Type Name="clang::DeclSpec">
229 <DisplayString>[{(clang::DeclSpec::SCS)StorageClassSpec}], [{(clang::TypeSpecifierType)TypeSpecType}]</DisplayString>
Aaron Ballman83f197b2014-01-24 19:46:45 +0000230 </Type>
231 <Type Name="clang::PragmaHandler">
232 <DisplayString>{Name,s}</DisplayString>
233 </Type>
234 <Type Name="clang::FileEntry">
235 <DisplayString>{Name,s}</DisplayString>
236 </Type>
237 <Type Name="clang::DirectoryEntry">
238 <DisplayString>{Name,s}</DisplayString>
239 </Type>
Zachary Turnerdfa871b2014-06-26 16:26:42 +0000240 <Type Name="clang::VarDecl::VarDeclBitfields">
241 <Expand>
242 <Item Name="StorageClass">(clang::StorageClass)SClass</Item>
243 <Item Name="ThreadStorageClass">(clang::ThreadStorageClassSpecifier)TSCSpec</Item>
244 <Item Name="InitStyle">(clang::VarDecl::InitializationStyle)InitStyle</Item>
245 </Expand>
246 </Type>
247 <Type Name="clang::VarDecl">
248 <DisplayString>{Name}</DisplayString>
249 <Expand>
250 <ExpandedItem>*(DeclaratorDecl*)this,nd</ExpandedItem>
251 <Item Name="VarDeclBits">VarDeclBits</Item>
252 <Item Name="ParmVarDeclBits">ParmVarDeclBits</Item>
253 </Expand>
254 </Type>
Mike Spertus288daa52016-03-08 16:14:23 +0000255 <Type Name="clang::OpaquePtr&lt;*&gt;">
256 <DisplayString>{($T1 *)Ptr</DisplayString>
257 <Expand>
258 <ExpandedItem>($T1 *)Ptr</ExpandedItem>
259 </Expand>
260 </Type>
Aaron Ballman83f197b2014-01-24 19:46:45 +0000261</AutoVisualizer>