[cfe-dev] [StaticAnalyzer] False positive unreachable code
Daniel Marjamäki via cfe-dev
cfe-dev at lists.llvm.org
Mon Sep 19 04:36:00 PDT 2016
Hello!
I am looking at a false positive.
Here is a reduced example code:
void f(int e) {
switch (e) {
case 1:
break; // <- FP
case 2:
do { } while (0);
break;
}
}
Clang says that the first "break;" is unreachable.
In UnreachableCodeChecker::checkEndAnalysis() the check will first iterate over the ExplodedGraph and then the CFG. For the example code above the ExplodedGraph and CFG both have nodes for "case E1" but the block numbers are different.
I have made one fix that will work if the block numbers are different. I added a ReachableStmts variable. Does that sounds ok?
Otherwise I'll try to see why the block numbers are different. Are the AnalysisManager::getCFG() and AnalysisDeclContext::getUnoptimizedCFG() supposed to be guaranteed to generate the same block numbers?
Best regards,
Daniel Marjamäki
..................................................................................................................
Daniel Marjamäki Senior Engineer
Evidente ES East AB Warfvinges väg 34 SE-112 51 Stockholm Sweden
Mobile: +46 (0)709 12 42 62
E-mail: Daniel.Marjamaki at evidente.se
www.evidente.se
More information about the cfe-dev
mailing list