bool ignoreClass(StringRef s)
{ // ignore stuff in the standard library, and UNO stuff we can't touch. if (compat::starts_with(s, "rtl::") || compat::starts_with(s, "sal::")
|| compat::starts_with(s, "com::sun::") || compat::starts_with(s, "std::")
|| compat::starts_with(s, "boost::")
|| s == "OString" || s == "OUString" || s == "bad_alloc")
{ returntrue;
} // ignore instantiations of pointers and arrays if (compat::ends_with(s, "*") || compat::ends_with(s, "]")) { returntrue;
} returnfalse;
}
// check for implicit construction bool MergeClasses::VisitVarDecl( const VarDecl* pVarDecl )
{ if (ignoreLocation(pVarDecl)) { returntrue;
} if (pVarDecl->getType()->isReferenceType()) returntrue;
std::string s = pVarDecl->getType().getUnqualifiedType().getAsString(); if (!ignoreClass(s))
instantiatedSet.insert(s); returntrue;
}
// check for implicit construction bool MergeClasses::VisitFieldDecl( const FieldDecl* pFieldDecl )
{ if (ignoreLocation(pFieldDecl)) { returntrue;
} if (pFieldDecl->getType()->isReferenceType()) returntrue;
std::string s = pFieldDecl->getType().getUnqualifiedType().getAsString(); if (!ignoreClass(s))
instantiatedSet.insert(s); returntrue;
}
bool MergeClasses::VisitCXXConstructExpr( const CXXConstructExpr* pCXXConstructExpr )
{ if (ignoreLocation(pCXXConstructExpr)) { returntrue;
} // ignore calls when a sub-class is constructing its superclass if (pCXXConstructExpr->getConstructionKind() != compat::CXXConstructionKind::Complete) { returntrue;
} const CXXConstructorDecl* pCXXConstructorDecl = pCXXConstructExpr->getConstructor(); const CXXRecordDecl* pParentCXXRecordDecl = pCXXConstructorDecl->getParent();
std::string s = pParentCXXRecordDecl->getQualifiedNameAsString(); if (!ignoreClass(s))
instantiatedSet.insert(s); returntrue;
}
bool MergeClasses::VisitCXXRecordDecl(const CXXRecordDecl* decl)
{ if (ignoreLocation(decl)) { returntrue;
} if (decl->isThisDeclarationADefinition())
{
SourceLocation spellingLocation = compiler.getSourceManager().getSpellingLoc(decl->getBeginLoc()); auto filename = getFilenameOfLocation(spellingLocation);
filename = filename.substr(strlen(SRCDIR));
std::string s = decl->getQualifiedNameAsString(); if (ignoreClass(s)) returntrue;
definitionMap.insert( std::pair<std::string,std::string>(s, filename.str()) ); for (auto it = decl->bases_begin(); it != decl->bases_end(); ++it)
{ const CXXBaseSpecifier spec = *it; // need to look through typedefs, hence the getUnqualifiedDesugaredType
QualType baseType = spec.getType().getDesugaredType(compiler.getASTContext());
childToParentClassSet.insert( std::pair<std::string,std::string>(s, baseType.getAsString()) );
}
} returntrue;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.