private: // the key is the pair of VarDecl and the type being cast to. struct BlockState
{
std::map<std::pair<VarDecl const*, clang::Type const*>, SourceLocation> staticCastVars;
std::map<std::pair<VarDecl const*, clang::Type const*>, SourceLocation> dynamicCastVars;
}; // only maintain state inside a single basic block, we're not trying to analyse // cross-block interactions.
std::vector<BlockState> blockStack;
BlockState blockState;
};
bool StaticDynamic::VisitCXXStaticCastExpr(CXXStaticCastExpr const* staticCastExpr)
{ if (ignoreLocation(staticCastExpr)) returntrue; auto subExprDecl = dyn_cast<DeclRefExpr>(staticCastExpr->getSubExpr()->IgnoreParenImpCasts()); if (!subExprDecl) returntrue; auto varDecl = dyn_cast_or_null<VarDecl>(subExprDecl->getDecl()); if (!varDecl) returntrue; auto varType = strip(staticCastExpr->getType()); auto it = blockState.dynamicCastVars.find({ varDecl, varType }); if (it != blockState.dynamicCastVars.end())
{
StringRef fn = getFilenameOfLocation(
compiler.getSourceManager().getSpellingLoc(staticCastExpr->getBeginLoc())); // loop if (loplugin::isSamePathname(fn, SRCDIR "/basctl/source/basicide/basobj3.cxx")) returntrue; if (loplugin::isSamePathname(fn, SRCDIR "/sw/source/core/doc/swserv.cxx")) returntrue; if (loplugin::isSamePathname(fn, SRCDIR "/sw/source/core/text/txtfly.cxx")) 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.