[PATCH] D56186: Fix MSVC PointerUnion visualization

Mike Spertus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 1 11:39:12 PST 2019


mspertus updated this revision to Diff 179801.
mspertus added a comment.

Improve PointerUnion expansion to show what type it holds
F7783503: PointerUnion.jpg <https://reviews.llvm.org/F7783503>


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56186/new/

https://reviews.llvm.org/D56186

Files:
  include/llvm/ADT/PointerIntPair.h
  utils/LLVMVisualizers/llvm.natvis


Index: utils/LLVMVisualizers/llvm.natvis
===================================================================
--- utils/LLVMVisualizers/llvm.natvis
+++ utils/LLVMVisualizers/llvm.natvis
@@ -35,6 +35,7 @@
     <DisplayString IncludeView ="elt4">, /* {Size - 4} more*/ </DisplayString>
     <DisplayString Condition="Size == 0">empty</DisplayString>
     <DisplayString Condition="Size != 0">{{{*this,view(elt0)}}}</DisplayString>
+    <DisplayString>Uninitialized</DisplayString>
     <Expand>
       <Item Name="[size]">Size</Item>
       <Item Name="[capacity]">Capacity</Item>
@@ -93,11 +94,13 @@
   </Type>
 
   <Type Name="llvm::PointerUnion<*,*>">
-    <DisplayString Condition="((Val.Value >> Val.IntShift) & Val.IntMask) == 0">{"$T1", s8b}: {($T1)(Val.Value & Val.PointerBitMask)}</DisplayString>
-    <DisplayString Condition="((Val.Value >> Val.IntShift) & Val.IntMask) != 0">{"$T2", s8b}: {($T2)(Val.Value & Val.PointerBitMask)}</DisplayString>
+    <DisplayString Condition="((Val.Value >> ValTy::InfoTy::IntShift) & ValTy::InfoTy::IntMask) == 0">{"$T1", s8b}: {($T1)(Val.Value & ValTy::InfoTy::PointerBitMask)}</DisplayString>
+    <DisplayString Condition="((Val.Value >> ValTy::InfoTy::IntShift) & ValTy::InfoTy::IntMask) != 0">{"$T2", s8b}: {($T2)(Val.Value & ValTy::InfoTy::PointerBitMask)}</DisplayString>
     <Expand>
-      <ExpandedItem Condition="((Val.Value >> Val.IntShift) & Val.IntMask) == 0">($T1)(Val.Value & Val.PointerBitMask)</ExpandedItem>
-      <ExpandedItem Condition="((Val.Value >> Val.IntShift) & Val.IntMask) != 0">($T2)(Val.Value & Val.PointerBitMask)</ExpandedItem>
+      <Item Name="[Holds]" Condition="((Val.Value >> ValTy::InfoTy::IntShift) & ValTy::InfoTy::IntMask) == 0">"$T1", s8b</Item>
+      <Item Name="[Ptr]" Condition="((Val.Value >> ValTy::InfoTy::IntShift) & ValTy::InfoTy::IntMask) == 0">($T1)(Val.Value & ValTy::InfoTy::PointerBitMask)</Item>
+      <Item Name="[Holds]" Condition="((Val.Value >> ValTy::InfoTy::IntShift) & ValTy::InfoTy::IntMask) != 0">"$T2", s8b</Item>
+      <Item Name="[Ptr]" Condition="((Val.Value >> ValTy::InfoTy::IntShift) & ValTy::InfoTy::IntMask) != 0">($T2)(Val.Value & ValTy::InfoTy::PointerBitMask)</Item>
     </Expand>
   </Type>
 
Index: include/llvm/ADT/PointerIntPair.h
===================================================================
--- include/llvm/ADT/PointerIntPair.h
+++ include/llvm/ADT/PointerIntPair.h
@@ -42,6 +42,8 @@
           typename PtrTraits = PointerLikeTypeTraits<PointerTy>,
           typename Info = PointerIntPairInfo<PointerTy, IntBits, PtrTraits>>
 class PointerIntPair {
+  // Used by MSVC visualizer and generally helpful for debugging/visualizing
+  using InfoTy = Info;
   intptr_t Value = 0;
 
 public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56186.179801.patch
Type: text/x-patch
Size: 2899 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190101/07005e7f/attachment.bin>


More information about the llvm-commits mailing list