[cfe-dev] Static analyzer: check for ForStmt
Siraj, Tareq A
tareq.a.siraj at intel.com
Tue Jun 25 08:10:14 PDT 2013
Hello,
I am new to the static analyzer codebase and wanted to try out some simple checkers on for loops. I noticed that PreStmt ignores control flow e.g. IfStmt and we should be using check::BranchCondition. I tried using check::BranchCondition on for loops and looks like it calls the checkBranchCondition function 4 times for 1 for loop. So,
(1) Is this a bug?
(2) Is check::BranchCondition the right checker to use here?
Thanks.
Sample for loop:
=============
for (int i = 0; i < 10; ++i)
Calling dump() on the statement in checkBranchCondition() produces:
======================================================
BinaryOperator 0x476f540 '_Bool' '<'
|-ImplicitCastExpr 0x476f528 'int' <LValueToRValue>
| `-DeclRefExpr 0x476f4e0 'int' lvalue Var 0x476f450 'i' 'int'
`-IntegerLiteral 0x476f508 'int' 10
BinaryOperator 0x476f540 '_Bool' '<'
|-ImplicitCastExpr 0x476f528 'int' <LValueToRValue>
| `-DeclRefExpr 0x476f4e0 'int' lvalue Var 0x476f450 'i' 'int'
`-IntegerLiteral 0x476f508 'int' 10
BinaryOperator 0x476f540 '_Bool' '<'
|-ImplicitCastExpr 0x476f528 'int' <LValueToRValue>
| `-DeclRefExpr 0x476f4e0 'int' lvalue Var 0x476f450 'i' 'int'
`-IntegerLiteral 0x476f508 'int' 10
BinaryOperator 0x476f540 '_Bool' '<'
|-ImplicitCastExpr 0x476f528 'int' <LValueToRValue>
| `-DeclRefExpr 0x476f4e0 'int' lvalue Var 0x476f450 'i' 'int'
`-IntegerLiteral 0x476f508 'int' 10
--
Tareq A. Siraj
More information about the cfe-dev
mailing list