diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-11-11 05:50:44 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-11-11 05:50:44 +0000 |
commit | f493f49fae3ab242ae055ae00b24fa5512655e15 (patch) | |
tree | e10570319a28938d4e2971a68b7ffc5a992c725e /lib | |
parent | d8daaa7450535e101d3155fb939b0914278987c4 (diff) |
Remove public headers for UndefinedArgChecker, AttrNonNullChecker, and BadCallChecker, making their implementations completely private.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86809 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/AttrNonNullChecker.cpp | 22 | ||||
-rw-r--r-- | lib/Analysis/BadCallChecker.cpp | 23 | ||||
-rw-r--r-- | lib/Analysis/GRExprEngineInternalChecks.cpp | 9 | ||||
-rw-r--r-- | lib/Analysis/GRExprEngineInternalChecks.h | 3 | ||||
-rw-r--r-- | lib/Analysis/UndefinedArgChecker.cpp | 22 |
5 files changed, 60 insertions, 19 deletions
diff --git a/lib/Analysis/AttrNonNullChecker.cpp b/lib/Analysis/AttrNonNullChecker.cpp index 1cf5d0c4af..01e1a1fcf6 100644 --- a/lib/Analysis/AttrNonNullChecker.cpp +++ b/lib/Analysis/AttrNonNullChecker.cpp @@ -12,14 +12,28 @@ // //===----------------------------------------------------------------------===// -#include "clang/Analysis/PathSensitive/Checkers/AttrNonNullChecker.h" +#include "clang/Analysis/PathSensitive/CheckerVisitor.h" #include "clang/Analysis/PathSensitive/BugReporter.h" +#include "GRExprEngineInternalChecks.h" using namespace clang; -void *AttrNonNullChecker::getTag() { - static int x = 0; - return &x; +namespace { +class VISIBILITY_HIDDEN AttrNonNullChecker + : public CheckerVisitor<AttrNonNullChecker> { + BugType *BT; +public: + AttrNonNullChecker() : BT(0) {} + static void *getTag() { + static int x = 0; + return &x; + } + void PreVisitCallExpr(CheckerContext &C, const CallExpr *CE); +}; +} // end anonymous namespace + +void clang::RegisterAttrNonNullChecker(GRExprEngine &Eng) { + Eng.registerCheck(new AttrNonNullChecker()); } void AttrNonNullChecker::PreVisitCallExpr(CheckerContext &C, diff --git a/lib/Analysis/BadCallChecker.cpp b/lib/Analysis/BadCallChecker.cpp index 33bb5158d2..4175e8d141 100644 --- a/lib/Analysis/BadCallChecker.cpp +++ b/lib/Analysis/BadCallChecker.cpp @@ -12,14 +12,27 @@ // //===----------------------------------------------------------------------===// -#include "clang/Analysis/PathSensitive/Checkers/BadCallChecker.h" +#include "clang/Analysis/PathSensitive/CheckerVisitor.h" #include "clang/Analysis/PathSensitive/BugReporter.h" +#include "GRExprEngineInternalChecks.h" using namespace clang; -void *BadCallChecker::getTag() { - static int x = 0; - return &x; +namespace { +class VISIBILITY_HIDDEN BadCallChecker : public CheckerVisitor<BadCallChecker> { + BuiltinBug *BT; +public: + BadCallChecker() : BT(0) {} + static void *getTag() { + static int x = 0; + return &x; + } + void PreVisitCallExpr(CheckerContext &C, const CallExpr *CE); +}; +} // end anonymous namespace + +void clang::RegisterBadCallChecker(GRExprEngine &Eng) { + Eng.registerCheck(new BadCallChecker()); } void BadCallChecker::PreVisitCallExpr(CheckerContext &C, const CallExpr *CE) { @@ -29,7 +42,7 @@ void BadCallChecker::PreVisitCallExpr(CheckerContext &C, const CallExpr *CE) { if (L.isUndef() || isa<loc::ConcreteInt>(L)) { if (ExplodedNode *N = C.GenerateNode(CE, true)) { if (!BT) - BT = new BuiltinBug(0, "Invalid function call", + BT = new BuiltinBug("Invalid function call", "Called function pointer is a null or undefined pointer value"); EnhancedBugReport *R = diff --git a/lib/Analysis/GRExprEngineInternalChecks.cpp b/lib/Analysis/GRExprEngineInternalChecks.cpp index 66e021095a..447dfc08bf 100644 --- a/lib/Analysis/GRExprEngineInternalChecks.cpp +++ b/lib/Analysis/GRExprEngineInternalChecks.cpp @@ -16,10 +16,7 @@ #include "clang/Analysis/PathSensitive/BugReporter.h" #include "clang/Analysis/PathSensitive/GRExprEngine.h" #include "clang/Analysis/PathSensitive/CheckerVisitor.h" -#include "clang/Analysis/PathSensitive/Checkers/BadCallChecker.h" -#include "clang/Analysis/PathSensitive/Checkers/UndefinedArgChecker.h" #include "clang/Analysis/PathSensitive/Checkers/UndefinedAssignmentChecker.h" -#include "clang/Analysis/PathSensitive/Checkers/AttrNonNullChecker.h" #include "clang/Analysis/PathDiagnostic.h" #include "clang/Basic/SourceManager.h" #include "llvm/Support/Compiler.h" @@ -400,11 +397,11 @@ void GRExprEngine::RegisterInternalChecks() { // their associated BugType will get registered with the BugReporter // automatically. Note that the check itself is owned by the GRExprEngine // object. - registerCheck(new AttrNonNullChecker()); - registerCheck(new UndefinedArgChecker()); registerCheck(new UndefinedAssignmentChecker()); - registerCheck(new BadCallChecker()); + RegisterAttrNonNullChecker(*this); + RegisterUndefinedArgChecker(*this); + RegisterBadCallChecker(*this); RegisterDereferenceChecker(*this); RegisterVLASizeChecker(*this); RegisterDivZeroChecker(*this); diff --git a/lib/Analysis/GRExprEngineInternalChecks.h b/lib/Analysis/GRExprEngineInternalChecks.h index 7ee1c2a1b5..22151a12ef 100644 --- a/lib/Analysis/GRExprEngineInternalChecks.h +++ b/lib/Analysis/GRExprEngineInternalChecks.h @@ -19,6 +19,8 @@ namespace clang { class GRExprEngine; +void RegisterAttrNonNullChecker(GRExprEngine &Eng); +void RegisterBadCallChecker(GRExprEngine &Eng); void RegisterDereferenceChecker(GRExprEngine &Eng); void RegisterDivZeroChecker(GRExprEngine &Eng); void RegisterReturnPointerRangeChecker(GRExprEngine &Eng); @@ -29,6 +31,7 @@ void RegisterPointerSubChecker(GRExprEngine &Eng); void RegisterPointerArithChecker(GRExprEngine &Eng); void RegisterFixedAddressChecker(GRExprEngine &Eng); void RegisterCastToStructChecker(GRExprEngine &Eng); +void RegisterUndefinedArgChecker(GRExprEngine &Eng); } // end clang namespace #endif diff --git a/lib/Analysis/UndefinedArgChecker.cpp b/lib/Analysis/UndefinedArgChecker.cpp index 549c3b5fe9..43b4847cc4 100644 --- a/lib/Analysis/UndefinedArgChecker.cpp +++ b/lib/Analysis/UndefinedArgChecker.cpp @@ -12,14 +12,28 @@ // //===----------------------------------------------------------------------===// -#include "clang/Analysis/PathSensitive/Checkers/UndefinedArgChecker.h" +#include "clang/Analysis/PathSensitive/CheckerVisitor.h" #include "clang/Analysis/PathSensitive/BugReporter.h" +#include "GRExprEngineInternalChecks.h" using namespace clang; -void *UndefinedArgChecker::getTag() { - static int x = 0; - return &x; +namespace { +class VISIBILITY_HIDDEN UndefinedArgChecker + : public CheckerVisitor<UndefinedArgChecker> { + BugType *BT; +public: + UndefinedArgChecker() : BT(0) {} + static void *getTag() { + static int x = 0; + return &x; + } + void PreVisitCallExpr(CheckerContext &C, const CallExpr *CE); +}; +} // end anonymous namespace + +void clang::RegisterUndefinedArgChecker(GRExprEngine &Eng) { + Eng.registerCheck(new UndefinedArgChecker()); } void UndefinedArgChecker::PreVisitCallExpr(CheckerContext &C, |