How to iterate the members of AccessSpecDecl object.

How to get the source location of the AccessSpecifer using a CXXMethodDecl,


using a AccessSpecDecl object how to traverse the members under it.

Just walk through the members of the class declaration (i.e., a CXXRecordDecl) with decls_begin()/decls_end(), which come in source order. When you see an AccessSpecDecl, make that the “current” access specification decl, which specifies the access of all of the declarations that follow (until the next AccessSpecDecl, of course).

  • Doug

The documentation of AccessSpecDecl says

AccessSpecDecl - An access specifier followed by a colon ‘:’.

An objects of this class represents sugar for the syntactic occurence
of an access specifier followed by a colon in the list of member
specifiers of a C++ class definition.

Note that they do not repesent other uses of access specifiers,
such as those occuring in a list of base specifiers.
Also note that this class has nothing to do with so-called
“access declarations” (C++98 11.3 [class.access.dcl]).

Does the documentation has to be updated. ?

No, that documentation is perfectly accurate.

  • Doug