diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-11-13 07:25:27 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-11-13 07:25:27 +0000 |
commit | 7b76096474b39505cf81573dcfece32f602408ee (patch) | |
tree | a6a55c92f4e4a1ab3ed2f56813baed17a034b6a8 /lib/Analysis/MallocChecker.cpp | |
parent | 9400613b54bf56c317786d778f58f45f1080d619 (diff) |
Hook up Malloc checker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MallocChecker.cpp')
-rw-r--r-- | lib/Analysis/MallocChecker.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Analysis/MallocChecker.cpp b/lib/Analysis/MallocChecker.cpp index cbc115f9da..f007aa65da 100644 --- a/lib/Analysis/MallocChecker.cpp +++ b/lib/Analysis/MallocChecker.cpp @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#include "GRExprEngineExperimentalChecks.h" #include "clang/Analysis/PathSensitive/CheckerVisitor.h" #include "clang/Analysis/PathSensitive/GRState.h" #include "clang/Analysis/PathSensitive/GRStateTrait.h" @@ -33,8 +34,11 @@ class VISIBILITY_HIDDEN MallocChecker : public CheckerVisitor<MallocChecker> { IdentifierInfo *II_free; public: + MallocChecker() : BT_DoubleFree(0) {} static void *getTag(); void PostVisitCallExpr(CheckerContext &C, const CallExpr *CE); + void EvalDeadSymbols(CheckerContext &C,const Stmt *S,SymbolReaper &SymReaper); +private: void MallocMem(CheckerContext &C, const CallExpr *CE); void FreeMem(CheckerContext &C, const CallExpr *CE); }; @@ -59,6 +63,10 @@ namespace clang { }; } +void clang::RegisterMallocChecker(GRExprEngine &Eng) { + Eng.registerCheck(new MallocChecker()); +} + void *MallocChecker::getTag() { static int x; return &x; @@ -124,3 +132,7 @@ void MallocChecker::FreeMem(CheckerContext &C, const CallExpr *CE) { const GRState *FreedState = state->set<RegionState>(Sym, Released); C.addTransition(C.GenerateNode(CE, FreedState)); } + +void MallocChecker::EvalDeadSymbols(CheckerContext &C, const Stmt *S, + SymbolReaper &SymReaper) { +} |