diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-10-31 08:44:33 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-10-31 08:44:33 +0000 |
commit | 246a9ade3e1fd24249c03f1757ed740e35fef0cd (patch) | |
tree | 9a58d3a421ac179a3317b8f927b90d3012594ab8 /lib/Analysis/GRExprEngineInternalChecks.cpp | |
parent | 507eec8d849fd86ac42ebdae2a343f9ab64fb274 (diff) |
Move UndefDerefChecker into its own file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85645 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngineInternalChecks.cpp')
-rw-r--r-- | lib/Analysis/GRExprEngineInternalChecks.cpp | 52 |
1 files changed, 2 insertions, 50 deletions
diff --git a/lib/Analysis/GRExprEngineInternalChecks.cpp b/lib/Analysis/GRExprEngineInternalChecks.cpp index 239d04c09b..bfaf0f0379 100644 --- a/lib/Analysis/GRExprEngineInternalChecks.cpp +++ b/lib/Analysis/GRExprEngineInternalChecks.cpp @@ -16,6 +16,7 @@ #include "clang/Analysis/PathSensitive/GRExprEngine.h" #include "clang/Analysis/PathSensitive/CheckerVisitor.h" #include "clang/Analysis/PathSensitive/Checkers/NullDerefChecker.h" +#include "clang/Analysis/PathSensitive/Checkers/UndefDerefChecker.h" #include "clang/Analysis/PathDiagnostic.h" #include "clang/Basic/SourceManager.h" #include "llvm/Support/Compiler.h" @@ -133,20 +134,6 @@ public: } }; - - -class VISIBILITY_HIDDEN UndefinedDeref : public BuiltinBug { -public: - UndefinedDeref() - : BuiltinBug(0, "Dereference of undefined pointer value") {} - - void registerInitialVisitors(BugReporterContext& BRC, - const ExplodedNode* N, - BuiltinBugReport *R) { - registerTrackNullOrUndefValue(BRC, GetDerefExpr(N), N); - } -}; - class VISIBILITY_HIDDEN DivZero : public BuiltinBug { public: DivZero(GRExprEngine* eng = 0) @@ -753,41 +740,6 @@ void CheckDivZero::PreVisitBinaryOperator(CheckerContext &C, C.addTransition(C.GenerateNode(B, stateNotZero)); } -class VISIBILITY_HIDDEN CheckUndefDeref : public Checker { - UndefinedDeref *BT; -public: - CheckUndefDeref() : BT(0) {} - - ExplodedNode *CheckLocation(const Stmt *S, ExplodedNode *Pred, - const GRState *state, SVal V, GRExprEngine &Eng); - - static void *getTag() { - static int x = 0; - return &x; - } -}; - -ExplodedNode *CheckUndefDeref::CheckLocation(const Stmt *S, ExplodedNode *Pred, - const GRState *state, SVal V, - GRExprEngine &Eng) { - GRStmtNodeBuilder &Builder = Eng.getBuilder(); - BugReporter &BR = Eng.getBugReporter(); - - if (V.isUndef()) { - ExplodedNode *N = Builder.generateNode(S, state, Pred, - ProgramPoint::PostUndefLocationCheckFailedKind); - if (N) { - if (!BT) - BT = new UndefinedDeref(); - - N->markAsSink(); - BR.EmitReport(new BuiltinBugReport(*BT, BT->getDescription().c_str(), N)); - } - return 0; - } - - return Pred; -} } // end clang namespace @@ -821,6 +773,6 @@ void GRExprEngine::RegisterInternalChecks() { registerCheck<CheckUndefinedArg>(new CheckUndefinedArg()); registerCheck<CheckBadCall>(new CheckBadCall()); registerCheck<CheckDivZero>(new CheckDivZero()); - registerCheck<CheckUndefDeref>(new CheckUndefDeref()); + registerCheck<UndefDerefChecker>(new UndefDerefChecker()); registerCheck<NullDerefChecker>(new NullDerefChecker()); } |