Determine field or member function visibility


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 ?




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

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