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  <!-- VS2013 -->
12  <Type Name="llvm::SmallVectorImpl&lt;*&gt;" Priority="MediumLow">
13    <DisplayString Condition="Size == 0">empty</DisplayString>
14    <DisplayString Condition="Size != 0">{{ size={Size} }}</DisplayString>
15    <Expand>
16      <Item Name="[size]">Size</Item>
17      <Item Name="[capacity]">Capacity</Item>
18      <ArrayItems>
19        <Size>Size</Size>
20        <ValuePointer>($T1*)BeginX</ValuePointer>
21      </ArrayItems>
22    </Expand>
23  </Type>
24  <!-- VS2015 and up -->
25  <Type Name="llvm::SmallVectorImpl&lt;*&gt;">
26    <DisplayString IncludeView ="elt0" Condition="Size == 0"></DisplayString>
27    <DisplayString IncludeView ="elt0">{(($T1*)BeginX)[0]}{*this,view(elt1)}</DisplayString>
28    <DisplayString IncludeView ="elt1" Condition="Size == 1"></DisplayString>
29    <DisplayString IncludeView ="elt1">, {(($T1*)BeginX)[1]}{*this,view(elt2)}</DisplayString>
30    <DisplayString IncludeView ="elt2" Condition="Size == 2"></DisplayString>
31    <DisplayString IncludeView ="elt2">, {(($T1*)BeginX)[2]}{*this,view(elt3)}</DisplayString>
32    <DisplayString IncludeView ="elt3" Condition="Size == 3"></DisplayString>
33    <DisplayString IncludeView ="elt3">, {(($T1*)BeginX)[3]}{*this,view(elt4)}</DisplayString>
34    <DisplayString IncludeView ="elt4" Condition="Size == 4"></DisplayString>
35    <DisplayString IncludeView ="elt4">, /* {Size - 4} more*/ </DisplayString>
36    <DisplayString Condition="Size == 0">empty</DisplayString>
37    <DisplayString Condition="Size != 0">{{{*this,view(elt0)}}}</DisplayString>
38    <DisplayString>Uninitialized</DisplayString>
39    <Expand>
40      <Item Name="[size]">Size</Item>
41      <Item Name="[capacity]">Capacity</Item>
42      <ArrayItems>
43        <Size>Size</Size>
44        <ValuePointer>($T1*)BeginX</ValuePointer>
45      </ArrayItems>
46    </Expand>
47  </Type>
48  <Type Name="llvm::ArrayRef&lt;*&gt;">
49    <DisplayString Condition="Length == 0">empty</DisplayString>
50    <DisplayString Condition="Length != 0">{{ size={Length} }}</DisplayString>
51    <Expand>
52      <Item Name="[size]">Length</Item>
53      <ArrayItems>
54        <Size>Length</Size>
55        <ValuePointer>Data</ValuePointer>
56      </ArrayItems>
57    </Expand>
58  </Type>
59  <Type Name="llvm::SmallString&lt;*&gt;">
60    <DisplayString>{(const char*)BeginX,[Size] na}</DisplayString>
61    <StringView>(const char*)BeginX,[Size]</StringView>
62    <Expand>
63      <Item Name="[size]">Size</Item>
64      <Item Name="[capacity]">Capacity</Item>
65      <ArrayItems>
66        <Size>Size</Size>
67        <ValuePointer>(char*)BeginX</ValuePointer>
68      </ArrayItems>
69    </Expand>
70  </Type>
71
72  <Type Name="StringView">
73    <DisplayString>{First,[Last - First]s}</DisplayString>
74  </Type>
75
76  <Type Name="llvm::StringRef">
77    <DisplayString>{Data,[Length]s}</DisplayString>
78    <StringView>Data,[Length]s</StringView>
79    <Expand>
80      <Item Name="[size]">Length</Item>
81      <ArrayItems>
82        <Size>Length</Size>
83        <ValuePointer>Data</ValuePointer>
84      </ArrayItems>
85    </Expand>
86  </Type>
87
88  <Type Name="llvm::PointerIntPair&lt;*,*,*,*&gt;">
89    <DisplayString>{$T5::IntMask}: {($T1)(Value &amp; $T5::PointerBitMask)} [{($T3)((Value &gt;&gt; $T5::IntShift) &amp; $T5::IntMask)}]</DisplayString>
90    <Expand>
91      <Item Name="[ptr]">($T1)(Value &amp; $T5::PointerBitMask)</Item>
92      <Item Name="[int]">($T3)((Value &gt;&gt; $T5::IntShift) &amp; $T5::IntMask)</Item>
93    </Expand>
94  </Type>
95
96  <!-- PointerUnion types - In addition to the regular view, which displays the pointer, there is a "deref" view that
97       displays the pointed to object, which is often needed by other visualizers -->
98  <Type Name="llvm::PointerUnion&lt;*,*&gt;">
99    <DisplayString  Optional="true" IncludeView="deref" Condition="((Val.Value &gt;&gt; ValTy::InfoTy::IntShift) &amp; ValTy::InfoTy::IntMask) == 0">{*($T1)(Val.Value &amp; ValTy::InfoTy::PointerBitMask)}</DisplayString>
100    <DisplayString  Optional="true" IncludeView="deref" Condition="((Val.Value &gt;&gt; ValTy::InfoTy::IntShift) &amp; ValTy::InfoTy::IntMask) != 0">{*($T2)(Val.Value &amp; ValTy::InfoTy::PointerBitMask)}</DisplayString>
101    <DisplayString  Optional="true" Condition="((Val.Value &gt;&gt; ValTy::InfoTy::IntShift) &amp; ValTy::InfoTy::IntMask) == 0">{"$T1", s8b}: {($T1)(Val.Value &amp; ValTy::InfoTy::PointerBitMask)}</DisplayString>
102    <DisplayString  Optional="true" Condition="((Val.Value &gt;&gt; ValTy::InfoTy::IntShift) &amp; ValTy::InfoTy::IntMask) != 0">{"$T2", s8b}: {($T2)(Val.Value &amp; ValTy::InfoTy::PointerBitMask)}</DisplayString>
103    <Expand>
104      <Item Name="[Holds]" Condition="((Val.Value &gt;&gt; ValTy::InfoTy::IntShift) &amp; ValTy::InfoTy::IntMask) == 0">"$T1", s8b</Item>
105      <Item Name="[Ptr]" Optional="true"  Condition="((Val.Value &gt;&gt; ValTy::InfoTy::IntShift) &amp; ValTy::InfoTy::IntMask) == 0">($T1)(Val.Value &amp; ValTy::InfoTy::PointerBitMask)</Item>
106      <Item Name="[Holds]" Condition="((Val.Value &gt;&gt; ValTy::InfoTy::IntShift) &amp; ValTy::InfoTy::IntMask) != 0">"$T2", s8b</Item>
107      <Item Name="[Ptr]" Optional="true" Condition="((Val.Value &gt;&gt; ValTy::InfoTy::IntShift) &amp; ValTy::InfoTy::IntMask) != 0">($T2)(Val.Value &amp; ValTy::InfoTy::PointerBitMask)</Item>
108    </Expand>
109  </Type>
110
111  <Type Name="llvm::PointerUnion3&lt;*,*,*&gt;">
112    <DisplayString Optional="true" IncludeView="deref" Condition="(Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1">{Val,view(deref)}</DisplayString>
113    <DisplayString Optional="true" IncludeView="deref">{*(InnerUnion*)&amp;Val.Val.Value,view(deref)}</DisplayString>
114    <DisplayString Condition="(Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1">{Val}</DisplayString>
115    <DisplayString>{*(InnerUnion*)&amp;Val.Val.Value}</DisplayString>
116    <Expand>
117      <Item Name="[Holds]" Condition="(Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1">"$T3", s8b</Item>
118      <Item Name="[Ptr]" Condition="(Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1">($T3)(Val.Val.Value &amp; ValTy::ValTy::InfoTy::PointerBitMask)</Item>
119      <ExpandedItem Condition="!((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1)">*(InnerUnion*)&amp;Val.Val.Value</ExpandedItem>
120    </Expand>
121  </Type>
122
123  <Type Name="llvm::PointerUnion4&lt;*,*,*,*&gt;">
124    <DisplayString Optional="true" IncludeView="deref"
125                   Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 0 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion1::ValTy::InfoTy::IntShift) &amp; 1) == 0">
126      {*($T1)(Val.Val.Value &amp; InnerUnion1::ValTy::InfoTy::PointerBitMask)}
127    </DisplayString>
128    <DisplayString Optional="true" IncludeView="deref"
129                   Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 0 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion1::ValTy::InfoTy::IntShift) &amp; 1) == 1">
130      {*($T2)(Val.Val.Value &amp; InnerUnion1::ValTy::InfoTy::PointerBitMask)}
131    </DisplayString>
132    <DisplayString  Optional="true" IncludeView="deref"
133                    Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 1 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion2::ValTy::InfoTy::IntShift) &amp; 1) == 0">
134      {*($T3)(Val.Val.Value &amp; InnerUnion2::ValTy::InfoTy::PointerBitMask)}
135    </DisplayString>
136    <DisplayString  Optional="true" IncludeView="deref"
137                    Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 1 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion2::ValTy::InfoTy::IntShift) &amp; 1) == 1">
138      {*($T4)(Val.Val.Value &amp; InnerUnion2::ValTy::InfoTy::PointerBitMask)}
139    </DisplayString>
140    <DisplayString Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 0 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion1::ValTy::InfoTy::IntShift) &amp; 1) == 0">
141      {"$T1", s8b}: {($T1)(Val.Val.Value &amp; InnerUnion1::ValTy::InfoTy::PointerBitMask)}
142    </DisplayString>
143    <DisplayString Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 0 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion1::ValTy::InfoTy::IntShift) &amp; 1) == 1">
144      {"$T2", s8b}: {($T2)(Val.Val.Value &amp; InnerUnion1::ValTy::InfoTy::PointerBitMask)}
145    </DisplayString>
146    <DisplayString Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 1 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion2::ValTy::InfoTy::IntShift) &amp; 1) == 0">
147      {"$T3", s8b}: {($T3)(Val.Val.Value &amp; InnerUnion2::ValTy::InfoTy::PointerBitMask)}
148    </DisplayString>
149    <DisplayString Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 1 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion2::ValTy::InfoTy::IntShift) &amp; 1) == 1">
150      {"$T4", s8b}: {($T4)(Val.Val.Value &amp; InnerUnion2::ValTy::InfoTy::PointerBitMask)}
151    </DisplayString>
152    <Expand>
153      <Item Name="[Holds]" Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 0 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion1::ValTy::InfoTy::IntShift) &amp; 1) == 0">
154        "$T1", s8b
155      </Item>
156      <Item Name="[Ptr]" Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 0 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion1::ValTy::InfoTy::IntShift) &amp; 1) == 0">
157        ($T1)(Val.Val.Value &amp; InnerUnion1::ValTy::InfoTy::PointerBitMask)
158      </Item>
159      <Item Name="[Holds]" Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 0 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion1::ValTy::InfoTy::IntShift) &amp; 1) == 1">
160        "$T2", s8b
161      </Item>
162      <Item Name="[Ptr]" Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 0 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion1::ValTy::InfoTy::IntShift) &amp; 1) == 1">
163        ($T2)(Val.Val.Value &amp; InnerUnion1::ValTy::InfoTy::PointerBitMask)
164      </Item>
165      <Item Name="[Holds]" Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 1 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion2::ValTy::InfoTy::IntShift) &amp; 1) == 0">
166        "$T3", s8b
167      </Item>
168      <Item Name="[Ptr]" Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 1 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion2::ValTy::InfoTy::IntShift) &amp; 1) == 0">
169        ($T3)(Val.Val.Value &amp; InnerUnion1::ValTy::InfoTy::PointerBitMask)
170      </Item>
171      <Item Name="[Holds]" Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 1 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion2::ValTy::InfoTy::IntShift) &amp; 1) == 1">
172        "$T4", s8b
173      </Item>
174      <Item Name="[Ptr]" Condition="((Val.Val.Value &gt;&gt; ValTy::ValTy::InfoTy::IntShift) &amp; 1) == 1 &amp;&amp; ((Val.Val.Value &gt;&gt; InnerUnion2::ValTy::InfoTy::IntShift) &amp; 1) == 1">
175        ($T4)(Val.Val.Value &amp; InnerUnion1::ValTy::InfoTy::PointerBitMask)
176      </Item>
177    </Expand>
178  </Type>
179
180  <Type Name="llvm::iplist&lt;*,*&gt;">
181    <DisplayString Condition="Head == 0">{{ empty }}</DisplayString>
182    <DisplayString Condition="Head != 0">{{ head={Head} }}</DisplayString>
183    <Expand>
184      <LinkedListItems>
185        <HeadPointer>Head</HeadPointer>
186        <NextPointer>Next</NextPointer>
187        <ValueNode>this</ValueNode>
188      </LinkedListItems>
189    </Expand>
190  </Type>
191
192  <Type Name="llvm::IntrusiveRefCntPtr&lt;*&gt;">
193    <DisplayString Condition="Obj == 0">empty</DisplayString>
194    <DisplayString Condition="(Obj != 0) &amp;&amp; (Obj-&gt;ref_cnt == 1)">RefPtr [1 ref] {*Obj}</DisplayString>
195    <DisplayString Condition="(Obj != 0) &amp;&amp; (Obj-&gt;ref_cnt != 1)">RefPtr [{Obj-&gt;ref_cnt} refs] {*Obj}</DisplayString>
196    <Expand>
197      <Item Condition="Obj != 0" Name="[refs]">Obj-&gt;ref_cnt</Item>
198      <ExpandedItem Condition="Obj != 0">Obj</ExpandedItem>
199    </Expand>
200  </Type>
201
202  <Type Name="llvm::SmallPtrSet&lt;*,*&gt;">
203    <DisplayString Condition="CurArray == SmallArray">{{ [Small Mode] size={NumElements}, capacity={CurArraySize} }}</DisplayString>
204    <DisplayString Condition="CurArray != SmallArray">{{ [Big Mode] size={NumElements}, capacity={CurArraySize} }}</DisplayString>
205    <Expand>
206      <Item Name="[size]">NumElements</Item>
207      <Item Name="[capacity]">CurArraySize</Item>
208      <ArrayItems>
209        <Size>CurArraySize</Size>
210        <ValuePointer>($T1*)CurArray</ValuePointer>
211      </ArrayItems>
212    </Expand>
213  </Type>
214
215  <Type Name="llvm::DenseMap&lt;*,*,*&gt;">
216    <DisplayString Condition="NumEntries == 0">empty</DisplayString>
217    <DisplayString Condition="NumEntries != 0">{{ size={NumEntries}, buckets={NumBuckets} }}</DisplayString>
218    <Expand>
219      <Item Name="[size]">NumEntries</Item>
220      <Item Name="[buckets]">NumBuckets</Item>
221      <ArrayItems>
222        <Size>NumBuckets</Size>
223        <ValuePointer>Buckets</ValuePointer>
224      </ArrayItems>
225    </Expand>
226  </Type>
227
228  <Type Name="llvm::StringMap&lt;*,*&gt;">
229    <DisplayString>{{ size={NumItems}, buckets={NumBuckets} }}</DisplayString>
230    <Expand>
231      <Item Name="[size]">NumItems</Item>
232      <Item Name="[buckets]">NumBuckets</Item>
233      <ArrayItems>
234        <Size>NumBuckets</Size>
235        <ValuePointer>(MapEntryTy**)TheTable</ValuePointer>
236      </ArrayItems>
237    </Expand>
238  </Type>
239
240  <Type Name="llvm::StringMapEntry&lt;*&gt;">
241    <DisplayString Condition="StrLen == 0">empty</DisplayString>
242    <DisplayString Condition="StrLen != 0">({this+1,s}, {second})</DisplayString>
243    <Expand>
244      <Item Name="[key]">this+1,s</Item>
245      <Item Name="[value]" Condition="StrLen != 0">second</Item>
246    </Expand>
247  </Type>
248
249  <Type Name="llvm::Triple">
250    <DisplayString>{Data}</DisplayString>
251  </Type>
252
253  <Type Name="llvm::Optional&lt;*&gt;">
254    <DisplayString Condition="!Storage.hasVal">None</DisplayString>
255    <DisplayString Condition="Storage.hasVal">{*(($T1 *)(unsigned char *)Storage.storage.buffer)}</DisplayString>
256    <Expand>
257      <Item Name="[underlying]" Condition="Storage.hasVal">*(($T1 *)(unsigned char *)Storage.storage.buffer)</Item>
258    </Expand>
259  </Type>
260
261  <Type Name="llvm::Expected&lt;*&gt;">
262    <DisplayString Condition="HasError">Error</DisplayString>
263    <DisplayString Condition="!HasError">{*((storage_type *)TStorage.buffer)}</DisplayString>
264    <Expand>
265      <Item Name="[value]" Condition="!HasError">*((storage_type *)TStorage.buffer)</Item>
266      <Item Name="[error]" Condition="HasError">*((error_type *)ErrorStorage.buffer)</Item>
267    </Expand>
268  </Type>
269
270
271  <!-- Since we're in MSVC, we can assume that the system is little endian.  Therefore
272       the little and native cases just require a cast.  Handle this easy case first. Use
273       a wildcard for the second template argument (the endianness), but we will use a
274       specific value of 0 later on for the big endian to give it priority for being a
275       better match.  -->
276  <Type Name="llvm::support::detail::packed_endian_specific_integral&lt;*,*,1&gt;">
277    <DisplayString>{{little endian value = {*(($T1*)(unsigned char *)Value.buffer)} }}</DisplayString>
278    <Expand>
279      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==1">(unsigned char *)Value.buffer,1</Item>
280      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==2">(unsigned char *)Value.buffer,2</Item>
281      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==4">(unsigned char *)Value.buffer,4</Item>
282      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==8">(unsigned char *)Value.buffer,8</Item>
283    </Expand>
284  </Type>
285
286  <!-- Now handle the hard case of big endian.  We need to do the swizzling here, but
287       we need to specialize it based on the size of the value type. -->
288  <Type Name="llvm::support::detail::packed_endian_specific_integral&lt;*,0,1&gt;">
289    <DisplayString Condition="sizeof($T1)==1">{{ big endian value = {*(unsigned char *)Value.buffer} }}</DisplayString>
290    <DisplayString Condition="sizeof($T1)==2">{{ big endian value = {(($T1)(*(unsigned char *)Value.buffer) &lt;&lt; 8)
291                                                                    | ($T1)(*((unsigned char *)Value.buffer+1))} }}</DisplayString>
292    <DisplayString Condition="sizeof($T1)==4">{{ big endian value = {(($T1)(*(unsigned char *)Value.buffer) &lt;&lt; 24)
293                                                                    | (($T1)(*((unsigned char *)Value.buffer+1)) &lt;&lt; 16)
294                                                                    | (($T1)(*((unsigned char *)Value.buffer+2)) &lt;&lt; 8)
295                                                                    |  ($T1)(*((unsigned char *)Value.buffer+3))} }}</DisplayString>
296    <DisplayString Condition="sizeof($T1)==8">{{ big endian value = {(($T1)(*(unsigned char *)Value.buffer) &lt;&lt; 56)
297                                                                    | (($T1)(*((unsigned char *)Value.buffer+1)) &lt;&lt; 48)
298                                                                    | (($T1)(*((unsigned char *)Value.buffer+2)) &lt;&lt; 40)
299                                                                    | (($T1)(*((unsigned char *)Value.buffer+3)) &lt;&lt; 32)
300                                                                    | (($T1)(*((unsigned char *)Value.buffer+4)) &lt;&lt; 24)
301                                                                    | (($T1)(*((unsigned char *)Value.buffer+5)) &lt;&lt; 16)
302                                                                    | (($T1)(*((unsigned char *)Value.buffer+6)) &lt;&lt; 8)
303                                                                    |  ($T1)(*((unsigned char *)Value.buffer+7))} }}</DisplayString>
304    <Expand>
305      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==1">(unsigned char *)Value.buffer,1</Item>
306      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==2">(unsigned char *)Value.buffer,2</Item>
307      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==4">(unsigned char *)Value.buffer,4</Item>
308      <Item Name="[Raw Bytes]" Condition="sizeof($T1)==8">(unsigned char *)Value.buffer,8</Item>
309    </Expand>
310  </Type>
311</AutoVisualizer>
312