[cfe-commits] r87093 - in /cfe/trunk/lib/Analysis: GRExprEngineExperimentalChecks.cpp GRExprEngineExperimentalChecks.h MallocChecker.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Thu Nov 12 23:25:27 PST 2009
Author: zhongxingxu
Date: Fri Nov 13 01:25:27 2009
New Revision: 87093
URL: http://llvm.org/viewvc/llvm-project?rev=87093&view=rev
Log:
Hook up Malloc checker.
Modified:
cfe/trunk/lib/Analysis/GRExprEngineExperimentalChecks.cpp
cfe/trunk/lib/Analysis/GRExprEngineExperimentalChecks.h
cfe/trunk/lib/Analysis/MallocChecker.cpp
Modified: cfe/trunk/lib/Analysis/GRExprEngineExperimentalChecks.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngineExperimentalChecks.cpp?rev=87093&r1=87092&r2=87093&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngineExperimentalChecks.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngineExperimentalChecks.cpp Fri Nov 13 01:25:27 2009
@@ -19,5 +19,6 @@
void clang::RegisterExperimentalChecks(GRExprEngine &Eng) {
RegisterPthreadLockChecker(Eng);
+ RegisterMallocChecker(Eng);
}
Modified: cfe/trunk/lib/Analysis/GRExprEngineExperimentalChecks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngineExperimentalChecks.h?rev=87093&r1=87092&r2=87093&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngineExperimentalChecks.h (original)
+++ cfe/trunk/lib/Analysis/GRExprEngineExperimentalChecks.h Fri Nov 13 01:25:27 2009
@@ -20,6 +20,7 @@
class GRExprEngine;
void RegisterPthreadLockChecker(GRExprEngine &Eng);
+void RegisterMallocChecker(GRExprEngine &Eng);
} // end clang namespace
#endif
Modified: cfe/trunk/lib/Analysis/MallocChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/MallocChecker.cpp?rev=87093&r1=87092&r2=87093&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/MallocChecker.cpp (original)
+++ cfe/trunk/lib/Analysis/MallocChecker.cpp Fri Nov 13 01:25:27 2009
@@ -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 @@
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 @@
};
}
+void clang::RegisterMallocChecker(GRExprEngine &Eng) {
+ Eng.registerCheck(new MallocChecker());
+}
+
void *MallocChecker::getTag() {
static int x;
return &x;
@@ -124,3 +132,7 @@
const GRState *FreedState = state->set<RegionState>(Sym, Released);
C.addTransition(C.GenerateNode(CE, FreedState));
}
+
+void MallocChecker::EvalDeadSymbols(CheckerContext &C, const Stmt *S,
+ SymbolReaper &SymReaper) {
+}
More information about the cfe-commits
mailing list