// the value is rather arbitrary, but code above this number of stmts begins to // be smelly staticconstint stmtlimit = 20;
namespace loplugin
{
struct WalkCounter
{ int stmtcount; bool cascading; bool conditionals;
};
// Ctor, nothing special, pass the argument(s).
CascadingAssignOp::CascadingAssignOp( const InstantiationData& data )
: FilteringPlugin( data )
{
}
// Perform the actual action. void CascadingAssignOp::run()
{ // Traverse the whole AST of the translation unit (i.e. examine the whole source file). // The Clang AST helper class will call VisitReturnStmt for every return statement.
TraverseDecl( compiler.getASTContext().getTranslationUnitDecl());
}
void CascadingAssignOp::Walk( const Stmt* stmt, WalkCounter& c )
{ for(Stmt::const_child_iterator it = stmt->child_begin(); it != stmt->child_end(); ++it)
{
++c.stmtcount; const BinaryOperator* binop = dyn_cast< BinaryOperator >( *it ); if ( binop )
{ if ( (binop->isAssignmentOp() || binop->isCompoundAssignmentOp()))
c.cascading = true; if ( dyn_cast< AbstractConditionalOperator >( binop ) || binop->isLogicalOp())
c.conditionals = true;
}
Walk(*it, c);
}
}
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.