Hi clang,<br><br>About the path explotion problems, I think it's a big job. So IMO i should get involved in it later. <br>Here is another problem, it's about how to store path information.<br>After the checker ownership changed, i want all the statistic information stored in the checker itself. So i designed some densemaps to store these information:<br>
<br><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">typedef llvm::DenseMap<const CallExpr*, bool > LocalMapTy;<br></font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">// The "local" DenseMap to record checked/unchecked state of all CallExprs in <br>
</font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">// one path.<br></font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">LocalMapTy *LocalPathMap;<br></font></div>
<div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1"><br></font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">// The "local" DenseMap to record checked/unchecked state of all CallExpr<br>
</font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">// uses.<br></font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">LocalMapTy *LocalUseMap;<br></font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);">
<font size="1"><br></font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">// First int indicates the checked count, and the secnd indicates the <br></font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);">
<font size="1">// unchecked count.<br></font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">typedef llvm::DenseMap<const NamedDecl*, std::pair<int, int> > GlobalMapTy;<br></font></div>
<div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">// The "global" DenseMap to keep statistics of a callee decl.<br></font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">GlobalMapTy *GlobalMap;<br>
</font></div>
<div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1"><br></font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">// The visited map to record whether a function body was already analyzed.<br>
</font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);"><font size="1">typedef llvm::DenseMap<const NamedDecl*, bool> VisitedMapTy;<br></font></div><div style="margin-left: 40px; color: rgb(0, 0, 153);">
<font size="1">VisitedMapTy *VisitedMap;<br></font></div><div style="margin-left: 40px;"><br></div>And a struct to keep checkedreturn information in GRState:<br>
<br><div style="margin-left: 40px;"><font size="1"><span style="color: rgb(0, 0, 153);">struct CheckedReturnState {</span><br style="color: rgb(0, 0, 153);"></font><div style="margin-left: 40px; color: rgb(0, 0, 153);">
<font size="1">enum Kind { Unchecked, Checked } K;<br>const Stmt *S;<br>...<br></font></div><font size="1"><span style="color: rgb(0, 0, 153);">}; </span></font><br></div><br>My process:<br><ol><li>While we do path simulation, record CheckedReturnState in GRState. And update it to LocalPathMap at some program point(checkdeadsymbol, endpath, brach).</li>
<li>
While in endpath analysis, analyze LocalPathMap(currently using a pessimistic way, a CE is checked unless it's checked in all the paths), then update the LocalUseMap. Of course, this step is optional.</li><li>If we use LocalPathMap, update the GlobalMap in checkEndPath; if LocalUseMap, update the GlobalMap in checkEndAnalysis.</li>
<li>
In checkEndOfTranslationUnit, do the math and emit bug report.</li></ol><br>Soon i found i was wrong in step 1, i should not use any structure in checker to record path-sensitive states. So i need other ways to handle this:<br>
<ol><li>
It seems ok that only to update LocalPathMap when end path(so we can record in GRState until the path analysis finished), but how should we take care of the dead symbols? Maybe i could keep that dead symbols instead of removing them?</li>
<li>
Keep the <CE, CheckedReturnState> in GRState, so we get it over. But how to effectively keep these information.</li></ol>I'll appreciate it if there are any advice. <br clear="all"><br>-- <br>Best regards!<br>
<br>Lei Zhang<br>