[analyzer] Pass CheckerManager to the registration functions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125777 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Argyrios Kyrtzidis 2011-02-17 21:39:17 +00:00
Родитель 35001ca261
Коммит 695fb50282
20 изменённых файлов: 124 добавлений и 27 удалений

Просмотреть файл

@ -23,16 +23,16 @@ namespace ento {
class CheckerManager {
public:
typedef void (*RegisterFunc)(ExprEngine &Eng);
typedef void (*RegisterToEngFunc)(ExprEngine &Eng);
void addCheckerRegisterFunction(RegisterFunc fn) {
void addCheckerRegisterFunction(RegisterToEngFunc fn) {
Funcs.push_back(fn);
}
void registerCheckersToEngine(ExprEngine &eng);
private:
llvm::SmallVector<RegisterFunc, 8> Funcs;
llvm::SmallVector<RegisterToEngFunc, 8> Funcs;
};
} // end ento namespace

Просмотреть файл

@ -16,6 +16,7 @@
#include "BasicObjCFoundationChecks.h"
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
@ -487,18 +488,34 @@ void ClassReleaseChecker::preVisitObjCMessage(CheckerContext &C,
// Check registration.
//===----------------------------------------------------------------------===//
void ento::registerNilArgChecker(ExprEngine& Eng) {
static void RegisterNilArgChecker(ExprEngine& Eng) {
Eng.registerCheck(new NilArgChecker());
}
void ento::registerCFNumberCreateChecker(ExprEngine& Eng) {
void ento::registerNilArgChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterNilArgChecker);
}
static void RegisterCFNumberCreateChecker(ExprEngine& Eng) {
Eng.registerCheck(new CFNumberCreateChecker());
}
void ento::registerCFRetainReleaseChecker(ExprEngine& Eng) {
void ento::registerCFNumberCreateChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterCFNumberCreateChecker);
}
static void RegisterCFRetainReleaseChecker(ExprEngine& Eng) {
Eng.registerCheck(new CFRetainReleaseChecker());
}
void ento::registerClassReleaseChecker(ExprEngine& Eng) {
void ento::registerCFRetainReleaseChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterCFRetainReleaseChecker);
}
static void RegisterClassReleaseChecker(ExprEngine& Eng) {
Eng.registerCheck(new ClassReleaseChecker());
}
void ento::registerClassReleaseChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterClassReleaseChecker);
}

Просмотреть файл

@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/GRStateTrait.h"
@ -109,10 +110,14 @@ namespace ento {
}
}
void ento::registerCStringChecker(ExprEngine &Eng) {
static void RegisterCStringChecker(ExprEngine &Eng) {
Eng.registerCheck(new CStringChecker());
}
void ento::registerCStringChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterCStringChecker);
}
//===----------------------------------------------------------------------===//
// Individual checks and utility methods.
//===----------------------------------------------------------------------===//

Просмотреть файл

@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
@ -74,6 +75,10 @@ void CastToStructChecker::PreVisitCastExpr(CheckerContext &C,
}
}
void ento::registerCastToStructChecker(ExprEngine &Eng) {
static void RegisterCastToStructChecker(ExprEngine &Eng) {
Eng.registerCheck(new CastToStructChecker());
}
void ento::registerCastToStructChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterCastToStructChecker);
}

Просмотреть файл

@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/GRState.h"
@ -59,10 +60,14 @@ private:
} // end anonymous namespace
void ento::registerChrootChecker(ExprEngine &Eng) {
static void RegisterChrootChecker(ExprEngine &Eng) {
Eng.registerCheck(new ChrootChecker());
}
void ento::registerChrootChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterChrootChecker);
}
bool ChrootChecker::evalCallExpr(CheckerContext &C, const CallExpr *CE) {
const GRState *state = C.getState();
const Expr *Callee = CE->getCallee();

Просмотреть файл

@ -40,7 +40,7 @@ namespace {
struct StaticCheckerInfoRec {
const char *FullName;
CheckerManager::RegisterFunc RegFunc;
void (*RegFunc)(CheckerManager &mgr);
bool Hidden;
};
@ -132,6 +132,6 @@ void ClangSACheckerProvider::registerCheckers(CheckerManager &checkerMgr,
collectCheckers(checkOpts[i], enabledCheckers);
for (llvm::DenseSet<const StaticCheckerInfoRec *>::iterator
I = enabledCheckers.begin(), E = enabledCheckers.end(); I != E; ++I) {
checkerMgr.addCheckerRegisterFunction((*I)->RegFunc);
(*I)->RegFunc(checkerMgr);
}
}

Просмотреть файл

@ -18,11 +18,11 @@
namespace clang {
namespace ento {
class ExprEngine;
class CheckerManager;
#define GET_CHECKERS
#define CHECKER(FULLNAME,CLASS,CXXFILE,HELPTEXT,HIDDEN) \
void register##CLASS(ExprEngine &Eng);
void register##CLASS(CheckerManager &mgr);
#include "Checkers.inc"
#undef CHECKER
#undef GET_CHECKERS

Просмотреть файл

@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
@ -67,6 +68,10 @@ void FixedAddressChecker::PreVisitBinaryOperator(CheckerContext &C,
}
}
void ento::registerFixedAddressChecker(ExprEngine &Eng) {
static void RegisterFixedAddressChecker(ExprEngine &Eng) {
Eng.registerCheck(new FixedAddressChecker());
}
void ento::registerFixedAddressChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterFixedAddressChecker);
}

Просмотреть файл

@ -45,6 +45,7 @@
#include "ClangSACheckers.h"
#include "clang/Analysis/CFGStmtMap.h"
#include "clang/Analysis/Analyses/PseudoConstantAnalysis.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
@ -132,10 +133,14 @@ void *IdempotentOperationChecker::getTag() {
return &x;
}
void ento::registerIdempotentOperationChecker(ExprEngine &Eng) {
static void RegisterIdempotentOperationChecker(ExprEngine &Eng) {
Eng.registerCheck(new IdempotentOperationChecker());
}
void ento::registerIdempotentOperationChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterIdempotentOperationChecker);
}
void IdempotentOperationChecker::PreVisitBinaryOperator(
CheckerContext &C,
const BinaryOperator *B) {

Просмотреть файл

@ -17,6 +17,7 @@
#include "ClangSACheckers.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/GRStateTrait.h"
@ -45,10 +46,14 @@ public:
};
} //end anonymous namespace
void ento::registerMacOSXAPIChecker(ExprEngine &Eng) {
static void RegisterMacOSXAPIChecker(ExprEngine &Eng) {
Eng.registerCheck(new MacOSXAPIChecker());
}
void ento::registerMacOSXAPIChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterMacOSXAPIChecker);
}
//===----------------------------------------------------------------------===//
// dispatch_once and dispatch_once_f
//===----------------------------------------------------------------------===//

Просмотреть файл

@ -16,6 +16,7 @@
//===----------------------------------------------------------------------===//
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
@ -45,7 +46,7 @@ public:
} // end anonymous namespace
void ento::registerNSAutoreleasePoolChecker(ExprEngine &Eng) {
static void RegisterNSAutoreleasePoolChecker(ExprEngine &Eng) {
ASTContext &Ctx = Eng.getContext();
if (Ctx.getLangOptions().getGCMode() != LangOptions::NonGC) {
Eng.registerCheck(new NSAutoreleasePoolChecker(GetNullarySelector("release",
@ -53,6 +54,10 @@ void ento::registerNSAutoreleasePoolChecker(ExprEngine &Eng) {
}
}
void ento::registerNSAutoreleasePoolChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterNSAutoreleasePoolChecker);
}
void
NSAutoreleasePoolChecker::preVisitObjCMessage(CheckerContext &C,
ObjCMessage msg) {

Просмотреть файл

@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Checkers/DereferenceChecker.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
@ -33,12 +34,16 @@ public:
};
} // end anonymous namespace
void ento::registerObjCAtSyncChecker(ExprEngine &Eng) {
static void RegisterObjCAtSyncChecker(ExprEngine &Eng) {
// @synchronized is an Objective-C 2 feature.
if (Eng.getContext().getLangOptions().ObjC2)
Eng.registerCheck(new ObjCAtSyncChecker());
}
void ento::registerObjCAtSyncChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterObjCAtSyncChecker);
}
void ObjCAtSyncChecker::PreVisitObjCAtSynchronizedStmt(CheckerContext &C,
const ObjCAtSynchronizedStmt *S) {

Просмотреть файл

@ -47,6 +47,7 @@
// http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/GRStateTrait.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
@ -92,11 +93,15 @@ public:
};
} // end anonymous namespace
void ento::registerObjCSelfInitChecker(ExprEngine &Eng) {
static void RegisterObjCSelfInitChecker(ExprEngine &Eng) {
if (Eng.getContext().getLangOptions().ObjC1)
Eng.registerCheck(new ObjCSelfInitChecker());
}
void ento::registerObjCSelfInitChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterObjCSelfInitChecker);
}
namespace {
class InitSelfBug : public BugType {

Просмотреть файл

@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
@ -67,6 +68,10 @@ void PointerArithChecker::PreVisitBinaryOperator(CheckerContext &C,
}
}
void ento::registerPointerArithChecker(ExprEngine &Eng) {
static void RegisterPointerArithChecker(ExprEngine &Eng) {
Eng.registerCheck(new PointerArithChecker());
}
void ento::registerPointerArithChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterPointerArithChecker);
}

Просмотреть файл

@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
@ -74,6 +75,10 @@ void PointerSubChecker::PreVisitBinaryOperator(CheckerContext &C,
}
}
void ento::registerPointerSubChecker(ExprEngine &Eng) {
static void RegisterPointerSubChecker(ExprEngine &Eng) {
Eng.registerCheck(new PointerSubChecker());
}
void ento::registerPointerSubChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterPointerSubChecker);
}

Просмотреть файл

@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/GRStateTrait.h"
@ -53,10 +54,14 @@ template <> struct GRStateTrait<LockSet> :
} // end GR namespace
} // end clang namespace
void ento::registerPthreadLockChecker(ExprEngine &Eng) {
static void RegisterPthreadLockChecker(ExprEngine &Eng) {
Eng.registerCheck(new PthreadLockChecker());
}
void ento::registerPthreadLockChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterPthreadLockChecker);
}
void PthreadLockChecker::PostVisitCallExpr(CheckerContext &C,
const CallExpr *CE) {

Просмотреть файл

@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/GRState.h"
@ -41,10 +42,14 @@ private:
};
}
void ento::registerStackAddrLeakChecker(ExprEngine &Eng) {
static void RegisterStackAddrLeakChecker(ExprEngine &Eng) {
Eng.registerCheck(new StackAddrLeakChecker());
}
void ento::registerStackAddrLeakChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterStackAddrLeakChecker);
}
SourceRange StackAddrLeakChecker::GenName(llvm::raw_ostream &os,
const MemRegion *R,
SourceManager &SM) {

Просмотреть файл

@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "ClangSACheckers.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/GRState.h"
@ -114,10 +115,14 @@ namespace ento {
}
}
void ento::registerStreamChecker(ExprEngine &Eng) {
static void RegisterStreamChecker(ExprEngine &Eng) {
Eng.registerCheck(new StreamChecker());
}
void ento::registerStreamChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterStreamChecker);
}
bool StreamChecker::evalCallExpr(CheckerContext &C, const CallExpr *CE) {
const GRState *state = C.getState();
const Expr *Callee = CE->getCallee();

Просмотреть файл

@ -14,6 +14,7 @@
#include "ClangSACheckers.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
#include "llvm/ADT/Optional.h"
@ -46,10 +47,14 @@ public:
};
} //end anonymous namespace
void ento::registerUnixAPIChecker(ExprEngine &Eng) {
static void RegisterUnixAPIChecker(ExprEngine &Eng) {
Eng.registerCheck(new UnixAPIChecker());
}
void ento::registerUnixAPIChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterUnixAPIChecker);
}
//===----------------------------------------------------------------------===//
// Utility functions.
//===----------------------------------------------------------------------===//

Просмотреть файл

@ -17,6 +17,7 @@
#include "clang/AST/ParentMap.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/SourceManager.h"
#include "clang/StaticAnalyzer/Core/CheckerManager.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
@ -54,10 +55,14 @@ void *UnreachableCodeChecker::getTag() {
return &x;
}
void ento::registerUnreachableCodeChecker(ExprEngine &Eng) {
static void RegisterUnreachableCodeChecker(ExprEngine &Eng) {
Eng.registerCheck(new UnreachableCodeChecker());
}
void ento::registerUnreachableCodeChecker(CheckerManager &mgr) {
mgr.addCheckerRegisterFunction(RegisterUnreachableCodeChecker);
}
void UnreachableCodeChecker::VisitEndAnalysis(ExplodedGraph &G,
BugReporter &B,
ExprEngine &Eng) {