[cfe-dev] Question on static analyzer callback: checkBranchCondition()
illiop via cfe-dev
cfe-dev at lists.llvm.org
Mon Nov 19 19:56:47 PST 2018
Hello,
Thanks in advance for any help!
If I have the following code:
void function()
{
int a = 1;
if ( ( a<10 ) && ( a > 20 ) ) // always false
{
}
}
How can I evaluate the whole condition expression '( a<10 ) && ( a > 20 ) ' ?
When I write code like:
class MyChecker : public Checker< check::BranchCOndition >
{
public:
void checkBranchCondition(const Stmt* cond, CheckerContext& ctx) const;
}
I found that checkBranchCondition() only be called back 2 times, once for 'a<10' , once for 'a > 20 '. And it's done. No further call back.
But my goal is to get the 'value' for the whole '( a<10 ) && ( a > 20 ) '.
I tried the following in vain:
1. in checkBranchCondition(), find the 'father' node(it is '( a<10 ) && ( a > 20 ) ' ), and evaluate its 'sval', but the sval is invalid/undifined
2. Use check::PostStmt<CompoundStmt> call back. It does NOT called back at all
3. Use check::PostStmt<Stmt> call back, and try to find the 'father' by : if(isa<IfStmt>(stmt)), useless.
4. Use check::PostStmt<BinaryOperator>, but it still only called back 2 times: once for 'a<10' , once for 'a > 20 '
I am a fresh man in the static analyzer, please help, thanks!
illiop
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181120/49b641f9/attachment.html>
More information about the cfe-dev
mailing list