Make the VLASizeChecker implementation private, and its creation only known to GRExprEngineInternalChecks.cpp.
llvm-svn: 86292
This commit is contained in:
parent
95239110cd
commit
795c611cfa
|
@ -1,39 +0,0 @@
|
|||
//=== VLASizeChecker.h - Undefined dereference 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 two VLASizeCheckers, a builtin check in GRExprEngine that
|
||||
// performs checks for declaration of VLA of undefined or zero size.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Analysis/PathSensitive/Checker.h"
|
||||
|
||||
namespace clang {
|
||||
|
||||
class UndefSizedVLAChecker : public Checker {
|
||||
BugType *BT;
|
||||
|
||||
public:
|
||||
UndefSizedVLAChecker() : BT(0) {}
|
||||
static void *getTag();
|
||||
ExplodedNode *CheckType(QualType T, ExplodedNode *Pred,
|
||||
const GRState *state, Stmt *S, GRExprEngine &Eng);
|
||||
};
|
||||
|
||||
class ZeroSizedVLAChecker : public Checker {
|
||||
BugType *BT;
|
||||
|
||||
public:
|
||||
ZeroSizedVLAChecker() : BT(0) {}
|
||||
static void *getTag();
|
||||
ExplodedNode *CheckType(QualType T, ExplodedNode *Pred,
|
||||
const GRState *state, Stmt *S, GRExprEngine &Eng);
|
||||
};
|
||||
|
||||
}
|
|
@ -21,7 +21,6 @@
|
|||
#include "clang/Analysis/PathSensitive/Checkers/UndefinedArgChecker.h"
|
||||
#include "clang/Analysis/PathSensitive/Checkers/UndefinedAssignmentChecker.h"
|
||||
#include "clang/Analysis/PathSensitive/Checkers/AttrNonNullChecker.h"
|
||||
#include "clang/Analysis/PathSensitive/Checkers/VLASizeChecker.h"
|
||||
#include "clang/Analysis/PathDiagnostic.h"
|
||||
#include "clang/Basic/SourceManager.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
|
@ -397,13 +396,6 @@ 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
|
||||
|
@ -415,6 +407,12 @@ void GRExprEngine::RegisterInternalChecks() {
|
|||
registerCheck(new BadCallChecker());
|
||||
registerCheck(new UndefDerefChecker());
|
||||
registerCheck(new NullDerefChecker());
|
||||
registerCheck(new UndefSizedVLAChecker());
|
||||
registerCheck(new ZeroSizedVLAChecker());
|
||||
|
||||
RegisterVLASizeChecker(*this);
|
||||
RegisterDivZeroChecker(*this);
|
||||
RegisterReturnStackAddressChecker(*this);
|
||||
RegisterReturnUndefChecker(*this);
|
||||
|
||||
// Note that this must be registered after ReturnStackAddressChecker.
|
||||
RegisterReturnPointerRangeChecker(*this);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ void RegisterDivZeroChecker(GRExprEngine &Eng);
|
|||
void RegisterReturnPointerRangeChecker(GRExprEngine &Eng);
|
||||
void RegisterReturnStackAddressChecker(GRExprEngine &Eng);
|
||||
void RegisterReturnUndefChecker(GRExprEngine &Eng);
|
||||
void RegisterVLASizeChecker(GRExprEngine &Eng);
|
||||
|
||||
} // end clang namespace
|
||||
#endif
|
||||
|
|
|
@ -12,12 +12,40 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Analysis/PathSensitive/Checkers/VLASizeChecker.h"
|
||||
#include "GRExprEngineInternalChecks.h"
|
||||
#include "clang/Analysis/PathSensitive/Checker.h"
|
||||
#include "clang/Analysis/PathSensitive/GRExprEngine.h"
|
||||
#include "clang/Analysis/PathSensitive/BugReporter.h"
|
||||
|
||||
using namespace clang;
|
||||
|
||||
namespace {
|
||||
class VISIBILITY_HIDDEN UndefSizedVLAChecker : public Checker {
|
||||
BugType *BT;
|
||||
|
||||
public:
|
||||
UndefSizedVLAChecker() : BT(0) {}
|
||||
static void *getTag();
|
||||
ExplodedNode *CheckType(QualType T, ExplodedNode *Pred,
|
||||
const GRState *state, Stmt *S, GRExprEngine &Eng);
|
||||
};
|
||||
|
||||
class VISIBILITY_HIDDEN ZeroSizedVLAChecker : public Checker {
|
||||
BugType *BT;
|
||||
|
||||
public:
|
||||
ZeroSizedVLAChecker() : BT(0) {}
|
||||
static void *getTag();
|
||||
ExplodedNode *CheckType(QualType T, ExplodedNode *Pred,
|
||||
const GRState *state, Stmt *S, GRExprEngine &Eng);
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
void clang::RegisterVLASizeChecker(GRExprEngine &Eng) {
|
||||
Eng.registerCheck(new UndefSizedVLAChecker());
|
||||
Eng.registerCheck(new ZeroSizedVLAChecker());
|
||||
}
|
||||
|
||||
void *UndefSizedVLAChecker::getTag() {
|
||||
static int x = 0;
|
||||
return &x;
|
||||
|
|
Loading…
Reference in New Issue