parent
a4276b091d
commit
c4902a52a0
|
@ -19,5 +19,6 @@ using namespace clang;
|
|||
|
||||
void clang::RegisterExperimentalChecks(GRExprEngine &Eng) {
|
||||
RegisterPthreadLockChecker(Eng);
|
||||
RegisterMallocChecker(Eng);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ namespace clang {
|
|||
class GRExprEngine;
|
||||
|
||||
void RegisterPthreadLockChecker(GRExprEngine &Eng);
|
||||
void RegisterMallocChecker(GRExprEngine &Eng);
|
||||
|
||||
} // end clang namespace
|
||||
#endif
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue