This is an archive of the discontinued LLVM Phabricator instance.

Show members of DeclContexts (i.e., class members) in Visual Studio native visualizers
ClosedPublic

Authored by mspertus on Mar 17 2016, 6:59 PM.

Details

Summary

This change shows members of DeclContext objects in the Visual Studio debugger. It will also cast a TagType like a class or a struct to a DeclContext, so its methods and fields are visualized. For example, suppose we have a class

struct A {
  int foo();
};

With this change, the CXXRecordDecl * representing A will be displayed in the Visual Studio debugger as

D                 0x0067ab48 struct A
|- DeclKind       CXXRecord
|- [0]            struct A
|- [1]            Method {foo}
|- [Raw View]     //Remaining fields//

Diff Detail

Event Timeline

mspertus updated this revision to Diff 51009.Mar 17 2016, 6:59 PM
mspertus retitled this revision from to Show members of DeclContexts (i.e., class members) in Visual Studio native visualizers.
mspertus updated this object.
mspertus added reviewers: aaron.ballman, zturner.
mspertus added a subscriber: cfe-commits.
aaron.ballman edited edge metadata.Mar 18 2016, 6:14 AM

Mostly LGTM with one question about a comment.

clang.natvis
77

The only hard-wiring I see uses 3 bits, so is this comment still accurate?

I think the code is correct as written, see response in comment

clang.natvis
77

I think the code is correct.

llvm::PointerIntPair<Decl *, 2, unsigned> NextInContextAndBits;

so NextInContextAndBits uses 2 bits for the int part. Just to be sure, I also double checked in the debugger (an IntMask of 3 represents two bits :) ),

		((((clang::DeclContext *)(clang::CXXRecordDecl *)D)->FirstDecl)->NextInContextAndBits).IntMask	IntMask (3)	llvm::PointerIntPair<clang::Decl *,2,unsigned int,llvm::PointerLikeTypeTraits<clang::Decl *> >::<unnamed-enum-PointerBitMask>
aaron.ballman accepted this revision.Mar 18 2016, 8:56 AM
aaron.ballman edited edge metadata.

LGTM!

clang.natvis
77

Oh yeah, that's right, an IntMask of 3 does represent 2 bits. Sorry for the confusion!

This revision is now accepted and ready to land.Mar 18 2016, 8:56 AM
mspertus closed this revision.Mar 18 2016, 9:44 AM

Thanks, Aaron. Committed as revision 263794