Determine field or member function visibility

Hi,

I’m using libtooling and I would like to know if a CXXMethodDecl or FieldDecl is public/private/protected.

This sounds pretty simple but I can’t find in the doc any kind of isPublic/isPrivate/isProtected. There is a getVisibility but it seems related to the linker.

What am I missing ?

Thanks,

David.

Hi,

There are actually AST Matchers which can help you with that. You can also look at the implementation to see how it’s done.

http://clang.llvm.org/docs/LibASTMatchersReference.html → isPrivate, isProtected, isPublic.

What you’re actually looking for is Decl->getAccess().