This is an archive of the discontinued LLVM Phabricator instance.

Add Visual Studio Visualizers for more Clang types
ClosedPublic

Authored by mspertus on Mar 5 2016, 8:47 AM.

Details

Summary

This is the first of a series of patches to add additional Visual Studio native visualizers for subclasses of clang::Type. For example, a SubstTemplateTypeParmType where the template type parameter "T" is replaced by the class "A" will show as follows in the locals window:

Type (1), SubstTemplateTypeParm (30): {Identifier (("T"))} => Record (25), {Identifier (("A"))}

Once this is accepted, I will continue to add further clang Type subclasses

Diff Detail

Event Timeline

mspertus updated this revision to Diff 49879.Mar 5 2016, 8:47 AM
mspertus retitled this revision from to Add Visual Studio Visualizers for more Clang types.
mspertus updated this object.
mspertus added reviewers: aaron.ballman, zturner.
mspertus added a subscriber: cfe-commits.
aaron.ballman added inline comments.Mar 7 2016, 6:21 AM
clang.natvis
1–3

Do you know if these visualizers will work in MSVC 2013 as well, or are you using MSVC 2015-specific features? I ask because 2013 is our base MSVC version currently, so it would be good to know if this will break anyone. If the features work in 2013, we should probably change it from 2012 to 2013 in the comment.

zturner edited edge metadata.Mar 7 2016, 7:05 AM
zturner added a subscriber: zturner.

Better yet, just delete the number

aaron.ballman edited edge metadata.Mar 7 2016, 7:09 AM

Better yet, just delete the number

The number is sort of helpful since it's the only documentation as to what least common denominator we support. I don't have a strong attachment to the number, however.

Natvis has hardly changed at all since it was introduced, so I'm guessing
the lowest common denominator is always going to be our minimum required VS
version

Natvis has hardly changed at all since it was introduced, so I'm guessing
the lowest common denominator is always going to be our minimum required VS
version

Awesome! Sold on removing the date.

I believe that it will all work on VS2013 (and have kicked off a build to confirm). I guess I would rather drop the number so it doesn't get out of sync whenever the base compiler version changes.

Hmm, testing reveals that the preexisting clang.natvis does not work in VS2013!

Natvis: E:\Users\mspertus\Documents\Visual Studio 2013\Visualizers\clang.natvis(59,21): Error: identifier "clang::TypeAlignmentInBits" is undefined

If I change all clang.natvis occurrences of clang::TypeAlignmentInBits to 4, it now works in VS2013 and VS2015, including all my edits. While this kind of hardwiring is brittle, it seems like the best option until we drop VS2013 support.

Is it ok for me to make that change?

Hmm, testing reveals that the preexisting clang.natvis does not work in VS2013!

Natvis: E:\Users\mspertus\Documents\Visual Studio 2013\Visualizers\clang.natvis(59,21): Error: identifier "clang::TypeAlignmentInBits" is undefined

If I change all clang.natvis occurrences of clang::TypeAlignmentInBits to 4, it now works in VS2013 and VS2015, including all my edits. While this kind of hardwiring is brittle, it seems like the best option until we drop VS2013 support.

Is it ok for me to make that change?

Yeah, I think that change makes sense. We can always rectify it when we drop support for MSVC 2013. Good catch!

mspertus updated this revision to Diff 50015.Mar 7 2016, 6:14 PM
mspertus edited edge metadata.

Updated in response to review comments to fix issues around MSVC versions

mspertus updated this revision to Diff 50022.EditedMar 7 2016, 8:38 PM

Based on Eric Feiveson's comment that I can suppress the numeric value of an enum visualization with ", en" I have uploaded a new diff. By suppressing the numeric values, instead of the verbose TemplateArgumentLoc visualization

Type (0x00000001), SubstTemplateTypeParm (0x0000001e): {Identifier (("T"))} => Record (0x00000019), {Identifier (("A"))}

I get the much more readable

Type template parameter: SubstTemplateTypeParm: {Identifier (("T"))} => Record, {Identifier (("A"))}
aaron.ballman accepted this revision.Mar 8 2016, 5:07 AM
aaron.ballman edited edge metadata.

LGTM. thank you!

This revision is now accepted and ready to land.Mar 8 2016, 5:07 AM

Committed, thanks!

mspertus closed this revision.Mar 14 2016, 3:00 PM

Committed as revision 262933