Make the implementation of DivZeroChecker private.

llvm-svn: 86288
This commit is contained in:
Ted Kremenek 2009-11-06 20:47:51 +00:00
parent e8e631c912
commit 53a70c055d
4 changed files with 27 additions and 37 deletions

View File

@ -1,28 +0,0 @@
//== DivZeroChecker.h - Division by zero checker ----------------*- C++ -*--==//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This defines DivZeroChecker, a builtin check in GRExprEngine that performs
// checks for division by zeros.
//
//===----------------------------------------------------------------------===//
#include "clang/Analysis/PathSensitive/CheckerVisitor.h"
namespace clang {
class DivZeroChecker : public CheckerVisitor<DivZeroChecker> {
BuiltinBug *BT;
public:
DivZeroChecker() : BT(0) {}
static void *getTag();
void PreVisitBinaryOperator(CheckerContext &C, const BinaryOperator *B);
};
}

View File

@ -12,10 +12,25 @@
//
//===----------------------------------------------------------------------===//
#include "clang/Analysis/PathSensitive/Checkers/DivZeroChecker.h"
#include "clang/Analysis/PathSensitive/CheckerVisitor.h"
#include "GRExprEngineInternalChecks.h"
using namespace clang;
namespace {
class VISIBILITY_HIDDEN DivZeroChecker : public CheckerVisitor<DivZeroChecker> {
BuiltinBug *BT;
public:
DivZeroChecker() : BT(0) {}
static void *getTag();
void PreVisitBinaryOperator(CheckerContext &C, const BinaryOperator *B);
};
} // end anonymous namespace
void clang::RegisterDivZeroChecker(GRExprEngine &Eng) {
Eng.registerCheck(new DivZeroChecker());
}
void *DivZeroChecker::getTag() {
static int x;
return &x;

View File

@ -17,7 +17,6 @@
#include "clang/Analysis/PathSensitive/GRExprEngine.h"
#include "clang/Analysis/PathSensitive/CheckerVisitor.h"
#include "clang/Analysis/PathSensitive/Checkers/DereferenceChecker.h"
#include "clang/Analysis/PathSensitive/Checkers/DivZeroChecker.h"
#include "clang/Analysis/PathSensitive/Checkers/BadCallChecker.h"
#include "clang/Analysis/PathSensitive/Checkers/UndefinedArgChecker.h"
#include "clang/Analysis/PathSensitive/Checkers/UndefinedAssignmentChecker.h"
@ -398,19 +397,22 @@ void GRExprEngine::RegisterInternalChecks() {
BR.Register(new NilReceiverStructRet(this));
BR.Register(new NilReceiverLargerThanVoidPtrRet(this));
RegisterDivZeroChecker(*this);
RegisterReturnStackAddressChecker(*this);
RegisterReturnUndefChecker(*this);
// Note that this must be registered after ReturnStackAddressChecker.
RegisterReturnPointerRangeChecker(*this);
// The following checks do not need to have their associated BugTypes
// explicitly registered with the BugReporter. If they issue any BugReports,
// their associated BugType will get registered with the BugReporter
// automatically. Note that the check itself is owned by the GRExprEngine
// object.
RegisterReturnStackAddressChecker(*this);
RegisterReturnUndefChecker(*this);
RegisterReturnPointerRangeChecker(*this);
// object.
registerCheck(new AttrNonNullChecker());
registerCheck(new UndefinedArgChecker());
registerCheck(new UndefinedAssignmentChecker());
registerCheck(new BadCallChecker());
registerCheck(new DivZeroChecker());
registerCheck(new UndefDerefChecker());
registerCheck(new NullDerefChecker());
registerCheck(new UndefSizedVLAChecker());

View File

@ -19,9 +19,10 @@ namespace clang {
class GRExprEngine;
void RegisterReturnStackAddressChecker(GRExprEngine &Eng);
void RegisterReturnUndefChecker(GRExprEngine &Eng);
void RegisterDivZeroChecker(GRExprEngine &Eng);
void RegisterReturnPointerRangeChecker(GRExprEngine &Eng);
void RegisterReturnStackAddressChecker(GRExprEngine &Eng);
void RegisterReturnUndefChecker(GRExprEngine &Eng);
} // end clang namespace
#endif