From 695fb502825a53ccd178ec1c85c77929d88acb71 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 17 Feb 2011 21:39:17 +0000 Subject: [PATCH] [analyzer] Pass CheckerManager to the registration functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125777 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../StaticAnalyzer/Core/CheckerManager.h | 6 ++--- .../Checkers/BasicObjCFoundationChecks.cpp | 25 ++++++++++++++++--- .../Checkers/CStringChecker.cpp | 7 +++++- .../Checkers/CastToStructChecker.cpp | 7 +++++- lib/StaticAnalyzer/Checkers/ChrootChecker.cpp | 7 +++++- .../Checkers/ClangSACheckerProvider.cpp | 4 +-- lib/StaticAnalyzer/Checkers/ClangSACheckers.h | 4 +-- .../Checkers/FixedAddressChecker.cpp | 7 +++++- .../Checkers/IdempotentOperationChecker.cpp | 7 +++++- .../Checkers/MacOSXAPIChecker.cpp | 7 +++++- .../Checkers/NSAutoreleasePoolChecker.cpp | 7 +++++- .../Checkers/ObjCAtSyncChecker.cpp | 7 +++++- .../Checkers/ObjCSelfInitChecker.cpp | 7 +++++- .../Checkers/PointerArithChecker.cpp | 7 +++++- .../Checkers/PointerSubChecker.cpp | 7 +++++- .../Checkers/PthreadLockChecker.cpp | 7 +++++- .../Checkers/StackAddrLeakChecker.cpp | 7 +++++- lib/StaticAnalyzer/Checkers/StreamChecker.cpp | 7 +++++- .../Checkers/UnixAPIChecker.cpp | 7 +++++- .../Checkers/UnreachableCodeChecker.cpp | 7 +++++- 20 files changed, 124 insertions(+), 27 deletions(-) diff --git a/include/clang/StaticAnalyzer/Core/CheckerManager.h b/include/clang/StaticAnalyzer/Core/CheckerManager.h index 6a98ed8eeb..0cd10de547 100644 --- a/include/clang/StaticAnalyzer/Core/CheckerManager.h +++ b/include/clang/StaticAnalyzer/Core/CheckerManager.h @@ -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 Funcs; + llvm::SmallVector Funcs; }; } // end ento namespace diff --git a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp index a1037b9713..1b6c528c2f 100644 --- a/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp +++ b/lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp @@ -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); +} diff --git a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp index 1981b87edc..03f9047e96 100644 --- a/lib/StaticAnalyzer/Checkers/CStringChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/CStringChecker.cpp @@ -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. //===----------------------------------------------------------------------===// diff --git a/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp b/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp index ca0a319e53..8ec226abf6 100644 --- a/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/CastToStructChecker.cpp @@ -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); +} diff --git a/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp b/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp index a184dd4622..36e76d0d3c 100644 --- a/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ChrootChecker.cpp @@ -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(); diff --git a/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp b/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp index 17646e07d9..94f200f3e8 100644 --- a/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp +++ b/lib/StaticAnalyzer/Checkers/ClangSACheckerProvider.cpp @@ -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::iterator I = enabledCheckers.begin(), E = enabledCheckers.end(); I != E; ++I) { - checkerMgr.addCheckerRegisterFunction((*I)->RegFunc); + (*I)->RegFunc(checkerMgr); } } diff --git a/lib/StaticAnalyzer/Checkers/ClangSACheckers.h b/lib/StaticAnalyzer/Checkers/ClangSACheckers.h index b01b0f4c54..73239f55b4 100644 --- a/lib/StaticAnalyzer/Checkers/ClangSACheckers.h +++ b/lib/StaticAnalyzer/Checkers/ClangSACheckers.h @@ -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 diff --git a/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp b/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp index b2ef4ffd43..fe628a2512 100644 --- a/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp @@ -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); +} diff --git a/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp b/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp index b8111c44ff..f49b125a60 100644 --- a/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/IdempotentOperationChecker.cpp @@ -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) { diff --git a/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp b/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp index 3cefded877..358be124b9 100644 --- a/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp @@ -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 //===----------------------------------------------------------------------===// diff --git a/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp b/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp index a32fe36e56..9fb89d79fc 100644 --- a/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/NSAutoreleasePoolChecker.cpp @@ -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) { diff --git a/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp index 8285ef4c31..7d440ab17e 100644 --- a/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ObjCAtSyncChecker.cpp @@ -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) { diff --git a/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp index f3810e04ff..4f247ea146 100644 --- a/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ObjCSelfInitChecker.cpp @@ -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 { diff --git a/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp b/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp index 71b0988c2c..741e48bfcb 100644 --- a/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/PointerArithChecker.cpp @@ -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); +} diff --git a/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp b/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp index 496cb9d475..f28fe9a537 100644 --- a/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp @@ -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); +} diff --git a/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp b/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp index e20230a885..34c095f42e 100644 --- a/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp @@ -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 : } // 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) { diff --git a/lib/StaticAnalyzer/Checkers/StackAddrLeakChecker.cpp b/lib/StaticAnalyzer/Checkers/StackAddrLeakChecker.cpp index 7d5da0d0fe..363f4042db 100644 --- a/lib/StaticAnalyzer/Checkers/StackAddrLeakChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/StackAddrLeakChecker.cpp @@ -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) { diff --git a/lib/StaticAnalyzer/Checkers/StreamChecker.cpp b/lib/StaticAnalyzer/Checkers/StreamChecker.cpp index 54792f74bd..2655be28a4 100644 --- a/lib/StaticAnalyzer/Checkers/StreamChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/StreamChecker.cpp @@ -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(); diff --git a/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp b/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp index d7108d432c..a53ebb5ae1 100644 --- a/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp @@ -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. //===----------------------------------------------------------------------===// diff --git a/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp b/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp index 6d72e6fb5e..3038e29c0e 100644 --- a/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/UnreachableCodeChecker.cpp @@ -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) {