[PATCH] D21256: Improved Visual Studio 2015 visualization of SmallVectorImpl

Mike Spertus via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 10 19:57:52 PDT 2016


mspertus created this revision.
mspertus added reviewers: aaron.ballman, zturner, aemerson.
mspertus added a subscriber: cfe-commits.

When visualizing small vectors in VS2015, show the first few elements in the DisplayString instead of the size. For example, a `SmallVector` of `DeclAccessPair` will visualize like

  {public typename ...Ts, public typename U}

The visualization in VS2013 remains the same because we continue to include the old visualizer with a lower-than-default priority of `MediumLow`, and the same `SmallVector` would continue to be visualized as

  {size = 2}

I decided to submit this one for review before commit because as `SmallVector` is used pretty much everywhere in LLVM and Clang, even though I think this is a huge improvement in practice but wanted to give others a chance to pipe in if they disagree. If no one pipes in, I plan to go ahead and commit in 48 hours

http://reviews.llvm.org/D21256

Files:
  llvm.natvis

Index: llvm.natvis
===================================================================
--- llvm.natvis
+++ llvm.natvis
@@ -8,8 +8,8 @@
 For later versions of Visual Studio, no setup is required.
 -->
 <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
-
-  <Type Name="llvm::SmallVectorImpl<*>">
+  <!-- VS2013 -->
+  <Type Name="llvm::SmallVectorImpl<*>" Priority="MediumLow">
     <DisplayString Condition="(($T1*)EndX - ($T1*)BeginX) == 0">empty</DisplayString>
     <DisplayString Condition="(($T1*)EndX - ($T1*)BeginX) != 0">{{ size={($T1*)EndX - ($T1*)BeginX} }}</DisplayString>
     <Expand>
@@ -21,6 +21,29 @@
       </ArrayItems>
     </Expand>
   </Type>
+  <!-- VS2015 and up -->
+  <Type Name="llvm::SmallVectorImpl<*>">
+    <DisplayString IncludeView ="elt0" Condition="(($T1*)EndX - ($T1*)BeginX) == 0"></DisplayString>
+    <DisplayString IncludeView ="elt0">{(($T1*)BeginX)[0]}{*this,view(elt1)}</DisplayString>
+    <DisplayString IncludeView ="elt1" Condition="(($T1*)EndX - ($T1*)BeginX) == 1"></DisplayString>
+    <DisplayString IncludeView ="elt1">, {(($T1*)BeginX)[1]}{*this,view(elt2)}</DisplayString>
+    <DisplayString IncludeView ="elt2" Condition="(($T1*)EndX - ($T1*)BeginX) == 2"></DisplayString>
+    <DisplayString IncludeView ="elt2">, {(($T1*)BeginX)[2]}{*this,view(elt3)}</DisplayString>
+    <DisplayString IncludeView ="elt3" Condition="(($T1*)EndX - ($T1*)BeginX) == 3"></DisplayString>
+    <DisplayString IncludeView ="elt3">, {(($T1*)BeginX)[2]}{*this,view(elt4)}</DisplayString>
+    <DisplayString IncludeView ="elt4" Condition="(($T1*)EndX - ($T1*)BeginX) == 4"></DisplayString>
+    <DisplayString IncludeView ="elt4">, /* {(($T1*)EndX - ($T1*)BeginX) - 4} more*/ </DisplayString>
+    <DisplayString Condition="(($T1*)EndX - ($T1*)BeginX) == 0">empty</DisplayString>
+    <DisplayString Condition="(($T1*)EndX - ($T1*)BeginX) != 0">{{{*this,view(elt0)}}}</DisplayString>
+    <Expand>
+      <Item Name="[size]">($T1*)EndX - ($T1*)BeginX</Item>
+      <Item Name="[capacity]">($T1*)CapacityX - ($T1*)BeginX</Item>
+      <ArrayItems>
+        <Size>($T1*)EndX - ($T1*)BeginX</Size>
+        <ValuePointer>($T1*)BeginX</ValuePointer>
+      </ArrayItems>
+    </Expand>
+  </Type>
   <Type Name="llvm::ArrayRef<*>">
     <DisplayString Condition="Length == 0">empty</DisplayString>
     <DisplayString Condition="Length != 0">{{ size={Length} }}</DisplayString>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21256.60434.patch
Type: text/x-patch
Size: 2465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160611/93463123/attachment.bin>


More information about the cfe-commits mailing list