[PATCH] D56186: Fix MSVC PointerUnion visualization

Mike Spertus via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 1 09:20:34 PST 2019


mspertus created this revision.
mspertus added reviewers: aaron.ballman, zturner.
Herald added subscribers: llvm-commits, kristina, dexonsmith.

When PointerIntPair was updated to put the IntShift etc. in a helper type, it broke some MSVC visualizations, in particular PointerIntPair and PointerUnion. This patch fixes PointerUnion (PointerIntPair visualization has already been fixed) visualization by adding a local typedef to PointerIntPair so the PointerUnion visualizer can find the IntShift, etc.

While this could have been done in principle without adding the typedef, it not only seems generally useful for debugging, but writing the complex expressions needed without it seem to break the MSVC native visualizer, so this approach seems like a win-win.

As a bonus, we also slightly improve the SmallVector visualizer not to go crazy when visualized before its constructor is called


Repository:
  rL LLVM

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,11 @@
   </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="[Ptr]" Condition="((Val.Value >> ValTy::InfoTy::IntShift) & ValTy::InfoTy::IntMask) == 0">($T1)(Val.Value & ValTy::InfoTy::PointerBitMask)</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 but generally helpful for debugging/visualizing
+  using InfoTy = Info;
   intptr_t Value = 0;
 
 public:


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


More information about the llvm-commits mailing list