Tutorial
Invoking the BoostCon tool:
$ clang -cc1 -boostcon t.cpp
Teach the BoostCon action to identify and print C++ classes:
bool VisitCXXRecordDecl(CXXRecordDecl *D) {
std::cout << D->getNameAsString()
<< '\n';
return false;
}
Walk and print base classes of a class:
for(CXXRecordDecl::base_class_iterator
B = D->bases_begin(), BEnd = D->bases_end();
B != BEnd; ++B) {
QualType BaseType = B->getType();
std::cout << " " << BaseType.getAsString()
<< '\n';
}
Retrieve the C++ class declaration from a base type:
if (const RecordType *RTy
= BaseType->getAs<RecordType>()) {
RecordDecl *Base = RTy->getDecl();
if (CXXRecordDecl *BaseCXX
= dyn_cast<CXXRecordDecl>(Base)) {
}
}