Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -817,3 +817,7 @@ ExternalProject_Add_StepTargets(${NEXT_CLANG_STAGE} ${target}) endforeach() endif() + +if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION) + add_subdirectory(utils/ClangVisualizers) +endif() Index: utils/ClangVisualizers/CMakeLists.txt =================================================================== --- utils/ClangVisualizers/CMakeLists.txt +++ utils/ClangVisualizers/CMakeLists.txt @@ -0,0 +1,7 @@ +# Do this by hand instead of using add_llvm_utilities(), which +# tries to create a corresponding executable, which we don't want. +if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION) + set(CLANG_VISUALIZERS clang.natvis) + add_custom_target(ClangVisualizers SOURCES ${CLANG_VISUALIZERS}) + set_target_properties(ClangVisualizers PROPERTIES FOLDER "Utils") +endif() Index: utils/ClangVisualizers/clang.natvis =================================================================== --- utils/ClangVisualizers/clang.natvis +++ utils/ClangVisualizers/clang.natvis @@ -2,9 +2,10 @@ +For Visual Studio 2013 only, put this file into +"%USERPROFILE%\Documents\Visual Studio 2013\Visualizers" or create a symbolic link so it updates automatically. + +For later versions of Visual Studio, no setup is required--> Index: utils/clang.natvis =================================================================== --- utils/clang.natvis +++ utils/clang.natvis @@ -1,361 +0,0 @@ - - - - - - - {(clang::Type::TypeClass)TypeBits.TC, en}Type - - {*(clang::BuiltinType *)this} - {*(clang::PointerType *)this} - {*(clang::LValueReferenceType *)this} - {*(clang::RValueReferenceType *)this} - {*(clang::AttributedType *)this} - {*(clang::TemplateTypeParmType *)this} - {*(clang::SubstTemplateTypeParmType *)this} - {*(clang::RecordType *)this} - {*(clang::RecordType *)this,view(cpp)} - {*(clang::FunctionProtoType *)this} - {*this,view(poly)} - {*this,view(cmn)}" - {*this,view(cmn)} {{{*this,view(poly)}}} - - (clang::Type::TypeClass)TypeBits.TC - TypeBits - CanonicalType - *(clang::BuiltinType *)this - *(clang::PointerType *)this - *(clang::LValueReferenceType *)this - *(clang::RValueReferenceType *)this - *(clang::AttributedType *)this - (clang::TemplateTypeParmType *)this - (clang::SubstTemplateTypeParmType *)this - (clang::RecordType *)this - (clang::FunctionProtoType *)this - - - - {PointeeType, view(poly)} * - - *(clang::Type *)this, view(cmn) - PointeeType - - - - - {((clang::ReferenceType *)this)->PointeeType,view(cpp)} & - - *(clang::Type *)this, view(cmn) - PointeeType - - - - {((clang::ReferenceType *)this)->PointeeType,view(cpp)} && - - *(clang::Type *)this, view(cmn) - PointeeType - - - - {ModifiedType} Attribute={(clang::AttributedType::Kind)AttributedTypeBits.AttrKind} - - - - - {(clang::Decl::Kind)DeclKind,en}Decl - - (clang::Decl::Kind)DeclKind,en - - - - - FirstDecl - (clang::Decl *)(NextInContextAndBits.Value & ~3) - *this - - - - - - - Field {{{*(clang::DeclaratorDecl *)this,view(cpp)nd}}} - - - {*(clang::FunctionDecl *)this,nd} - Method {{{*this,view(cpp)}}} - - - Constructor {{{Name,view(cpp)}({*(clang::FunctionDecl *)this,view(parm0)nd})}} - - - Destructor {{~{Name,view(cpp)}()}} - - - {Name,view(cpp)} - {Name} - - - implicit{" ",sb} - - {*this,view(implicit)} - {*this,view(modifiers)}{Name,view(cpp)} - {*this,view(modifiers)}struct {Name,view(cpp)} - {*this,view(modifiers)}interface {Name,view(cpp)} - {*this,view(modifiers)}union {Name,view(cpp)} - {*this,view(modifiers)}class {Name,view(cpp)} - {*this,view(modifiers)}enum {Name,view(cpp)} - - (clang::DeclContext *)this - - - - {*decl,view(cpp)} - {*decl} - - *(clang::Type *)this, view(cmn) - decl - - - - {*(clang::TagType *)this,view(cpp)} - {*(clang::TagType *)this} - - *(clang::TagType *)this - - - - {*Replaced,view(cpp)} <= {CanonicalType,view(cpp)} - - *(clang::Type *)this, view(cmn) - *Replaced - - - - - {ResultType,view(cpp)} - - {*(clang::QualType *)(this+1),view(cpp)}{*this,view(parm1)} - - , {*((clang::QualType *)(this+1)+1),view(cpp)}{*this,view(parm2)} - - , {*((clang::QualType *)(this+1)+2),view(cpp)}{*this,view(parm3)} - - , {*((clang::QualType *)(this+1)+3),view(cpp)}{*this,view(parm4)} - - , {*((clang::QualType *)(this+1)+4),view(cpp)}{*this,view(parm5)} - - , /* expand for more params */ - {*this,view(retType)}({*this,view(parm0)}) - - ResultType - - {*this,view(parm0)} - - - NumParams - (clang::QualType *)(this+1) - - - - *(clang::Type *)this, view(cmn) - - - - typename {*TTPDecl,view(cpp)} - - - - {*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType,view(poly)}{*this,view(fastQuals)} - {*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType,view(cpp)}{*this,view(fastQuals)} - - - {" ",sb}const - {" ",sb}restrict - {" ",sb}const restrict - {" ",sb}volatile - {" ",sb}const volatile - {" ",sb}volatile restrict - {" ",sb}const volatile restrict - Cannot visualize non-fast qualifiers - {*((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType}{*this,view(fastQuals)} - - *this,view(fastQuals) - *((clang::ExtQualsTypeCommonBase *)(((uintptr_t)Value.Value) & ~(uintptr_t)((1 << 4) - 1)))->BaseType - - - - {Argument} - - Argument - - - - {(clang::TemplateArgument::ArgKind)TypeOrValue.Kind,en} template parameter: {*(clang::QualType *)&TypeOrValue.V} - - *(clang::QualType *)&TypeOrValue.V - - - - - - void - bool - char - unsigned char - wchar_t - char16_t - char32_t - unsigned short - unsigned int - unsigned long - unsigned long long - __uint128_t - char - signed char - wchar_t - short - int - long - long long - __int128_t - __fp16 - float - double - long double - nullptr_t - {(clang::BuiltinType::Kind)BuiltinTypeBits.Kind, en} - - (clang::BuiltinType::Kind)BuiltinTypeBits.Kind - - - - - {(clang::TemplateDecl *)((Template.Storage.Val.Val.Value >> 2) << 2)} - {Template.Storage} - - - {((llvm::StringMapEntry<clang::IdentifierInfo *>*)Entry)+1,sb} - - ((llvm::StringMapEntry<clang::IdentifierInfo *>*)Entry)+1,s - (clang::tok::TokenKind)TokenID - - - - - Empty - {*(clang::IdentifierInfo *)(Ptr & ~PtrMask)} - {{Identifier ({*(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}} - {{ObjC Zero Arg Selector (*{(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}} - {{ObjC One Arg Selector (*{(clang::IdentifierInfo *)(Ptr & ~PtrMask)})}} - {*(clang::DeclarationNameExtra *)(Ptr & ~PtrMask),view(cpp)} - {{Extra ({*(clang::DeclarationNameExtra *)(Ptr & ~PtrMask)})}} - - *(clang::IdentifierInfo *)(Ptr & ~PtrMask) - *(clang::IdentifierInfo *)(Ptr & ~PtrMask) - *(clang::IdentifierInfo *)(Ptr & ~PtrMask) - (clang::DeclarationNameExtra *)(Ptr & ~PtrMask) - - - - {((clang::CXXSpecialName *)this)->Type,view(cpp)} - {(clang::DeclarationNameExtra::ExtraKind)ExtraKindOrNumArgs,en}{" ",sb}{*this,view(cpp)} - - - {(clang::tok::TokenKind)Kind,en} - {{Identifier ({*(clang::IdentifierInfo *)(PtrData)})}} - - - [{(clang::DeclSpec::SCS)StorageClassSpec}], [{(clang::TypeSpecifierType)TypeSpecType}] - - - {Name,s} - - - {Name,s} - - - {Name,s} - - - - (clang::StorageClass)SClass - (clang::ThreadStorageClassSpecifier)TSCSpec - (clang::VarDecl::InitializationStyle)InitStyle - - - - {DeclType,view(cpp)} {Name,view(cpp)} - - - {*(DeclaratorDecl*)this,nd} - - *(DeclaratorDecl*)this,nd - VarDeclBits - - - - {*(VarDecl*)this,nd} - - ParmVarDeclBits - *(VarDecl*)this,nd - - - - {*(clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType,view(retType)} - - {*ParamInfo[0]}{*this,view(parm1)nd} - - , {*ParamInfo[1]}{*this,view(parm2)nd} - - , {*ParamInfo[2]}{*this,view(parm3)nd} - - , {*ParamInfo[3]}{*this,view(parm4)nd} - - , {*ParamInfo[4]}{*this,view(parm5)nd} - - , /* expand for more params */ - {*this,view(retType)nd} {Name,view(cpp)nd}({*this,view(parm0)nd}) - - *this,view(retType)nd - - {*this,view(parm0)nd} - - - ((clang::FunctionProtoType *)((clang::ExtQualsTypeCommonBase *)(((uintptr_t)DeclType.Value.Value) & ~15))->BaseType)->NumParams - ParamInfo - - - - *(clang::Type *)this, view(cmn) - - - - {($T1 *)Ptr - - ($T1 *)Ptr - - - Index: www/hacking.html =================================================================== --- www/hacking.html +++ www/hacking.html @@ -98,14 +98,16 @@

The files - - utils/llvm.natvis and - - utils/clang.natvis provide debugger visualizers + + utils/LLVMVisualizers/llvm.natvis and + + utils/ClangVisualizers/clang.natvis provide debugger visualizers that make debugging of more complex data types much easier.

-

Put the files into - %USERPROFILE%\Documents\Visual Studio 2012\Visualizers or +

For Visual Studio 2013 only, put the files into + %USERPROFILE%\Documents\Visual Studio 2013\Visualizers or create a symbolic link so they update automatically.

+

For later versions of Visual Studio, no installation is required. + Note also that later versions of Visual Studio also display better visualizations.

Testing