Add visualizers for more clang types. Create more C++-like visualizations for existing Clang types

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.

llvm-svn: 263638
diff --git a/clang/utils/clang.natvis b/clang/utils/clang.natvis
index 6ff0123..ef20a21 100644
--- a/clang/utils/clang.natvis
+++ b/clang/utils/clang.natvis
@@ -6,46 +6,112 @@
 or create a symbolic link so it updates automatically.

 -->

 <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">

+

   <Type Name="clang::Type">

-    <DisplayString IncludeView="BaseOnly">{(clang::Type::TypeClass)TypeBits.TC, en}</DisplayString>

-    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Builtin">Builtin Type={*(clang::BuiltinType *)this}</DisplayString>

-    <DisplayString Condition="TypeBits.TC==clang::Type::Attributed">Modified Type={((clang::AttributedType*)this)->ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}</DisplayString>

-    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::SubstTemplateTypeParm">{*(clang::SubstTemplateTypeParmType *)this}</DisplayString>

-    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Record">{*(clang::RecordType *)this}</DisplayString>

-    <DisplayString>{(clang::Type::TypeClass)TypeBits.TC, en}</DisplayString>

+    <!-- To visualize clang::Types, we need to look at TypeBits.TC to determine the actual

+         type subclass and manually dispatch accordingly (Visual Studio can't identify the real type

+         because clang::Type has no virtual members hence no RTTI). 

+         

+         Views:

+           "cmn": Visualization that is common to all clang::Type subclasses

+           "poly": Visualization that is specific to the actual clang::Type subclass. The subtype-specific

+                   <DisplayString> is typically as C++-like as possible (like in dump()) with <Expand>

+                   containing all the gory details.

+           "cpp": Only occasionally used when we need to distinguish between an ordinary view and a C++-like view.

+    -->

+    <DisplayString IncludeView="cmn">{(clang::Type::TypeClass)TypeBits.TC, en}Type</DisplayString>

+    <!-- Dispatch to visualizers for the actual Type subclass -->

+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Builtin" IncludeView="poly">{*(clang::BuiltinType *)this}</DisplayString>

+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Pointer" IncludeView="poly">{*(clang::PointerType *)this}</DisplayString>

+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::LValueReference" IncludeView="poly">{*(clang::LValueReferenceType *)this}</DisplayString>

+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::RValueReference" IncludeView="poly">{*(clang::RValueReferenceType *)this}</DisplayString>

+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Attributed" IncludeView="poly">{*(clang::AttributedType *)this}</DisplayString>

+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::TemplateTypeParm" IncludeView="poly">{*(clang::TemplateTypeParmType *)this}</DisplayString>

+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::SubstTemplateTypeParm" IncludeView="poly">{*(clang::SubstTemplateTypeParmType *)this}</DisplayString>

+    <DisplayString Condition="TypeBits.TC==clang::Type::TypeClass::Record" IncludeView="poly">{*(clang::RecordType *)this}</DisplayString>

+    <DisplayString IncludeView="cpp">{*this,view(poly)}</DisplayString>

+    <DisplayString IncludeView="poly">{*this,view(cmn)}"</DisplayString> <!-- Not yet implemented Type subclass -->

+    <DisplayString>{*this,view(cmn)}  {{{*this,view(poly)}}}</DisplayString>

     <Expand>

-      <Item Name="TypeClass" IncludeView="BaseOnly">(clang::Type::TypeClass)TypeBits.TC</Item>

-      <Item Name="Flags" IncludeView="BaseOnly">TypeBits</Item>

-      <Item Name="Canonical" IncludeView="BaseOnly">CanonicalType</Item>

-      <ExpandedItem ExcludeView="BaseOnly" Condition="TypeBits.TC==clang::Type::TypeClass::Builtin">*(clang::BuiltinType *)this</ExpandedItem>

-      <ExpandedItem ExcludeView="BaseOnly" Condition="TypeBits.TC==clang::Type::TypeClass::SubstTemplateTypeParm">(clang::SubstTemplateTypeParmType *)this</ExpandedItem>

-      <ExpandedItem ExcludeView="BaseOnly" Condition="TypeBits.TC==clang::Type::TypeClass::Record">(clang::RecordType *)this</ExpandedItem>

+      <Item Name="TypeClass" IncludeView="cmn">(clang::Type::TypeClass)TypeBits.TC</Item>

+      <Item Name="Flags" IncludeView="cmn">TypeBits</Item>

+      <Item Name="Canonical" IncludeView="cmn">CanonicalType</Item>

+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Builtin">*(clang::BuiltinType *)this</ExpandedItem>

+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Pointer">*(clang::PointerType *)this</ExpandedItem>

+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::LValueReference">*(clang::LValueReferenceType *)this</ExpandedItem>

+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::RValueReference">*(clang::RValueReferenceType *)this</ExpandedItem>

+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Attributed">*(clang::AttributedType *)this</ExpandedItem>

+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::TemplateTypeParm">(clang::TemplateTypeParmType *)this</ExpandedItem>

+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::SubstTemplateTypeParm">(clang::SubstTemplateTypeParmType *)this</ExpandedItem>

+      <ExpandedItem ExcludeView="cmn" Condition="TypeBits.TC==clang::Type::TypeClass::Record">(clang::RecordType *)this</ExpandedItem>

     </Expand>

   </Type>

+  <Type Name="clang::PointerType">

+    <DisplayString>{PointeeType, view(poly)} *</DisplayString>

+    <Expand>

+      <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>

+      <Item Name="PointeeType">PointeeType</Item>

+    </Expand>

+  </Type>

+  <!-- We visualize all inner types for clang reference types. So a rvalue reference to an lvalue reference

+       to an int  would visual as int &amp; &amp;&amp; This is a little different than GetPointeeType(),

+       but more clearly displays the data structure and seems natural -->

+  <Type Name="clang::LValueReferenceType">

+    <DisplayString>{((clang::ReferenceType *)this)-&gt;PointeeType,view(cpp)} &amp;</DisplayString>

+    <Expand>

+      <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>

+      <Item Name="PointeeType">PointeeType</Item>

+    </Expand>

+  </Type>

+  <Type Name="clang::RValueReferenceType">

+    <DisplayString>{((clang::ReferenceType *)this)-&gt;PointeeType,view(cpp)} &amp;&amp;</DisplayString>

+    <Expand>

+      <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>

+      <Item Name="PointeeType">PointeeType</Item>

+    </Expand>

+  </Type>

+  <Type Name="clang::AttributedType">

+    <DisplayString>{ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind}</DisplayString>

+  </Type>

+  <Type Name="clang::NamedDecl" >

+    <DisplayString IncludeView="cpp">{Name,view(cpp)}</DisplayString>

+    <DisplayString>{Name}</DisplayString>

+  </Type>

+  <Type Name="clang::TagDecl">

+    <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Struct">struct {Name,view(cpp)}</DisplayString>

+    <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Interface">interface {Name,view(cpp)}</DisplayString>

+    <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Union">union {Name,view(cpp)}</DisplayString>

+    <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Class">class {Name,view(cpp)}</DisplayString>

+    <DisplayString Condition="TagDeclKind==clang::TagTypeKind::TTK_Enum">enum {Name,view(cpp)}</DisplayString>

+  </Type>

   <Type Name="clang::TagType">

     <DisplayString>{*decl}</DisplayString>

     <Expand>

+      <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>

       <Item Name="decl">decl</Item>

     </Expand>

   </Type>

   <Type Name="clang::RecordType">

-    <DisplayString>{*(clang::Type *)this, view(BaseOnly)}, {*(clang::TagType *)this}</DisplayString>

+    <DisplayString>{*(clang::TagType *)this}</DisplayString>

     <Expand>

       <Item Name="TagType">*(clang::TagType *)this</Item>

     </Expand>

   </Type>

+

   <Type Name="clang::SubstTemplateTypeParmType">

-    <DisplayString>{*(clang::Type *)this, view(BaseOnly)}: {*Replaced} =&gt; {CanonicalType}</DisplayString>

+    <DisplayString>{*Replaced,view(cpp)} &lt;= {CanonicalType,view(cpp)}</DisplayString>

     <Expand>

-      <ExpandedItem>*(clang::Type *)this, view(BaseOnly)</ExpandedItem>

+      <ExpandedItem>*(clang::Type *)this, view(cmn)</ExpandedItem>

       <Item Name="Replaced">*Replaced</Item>

     </Expand>

   </Type>

   <Type Name="clang::TemplateTypeParmType">

-    <DisplayString>{*TTPDecl}</DisplayString>

+    <DisplayString>typename {*TTPDecl,view(cpp)}</DisplayString>

   </Type>

   <Type Name="clang::QualType">

     <!-- TODO: Qualifiers. Also, when VS2013 support is deprecated, change 4 to clang::TypeAlignmentInBits (not properly recognized by VS2013) -->

+    <DisplayString IncludeView="poly">{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType,view(poly)}</DisplayString>

+    <DisplayString IncludeView="cpp">{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType,view(cpp)}</DisplayString>

     <DisplayString>{*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType}</DisplayString>

     <Expand>

       <Item Name="BaseType">*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) &amp; ~(uintptr_t)((1 &lt;&lt; 4) - 1)))-&gt;BaseType</Item>

@@ -70,15 +136,13 @@
       <Item Name="Kind">(clang::BuiltinType::Kind)BuiltinTypeBits.Kind</Item>

     </Expand>

   </Type>

-  <Type Name="clang::NamedDecl">

-    <DisplayString>{Name}</DisplayString>

-  </Type>

+

   <Type Name="clang::TemplateSpecializationType">

     <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>

     <DisplayString>{Template.Storage}</DisplayString>

   </Type>

   <Type Name="clang::IdentifierInfo">

-    <DisplayString Condition="Entry != 0">({((llvm::StringMapEntry&lt;clang::IdentifierInfo *&gt;*)Entry)+1,s})</DisplayString>

+    <DisplayString Condition="Entry != 0">{((llvm::StringMapEntry&lt;clang::IdentifierInfo *&gt;*)Entry)+1,sb}</DisplayString>

     <Expand>

       <Item Condition="Entry != 0" Name="[Identifier]">((llvm::StringMapEntry&lt;clang::IdentifierInfo *&gt;*)Entry)+1,s</Item>

       <Item Name="Token Kind">(clang::tok::TokenKind)TokenID</Item>

@@ -86,6 +150,7 @@
   </Type>

   <Type Name="clang::DeclarationName">

     <DisplayString Condition="Ptr == 0">Empty</DisplayString>

+    <DisplayString Condition="(Ptr &amp; PtrMask) == StoredIdentifier" IncludeView="cpp">{*(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)}</DisplayString>

     <DisplayString Condition="(Ptr &amp; PtrMask) == StoredIdentifier">{{Identifier ({*(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)})}}</DisplayString>

     <DisplayString Condition="(Ptr &amp; PtrMask) == StoredObjCZeroArgSelector">{{ObjC Zero Arg Selector (*{(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)})}}</DisplayString>

     <DisplayString Condition="(Ptr &amp; PtrMask) == StoredObjCOneArgSelector">{{ObjC One Arg Selector (*{(clang::IdentifierInfo *)(Ptr &amp; ~PtrMask)})}}</DisplayString>