1<?xml version="1.0" encoding="utf-8"?>
2<!--
3Visual Studio Native Debugging Visualizers for LLVM
4
5For Visual Studio 2013 only, put this file into
6"%USERPROFILE%\Documents\Visual Studio 2013\Visualizers" or create a symbolic link so it updates automatically.
7
8For later versions of Visual Studio, no setup is required.
9-->
10<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
11  <Type Name="llvm::SmallVectorImpl&lt;*&gt;">
12    <DisplayString IncludeView ="elt0" Condition="Size == 0"></DisplayString>
13    <DisplayString IncludeView ="elt0">{(($T1*)BeginX)[0]}{*this,view(elt1)}</DisplayString>
14    <DisplayString IncludeView ="elt1" Condition="Size == 1"></DisplayString>
15    <DisplayString IncludeView ="elt1">, {(($T1*)BeginX)[1]}{*this,view(elt2)}</DisplayString>
16    <DisplayString IncludeView ="elt2" Condition="Size == 2"></DisplayString>
17    <DisplayString IncludeView ="elt2">, {(($T1*)BeginX)[2]}{*this,view(elt3)}</DisplayString>
18    <DisplayString IncludeView ="elt3" Condition="Size == 3"></DisplayString>
19    <DisplayString IncludeView ="elt3">, {(($T1*)BeginX)[3]}{*this,view(elt4)}</DisplayString>
20    <DisplayString IncludeView ="elt4" Condition="Size == 4"></DisplayString>
21    <DisplayString IncludeView ="elt4">, /* {Size - 4} more*/ </DisplayString>
22    <DisplayString Condition="Size == 0">empty</DisplayString>
23    <DisplayString Condition="Size != 0">{{{*this,view(elt0)}}}</DisplayString>
24    <DisplayString>Uninitialized</DisplayString>
25    <Expand>
26      <Item Name="[size]">Size</Item>
27      <Item Name="[capacity]">Capacity</Item>
28      <ArrayItems>
29        <Size>Size</Size>
30        <ValuePointer>($T1*)BeginX</ValuePointer>
31      </ArrayItems>
32    </Expand>
33  </Type>
34  <Type Name="llvm::APInt">
35    <!-- For now, only handle up to 64-bit unsigned ints -->
36    <DisplayString Condition="BitWidth &lt;= 64">{U.VAL}</DisplayString>
37    <DisplayString>Cannot visualize APInts longer than 64 bits</DisplayString>
38  </Type>
39  <Type Name="llvm::ArrayRef&lt;*&gt;">
40    <DisplayString Condition="Length == 0">empty</DisplayString>
41    <DisplayString Condition="Length != 0">{{ size={Length} }}</DisplayString>
42    <Expand>
43      <Item Name="[size]">Length</Item>
44      <ArrayItems>
45        <Size>Length</Size>
46        <ValuePointer>Data</ValuePointer>
47      </ArrayItems>
48    </Expand>
49  </Type>
50  <Type Name="llvm::SmallString&lt;*&gt;">
51    <DisplayString>{(const char*)BeginX,[Size] na}</DisplayString>
52    <StringView>(const char*)BeginX,[Size]</StringView>
53    <Expand>
54      <Item Name="[size]">Size</Item>
55      <Item Name="[capacity]">Capacity</Item>
56      <ArrayItems>
57        <Size>Size</Size>
58        <ValuePointer>(char*)BeginX</ValuePointer>
59      </ArrayItems>
60    </Expand>
61  </Type>
62
63  <Type Name="StringView">
64    <DisplayString>{First,[Last - First]s}</DisplayString>
65  </Type>
66
67  <Type Name="llvm::StringRef">
68    <DisplayString>{Data,[Length]s}</DisplayString>
69    <StringView>Data,[Length]s</StringView>
70    <Expand>
71      <Item Name="[size]">Length</Item>
72      <ArrayItems>
73        <Size>Length</Size>
74        <ValuePointer>Data</ValuePointer>
75      </ArrayItems>
76    </Expand>
77  </Type>
78
79  <!-- PointerIntPair. In addition to the regular view, it is possible to view just the pointer or just the int
80    The same code is duplicated from the regular viewer to improve the performance of the common case -->
81  <Type Name="llvm::PointerIntPair&lt;*&gt;">
82    <DisplayString IncludeView="ptr">{($T1)(Value &amp; $T5::PointerBitMask)}</DisplayString>
83    <DisplayString IncludeView="int">{($T3)((Value &gt;&gt; $T5::IntShift) &amp; $T5::IntMask)}</DisplayString>
84    <DisplayString>{$T5::IntMask}: {($T1)(Value &amp; $T5::PointerBitMask)} [{($T3)((Value &gt;&gt; $T5::IntShift) &amp; $T5::IntMask)}]</DisplayString>
85    <Expand>
86      <Item Name="[ptr]">($T1)(Value &amp; $T5::PointerBitMask)</Item>
87      <Item Name="[int]">($T3)((Value &gt;&gt; $T5::IntShift) &amp; $T5::IntMask)</Item>
88    </Expand>
89  </Type>
90  <!-- PointerUnion types -->
91  <Type Name="llvm::pointer_union_detail::PointerUnionMembers&lt;*&gt;">
92    <DisplayString Optional="true" Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 0">
93      {($T4)(Val.Value &amp; $T2::InfoTy::PointerBitMask)}
94    </DisplayString>
95    <DisplayString Optional="true" Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 1">
96      {($T5)(Val.Value &amp; $T2::InfoTy::PointerBitMask)}
97    </DisplayString>
98    <DisplayString Optional="true" Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 2">
99      {($T6)(Val.Value &amp; $T2::InfoTy::PointerBitMask)}
100    </DisplayString>
101    <DisplayString Optional="true" Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 3">
102      {($T7)(Val.Value &amp; $T2::InfoTy::PointerBitMask)}
103    </DisplayString>
104    <DisplayString>Unexpected index in PointerUnion: {(Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask}</DisplayString>
105    <Expand>
106      <Item Name="[Holds]" Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 0">"$T4",s8b</Item>
107      <Item Name="[Ptr]" Optional="true"  Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 0">
108        ($T4)(Val.Value &amp; $T2::InfoTy::PointerBitMask)
109      </Item>
110      <Item Name="[Holds]" Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 1">"$T5",s8b</Item>
111      <Item Name="[Ptr]" Optional="true"  Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 1">
112        ($T5)(Val.Value &amp; $T2::InfoTy::PointerBitMask)
113      </Item>
114      <Item Name="[Holds]" Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 2">"$T6",s8b</Item>
115      <Item Name="[Ptr]" Optional="true"  Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 2">
116        ($T6)(Val.Value &amp; $T2::InfoTy::PointerBitMask)
117      </Item>
118      <Item Name="[Holds]" Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 3">"$T6",s8b</Item>
119      <Item Name="[Ptr]" Optional="true"  Condition="((Val.Value&gt;&gt;$T2::InfoTy::IntShift) &amp; $T2::InfoTy::IntMask) == 3">
120        ($T7)(Val.Value &amp; $T2::InfoTy::PointerBitMask)
121      </Item>
122    </Expand>
123  </Type>
124
125  <Type Name="llvm::iplist&lt;*,*&gt;">
126    <DisplayString Condition="Head == 0">{{ empty }}</DisplayString>
127    <DisplayString Condition="Head != 0">{{ head={Head} }}</DisplayString>
128    <Expand>
129      <LinkedListItems>
130        <HeadPointer>Head</HeadPointer>
131        <NextPointer>Next</NextPointer>
132        <ValueNode>this</ValueNode>
133      </LinkedListItems>
134    </Expand>
135  </Type>
136
137  <Type Name="llvm::IntrusiveRefCntPtr&lt;*&gt;">
138    <DisplayString Condition="Obj == 0">empty</DisplayString>
139    <DisplayString Condition="(Obj != 0) &amp;&amp; (Obj-&gt;RefCount == 1)">RefPtr [1 ref] {*Obj}</DisplayString>
140    <DisplayString Condition="(Obj != 0) &amp;&amp; (Obj-&gt;RefCount != 1)">RefPtr [{Obj-&gt;RefCount} refs] {*Obj}</DisplayString>
141    <Expand>
142      <Item Condition="Obj != 0" Name="[refs]">Obj-&gt;RefCount</Item>
143      <ExpandedItem Condition="Obj != 0">Obj</ExpandedItem>
144    </Expand>
145  </Type>
146
147  <Type Name="llvm::SmallPtrSet&lt;*,*&gt;">
148    <DisplayString Condition="CurArray == SmallArray">{{ [Small Mode] size={NumNonEmpty}, capacity={CurArraySize} }}</DisplayString>
149    <DisplayString Condition="CurArray != SmallArray">{{ [Big Mode] size={NumNonEmpty}, capacity={CurArraySize} }}</DisplayString>
150    <Expand>
151      <Item Name="[size]">NumNonEmpty</Item>
152      <Item Name="[capacity]">CurArraySize</Item>
153      <ArrayItems>
154        <Size>NumNonEmpty</Size>
155        <ValuePointer>($T1*)CurArray</ValuePointer>
156      </ArrayItems>
157    </Expand>
158  </Type>
159
160  <Type Name="llvm::DenseMap&lt;*,*,*&gt;">
161    <DisplayString Condition="NumEntries == 0">empty</DisplayString>
162    <DisplayString Condition="NumEntries != 0">{{ size={NumEntries}, buckets={NumBuckets} }}</DisplayString>
163    <Expand>
164      <Item Name="[size]">NumEntries</Item>
165      <Item Name="[buckets]">NumBuckets</Item>
166      <ArrayItems>
167        <Size>NumBuckets</Size>
168        <ValuePointer>Buckets</ValuePointer>
169      </ArrayItems>
170    </Expand>
171  </Type>
172
173  <Type Name="llvm::StringMap&lt;*,*&gt;">
174    <DisplayString>{{ size={NumItems}, buckets={NumBuckets} }}</DisplayString>
175    <Expand>
176      <Item Name="[size]">NumItems</Item>
177      <Item Name="[buckets]">NumBuckets</Item>
178      <ArrayItems>
179        <Size>NumBuckets</Size>
180        <ValuePointer>(MapEntryTy**)TheTable</ValuePointer>
181      </ArrayItems>
182    </Expand>
183  </Type>
184
185  <Type Name="llvm::StringMapEntry&lt;*&gt;">
186    <DisplayString Condition="StrLen == 0">empty</DisplayString>
187    <DisplayString Condition="StrLen != 0">({this+1,s}, {second})</DisplayString>
188    <Expand>
189      <Item Name="[key]">this+1,s</Item>
190      <Item Name="[value]" Condition="StrLen != 0">second</Item>
191    </Expand>
192  </Type>
193
194  <Type Name="llvm::Triple">
195    <DisplayString>{Data}</DisplayString>
196  </Type>
197
198  <Type Name="llvm::Optional&lt;*&gt;">
199    <DisplayString Condition="!Storage.hasVal">None</DisplayString>
200    <DisplayString Condition="Storage.hasVal">{*(($T1 *)(unsigned char *)Storage.storage.buffer)}</DisplayString>
201    <Expand>
202      <Item Name="[underlying]" Condition="Storage.hasVal">*(($T1 *)(unsigned char *)Storage.storage.buffer)</Item>
203    </Expand>
204  </Type>
205
206  <Type Name="llvm::Expected&lt;*&gt;">
207    <DisplayString Condition="HasError">Error</DisplayString>
208    <DisplayString Condition="!HasError">{*((storage_type *)TStorage.buffer)}</DisplayString>
209    <Expand>
210      <Item Name="[value]" Condition="!HasError">*((storage_type *)TStorage.buffer)</Item>
211      <Item Name="[error]" Condition="HasError">*((error_type *)ErrorStorage.buffer)</Item>
212    </Expand>
213  </Type>
214
215
216  <!-- Since we're in MSVC, we can assume that the system is little endian.  Therefore
217       the little and native cases just require a cast.  Handle this easy case first. Use
218       a wildcard for the second template argument (the endianness), but we will use a
219       specific value of 0 later on for the big endian to give it priority for being a
220       better match.  -->
221  <Type Name="llvm::support::detail::packed_endian_specific_integral&lt;*,*,1&gt;">
222    <DisplayString>{{little endian value = {*(($T1*)(unsigned char *)Value.buffer)} }}</DisplayString>
223    <Expand>
224      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==1">(unsigned char *)Value.buffer,1</Item>
225      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==2">(unsigned char *)Value.buffer,2</Item>
226      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==4">(unsigned char *)Value.buffer,4</Item>
227      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==8">(unsigned char *)Value.buffer,8</Item>
228    </Expand>
229  </Type>
230
231  <!-- Now handle the hard case of big endian.  We need to do the swizzling here, but
232       we need to specialize it based on the size of the value type. -->
233  <Type Name="llvm::support::detail::packed_endian_specific_integral&lt;*,0,1&gt;">
234    <DisplayString Condition="sizeof($T1)==1">{{ big endian value = {*(unsigned char *)Value.buffer} }}</DisplayString>
235    <DisplayString Condition="sizeof($T1)==2">{{ big endian value = {(($T1)(*(unsigned char *)Value.buffer) &lt;&lt; 8)
236                                                                    | ($T1)(*((unsigned char *)Value.buffer+1))} }}</DisplayString>
237    <DisplayString Condition="sizeof($T1)==4">{{ big endian value = {(($T1)(*(unsigned char *)Value.buffer) &lt;&lt; 24)
238                                                                    | (($T1)(*((unsigned char *)Value.buffer+1)) &lt;&lt; 16)
239                                                                    | (($T1)(*((unsigned char *)Value.buffer+2)) &lt;&lt; 8)
240                                                                    |  ($T1)(*((unsigned char *)Value.buffer+3))} }}</DisplayString>
241    <DisplayString Condition="sizeof($T1)==8">{{ big endian value = {(($T1)(*(unsigned char *)Value.buffer) &lt;&lt; 56)
242                                                                    | (($T1)(*((unsigned char *)Value.buffer+1)) &lt;&lt; 48)
243                                                                    | (($T1)(*((unsigned char *)Value.buffer+2)) &lt;&lt; 40)
244                                                                    | (($T1)(*((unsigned char *)Value.buffer+3)) &lt;&lt; 32)
245                                                                    | (($T1)(*((unsigned char *)Value.buffer+4)) &lt;&lt; 24)
246                                                                    | (($T1)(*((unsigned char *)Value.buffer+5)) &lt;&lt; 16)
247                                                                    | (($T1)(*((unsigned char *)Value.buffer+6)) &lt;&lt; 8)
248                                                                    |  ($T1)(*((unsigned char *)Value.buffer+7))} }}</DisplayString>
249    <Expand>
250      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==1">(unsigned char *)Value.buffer,1</Item>
251      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==2">(unsigned char *)Value.buffer,2</Item>
252      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==4">(unsigned char *)Value.buffer,4</Item>
253      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==8">(unsigned char *)Value.buffer,8</Item>
254    </Expand>
255  </Type>
256  <!-- llvm::Type has two fields, SubclassData and ContainedTys, the meaning of which change depending on the TypeID.
257       This visualiser decodes those fields based on the value of ID.
258  -->
259  <Type Name="llvm::Type">
260    <DisplayString>{ID}</DisplayString>
261    <Expand>
262      <Item Name="ID">ID</Item>
263
264      <Item Name="NumBits" Condition="ID == llvm::Type::TypeID::IntegerTyID">SubclassData</Item>
265
266      <Item Name="ReturnType" Condition="ID == llvm::Type::TypeID::FunctionTyID">*ContainedTys</Item>
267      <Synthetic Name="Arguments" Condition="ID == llvm::Type::TypeID::FunctionTyID">
268        <DisplayString>{NumContainedTys - 1}</DisplayString>
269        <Expand>
270        <ArrayItems>
271          <Size>NumContainedTys - 1</Size>
272          <ValuePointer>ContainedTys + 1</ValuePointer>
273        </ArrayItems>
274        </Expand>
275      </Synthetic>
276      <Item Name="IsVarArg" Condition="ID == llvm::Type::TypeID::FunctionTyID">SubclassData == 1</Item>
277
278      <Item Name="HasBody" Condition="ID == llvm::Type::TypeID::StructTyID">(SubclassData 	&amp; llvm::StructType::SCDB_HasBody) != 0</Item>
279      <Item Name="Packed" Condition="ID == llvm::Type::TypeID::StructTyID">(SubclassData 	&amp; llvm::StructType::SCDB_Packed) != 0</Item>
280      <Item Name="IsLiteral" Condition="ID == llvm::Type::TypeID::StructTyID">(SubclassData 	&amp; llvm::StructType::SCDB_IsLiteral) != 0</Item>
281      <Item Name="IsSized" Condition="ID == llvm::Type::TypeID::StructTyID">(SubclassData 	&amp; llvm::StructType::SCDB_IsSized) != 0</Item>
282      <Synthetic Name="Members" Condition="ID == llvm::Type::TypeID::StructTyID">
283        <DisplayString>{NumContainedTys}</DisplayString>
284        <Expand>
285          <ArrayItems>
286            <Size>NumContainedTys</Size>
287            <ValuePointer>ContainedTys</ValuePointer>
288          </ArrayItems>
289        </Expand>
290      </Synthetic>
291
292      <Item Name="ElementType" Condition="ID == llvm::Type::TypeID::ArrayTyID || ID == llvm::Type::TypeID::VectorTyID">*ContainedTys</Item>
293      <Item Name="NumElements" Condition="ID == llvm::Type::TypeID::ArrayTyID">((llvm::ArrayType*)this)->NumElements</Item>
294
295      <Item Name="AddressSpace" Condition="ID == llvm::Type::TypeID::PointerTyID">SubclassData</Item>
296      <Item Name="PointeeType" Condition="ID == llvm::Type::TypeID::PointerTyID">*ContainedTys</Item>
297
298      <Item Name="NumElements" Condition="ID == llvm::Type::TypeID::VectorTyID">((llvm::VectorType*)this)->NumElements</Item>
299
300      <Item Name="Context">Context</Item>
301    </Expand>
302  </Type>
303</AutoVisualizer>
304