]> granicus.if.org Git - clang/commitdiff
Add visualizers for more clang types. Create more C++-like visualizations for existin...
authorMike Spertus <mike@spertus.com>
Wed, 16 Mar 2016 14:27:50 +0000 (14:27 +0000)
committerMike Spertus <mike@spertus.com>
Wed, 16 Mar 2016 14:27:50 +0000 (14:27 +0000)
Created visualizer for PointerType, LValueReferenceType, RValueReferenceType, and TemplateParmType.
In addition, cleaned up the display of existing types to be more C++-like. For example, instead of

  SubstTemplateTypeParmType: {Identifier (("T"))} => Record (25), {Identifier (("A"))}

it now displays more readably as

  SubstTemplateTypeParmType: {typename T <= struct A}

The <expand> sections still can be used for all the gory details if necessary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263638 91177308-0d34-0410-b5e6-96231b3b80d8

utils/clang.natvis

index 6ff0123c16cd70540597a0331bba09748b85fa51..ef20a211ebc0393053420503a1a6a30aea46f42d 100644 (file)
@@ -6,46 +6,112 @@ Put this file into "%USERPROFILE%\Documents\Visual Studio 20xx\Visualizers"
 or create a symbolic link so it updates automatically.\r
 -->\r
 <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">\r
+\r
   <Type Name="clang::Type">\r
-    <DisplayString IncludeView="BaseOnly">{(clang::Type::TypeClass)TypeBits.TC, en}</DisplayString>\r
-    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Builtin">Builtin Type={*(clang::BuiltinType *)this}</DisplayString>\r
-    <DisplayString Condition="TypeBits.TC==clang::Type::Attributed">Modified Type={((clang::AttributedType*)this)->ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}</DisplayString>\r
-    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::SubstTemplateTypeParm">{*(clang::SubstTemplateTypeParmType *)this}</DisplayString>\r
-    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Record">{*(clang::RecordType *)this}</DisplayString>\r
-    <DisplayString>{(clang::Type::TypeClass)TypeBits.TC, en}</DisplayString>\r
+    <!-- To visualize clang::Types, we need to look at TypeBits.TC to determine the actual\r
+         type subclass and manually dispatch accordingly (Visual Studio can't identify the real type\r
+         because clang::Type has no virtual members hence no RTTI). \r
+         \r
+         Views:\r
+           "cmn": Visualization that is common to all clang::Type subclasses\r
+           "poly": Visualization that is specific to the actual clang::Type subclass. The subtype-specific\r
+                   <DisplayString> is typically as C++-like as possible (like in dump()) with <Expand>\r
+                   containing all the gory details.\r
+           "cpp": Only occasionally used when we need to distinguish between an ordinary view and a C++-like view.\r
+    -->\r
+    <DisplayString IncludeView="cmn">{(clang::Type::TypeClass)TypeBits.TC, en}Type</DisplayString>\r
+    <!-- Dispatch to visualizers for the actual Type subclass -->\r
+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Builtin" IncludeView="poly">{*(clang::BuiltinType *)this}</DisplayString>\r
+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Pointer" IncludeView="poly">{*(clang::PointerType *)this}</DisplayString>\r
+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::LValueReference" IncludeView="poly">{*(clang::LValueReferenceType *)this}</DisplayString>\r
+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::RValueReference" IncludeView="poly">{*(clang::RValueReferenceType *)this}</DisplayString>\r
+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Attributed" IncludeView="poly">{*(clang::AttributedType *)this}</DisplayString>\r
+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::TemplateTypeParm" IncludeView="poly">{*(clang::TemplateTypeParmType *)this}</DisplayString>\r
+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::SubstTemplateTypeParm" IncludeView="poly">{*(clang::SubstTemplateTypeParmType *)this}</DisplayString>\r
+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Record" IncludeView="poly">{*(clang::RecordType *)this}</DisplayString>\r
+    <DisplayString IncludeView="cpp">{*this,view(poly)}</DisplayString>\r
+    <DisplayString IncludeView="poly">{*this,view(cmn)}"</DisplayString> <!-- Not yet implemented Type subclass -->\r
+    <DisplayString>{*this,view(cmn)}  {{{*this,view(poly)}}}</DisplayString>\r
+    <Expand>\r
+      <Item Name="TypeClass" IncludeView="cmn">(clang::Type::TypeClass)TypeBits.TC</Item>\r
+      <Item Name="Flags" IncludeView="cmn">TypeBits</Item>\r
+      <Item Name="Canonical" IncludeView="cmn">CanonicalType</Item>\r
+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Builtin">*(clang::BuiltinType *)this</ExpandedItem>\r
+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Pointer">*(clang::PointerType *)this</ExpandedItem>\r
+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::LValueReference">*(clang::LValueReferenceType *)this</ExpandedItem>\r
+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::RValueReference">*(clang::RValueReferenceType *)this</ExpandedItem>\r
+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Attributed">*(clang::AttributedType *)this</ExpandedItem>\r
+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::TemplateTypeParm">(clang::TemplateTypeParmType *)this</ExpandedItem>\r
+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::SubstTemplateTypeParm">(clang::SubstTemplateTypeParmType *)this</ExpandedItem>\r
+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Record">(clang::RecordType *)this</ExpandedItem>\r
+    </Expand>\r
+  </Type>\r
+  <Type Name="clang::PointerType">\r
+    <DisplayString>{PointeeType, view(poly)} *</DisplayString>\r
+    <Expand>\r
+      <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>\r
+      <Item Name="PointeeType">PointeeType</Item>\r
+    </Expand>\r
+  </Type>\r
+  <!-- We visualize all inner types for clang reference types. So a rvalue reference to an lvalue reference\r
+       to an int  would visual as int &amp; &amp;&amp; This is a little different than GetPointeeType(),\r
+       but more clearly displays the data structure and seems natural -->\r
+  <Type Name="clang::LValueReferenceType">\r
+    <DisplayString>{((clang::ReferenceType *)this)-&gt;PointeeType,view(cpp)} &amp;</DisplayString>\r
+    <Expand>\r
+      <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>\r
+      <Item Name="PointeeType">PointeeType</Item>\r
+    </Expand>\r
+  </Type>\r
+  <Type Name="clang::RValueReferenceType">\r
+    <DisplayString>{((clang::ReferenceType *)this)-&gt;PointeeType,view(cpp)} &amp;&amp;</DisplayString>\r
     <Expand>\r
-      <Item Name="TypeClass" IncludeView="BaseOnly">(clang::Type::TypeClass)TypeBits.TC</Item>\r
-      <Item Name="Flags" IncludeView="BaseOnly">TypeBits</Item>\r
-      <Item Name="Canonical" IncludeView="BaseOnly">CanonicalType</Item>\r
-      <ExpandedItem ExcludeView="BaseOnly" Condition="TypeBits.TC==clang::Type::TypeClass::Builtin">*(clang::BuiltinType *)this</ExpandedItem>\r
-      <ExpandedItem ExcludeView="BaseOnly" Condition="TypeBits.TC==clang::Type::TypeClass::SubstTemplateTypeParm">(clang::SubstTemplateTypeParmType *)this</ExpandedItem>\r
-      <ExpandedItem ExcludeView="BaseOnly" Condition="TypeBits.TC==clang::Type::TypeClass::Record">(clang::RecordType *)this</ExpandedItem>\r
+      <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>\r
+      <Item Name="PointeeType">PointeeType</Item>\r
     </Expand>\r
   </Type>\r
+  <Type Name="clang::AttributedType">\r
+    <DisplayString>{ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}</DisplayString>\r
+  </Type>\r
+  <Type Name="clang::NamedDecl" >\r
+    <DisplayString IncludeView="cpp">{Name,view(cpp)}</DisplayString>\r
+    <DisplayString>{Name}</DisplayString>\r
+  </Type>\r
+  <Type Name="clang::TagDecl">\r
+    <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Struct">struct {Name,view(cpp)}</DisplayString>\r
+    <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Interface">interface {Name,view(cpp)}</DisplayString>\r
+    <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Union">union {Name,view(cpp)}</DisplayString>\r
+    <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Class">class {Name,view(cpp)}</DisplayString>\r
+    <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Enum">enum {Name,view(cpp)}</DisplayString>\r
+  </Type>\r
   <Type Name="clang::TagType">\r
     <DisplayString>{*decl}</DisplayString>\r
     <Expand>\r
+      <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>\r
       <Item Name="decl">decl</Item>\r
     </Expand>\r
   </Type>\r
   <Type Name="clang::RecordType">\r
-    <DisplayString>{*(clang::Type *)this, view(BaseOnly)}, {*(clang::TagType *)this}</DisplayString>\r
+    <DisplayString>{*(clang::TagType *)this}</DisplayString>\r
     <Expand>\r
       <Item Name="TagType">*(clang::TagType *)this</Item>\r
     </Expand>\r
   </Type>\r
+\r
   <Type Name="clang::SubstTemplateTypeParmType">\r
-    <DisplayString>{*(clang::Type *)this, view(BaseOnly)}: {*Replaced} =&gt; {CanonicalType}</DisplayString>\r
+    <DisplayString>{*Replaced,view(cpp)} &lt;= {CanonicalType,view(cpp)}</DisplayString>\r
     <Expand>\r
-      <ExpandedItem>*(clang::Type *)this, view(BaseOnly)</ExpandedItem>\r
+      <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>\r
       <Item Name="Replaced">*Replaced</Item>\r
     </Expand>\r
   </Type>\r
   <Type Name="clang::TemplateTypeParmType">\r
-    <DisplayString>{*TTPDecl}</DisplayString>\r
+    <DisplayString>typename {*TTPDecl,view(cpp)}</DisplayString>\r
   </Type>\r
   <Type Name="clang::QualType">\r
     <!-- TODO: Qualifiers. Also, when VS2013 support is deprecated, change 4 to clang::TypeAlignmentInBits (not properly recognized by VS2013) -->\r
+    <DisplayString IncludeView="poly">{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType,view(poly)}</DisplayString>\r
+    <DisplayString IncludeView="cpp">{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType,view(cpp)}</DisplayString>\r
     <DisplayString>{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType}</DisplayString>\r
     <Expand>\r
       <Item Name="BaseType">*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType</Item>\r
@@ -70,15 +136,13 @@ or create a symbolic link so it updates automatically.
       <Item Name="Kind">(clang::BuiltinType::Kind)BuiltinTypeBits.Kind</Item>\r
     </Expand>\r
   </Type>\r
-  <Type Name="clang::NamedDecl">\r
-    <DisplayString>{Name}</DisplayString>\r
-  </Type>\r
+\r
   <Type Name="clang::TemplateSpecializationType">\r
     <DisplayString Condition="(Template.Storage.Val.Val.Value &amp; 3) != 3 &amp;&amp; (Template.Storage.Val.Val.Value &amp; 2) != 2 &amp;&amp; (Template.Storage.Val.Val.Value &amp; 1) != 1">{(clang::TemplateDecl *)((Template.Storage.Val.Val.Value &gt;&gt; 2) &lt;&lt; 2)}</DisplayString>\r
     <DisplayString>{Template.Storage}</DisplayString>\r
   </Type>\r
   <Type Name="clang::IdentifierInfo">\r
-    <DisplayString Condition="Entry != 0">({((llvm::StringMapEntry&lt;clang::IdentifierInfo *&gt;*)Entry)+1,s})</DisplayString>\r
+    <DisplayString Condition="Entry != 0">{((llvm::StringMapEntry&lt;clang::IdentifierInfo *&gt;*)Entry)+1,sb}</DisplayString>\r
     <Expand>\r
       <Item Condition="Entry != 0" Name="[Identifier]">((llvm::StringMapEntry&lt;clang::IdentifierInfo *&gt;*)Entry)+1,s</Item>\r
       <Item Name="Token Kind">(clang::tok::TokenKind)TokenID</Item>\r
@@ -86,6 +150,7 @@ or create a symbolic link so it updates automatically.
   </Type>\r
   <Type Name="clang::DeclarationName">\r
     <DisplayString Condition="Ptr == 0">Empty</DisplayString>\r
+    <DisplayString Condition="(Ptr &amp; PtrMask) == StoredIdentifier" IncludeView="cpp">{*(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)}</DisplayString>\r
     <DisplayString Condition="(Ptr &amp; PtrMask) == StoredIdentifier">{{Identifier ({*(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)})}}</DisplayString>\r
     <DisplayString Condition="(Ptr &amp; PtrMask) == StoredObjCZeroArgSelector">{{ObjC Zero Arg Selector (*{(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)})}}</DisplayString>\r
     <DisplayString Condition="(Ptr &amp; PtrMask) == StoredObjCOneArgSelector">{{ObjC One Arg Selector (*{(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)})}}</DisplayString>\r