[cfe-dev] Process in UncheckedReturn

章磊 ioripolo at gmail.com
Mon May 30 22:48:56 PDT 2011


Hi clang,

About the path explotion problems, I think it's a big job. So IMO i should
get involved in it later.
Here is another problem, it's about how to store path information.
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:

typedef llvm::DenseMap<const CallExpr*, bool > LocalMapTy;
// The "local" DenseMap to record checked/unchecked state of all CallExprs
in
// one path.
LocalMapTy *LocalPathMap;

// The "local" DenseMap to record checked/unchecked state of all CallExpr
// uses.
LocalMapTy *LocalUseMap;

// First int indicates the checked count, and the secnd indicates the
// unchecked count.
typedef llvm::DenseMap<const NamedDecl*, std::pair<int, int> > GlobalMapTy;
// The "global" DenseMap to keep statistics of a callee decl.
GlobalMapTy *GlobalMap;

// The visited map to record whether a function body was already analyzed.
typedef llvm::DenseMap<const NamedDecl*, bool> VisitedMapTy;
VisitedMapTy *VisitedMap;

And a struct to keep checkedreturn information in GRState:

struct CheckedReturnState {
enum Kind { Unchecked, Checked } K;
const Stmt *S;
...
};

My process:

   1. While we do path simulation, record CheckedReturnState in GRState. And
   update it to LocalPathMap at some program point(checkdeadsymbol, endpath,
   brach).
   2. 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.
   3. If we use LocalPathMap, update the GlobalMap in checkEndPath; if
   LocalUseMap, update the GlobalMap in checkEndAnalysis.
   4. In checkEndOfTranslationUnit, do the math and emit bug report.


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:

   1. 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?
   2. Keep the <CE, CheckedReturnState> in GRState, so we get it over. But
   how to effectively keep these information.

I'll appreciate it if there are any advice.

-- 
Best regards!

Lei Zhang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110531/69d1cca3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: UncheckedReturnChecker.cpp
Type: text/x-c++src
Size: 15345 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110531/69d1cca3/attachment.cpp>


More information about the cfe-dev mailing list