Clang-AST traversal - How to get class member variables
1 answer
Fields can be retrieved using RecordDecl::fields
(there are also methods that get the start and end iterators of that range) for example. for aCXXRecordDecl
CXXRecordDecl* cl = ...;
for (const auto& field : cl->fields) {
const auto& name = field->getName();
const auto field_cl = field->getType()->getAsCXXRecordDecl();
}
Likewise, you can access methods with methods()
.
+2
source to share