diff options
-rw-r--r-- | include/clang/Analysis/PathSensitive/Checkers/AttrNonNullChecker.h | 28 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/Checkers/BadCallChecker.h | 30 | ||||
-rw-r--r-- | include/clang/Analysis/PathSensitive/Checkers/UndefinedArgChecker.h | 34 | ||||
-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 |
8 files changed, 60 insertions, 111 deletions
diff --git a/include/clang/Analysis/PathSensitive/Checkers/AttrNonNullChecker.h b/include/clang/Analysis/PathSensitive/Checkers/AttrNonNullChecker.h deleted file mode 100644 index 007ec093b2..0000000000 --- a/include/clang/Analysis/PathSensitive/Checkers/AttrNonNullChecker.h +++ /dev/null @@ -1,28 +0,0 @@ -//===--- AttrNonNullChecker.h - Undefined arguments 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 AttrNonNullChecker, a builtin check in GRExprEngine that -// performs checks for arguments declared to have nonnull attribute. -// -//===----------------------------------------------------------------------===// - -#include "clang/Analysis/PathSensitive/CheckerVisitor.h" - -namespace clang { - -class AttrNonNullChecker : public CheckerVisitor<AttrNonNullChecker> { - BugType *BT; - -public: - AttrNonNullChecker() : BT(0) {} - static void *getTag(); - void PreVisitCallExpr(CheckerContext &C, const CallExpr *CE); -}; - -} diff --git a/include/clang/Analysis/PathSensitive/Checkers/BadCallChecker.h b/include/clang/Analysis/PathSensitive/Checkers/BadCallChecker.h deleted file mode 100644 index 70f3c44165..0000000000 --- a/include/clang/Analysis/PathSensitive/Checkers/BadCallChecker.h +++ /dev/null @@ -1,30 +0,0 @@ -//===--- BadCallChecker.h - Bad call 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 BadCallChecker, a builtin check in GRExprEngine that performs -// checks for bad callee at call sites. -// -//===----------------------------------------------------------------------===// - -#include "clang/Analysis/PathSensitive/CheckerVisitor.h" - -namespace clang { - -class BadCallChecker : public CheckerVisitor<BadCallChecker> { - BuiltinBug *BT; - -public: - BadCallChecker() : BT(0) {} - - static void *getTag(); - - void PreVisitCallExpr(CheckerContext &C, const CallExpr *CE); -}; - -} diff --git a/include/clang/Analysis/PathSensitive/Checkers/UndefinedArgChecker.h b/include/clang/Analysis/PathSensitive/Checkers/UndefinedArgChecker.h deleted file mode 100644 index 7f4e7d524f..0000000000 --- a/include/clang/Analysis/PathSensitive/Checkers/UndefinedArgChecker.h +++ /dev/null @@ -1,34 +0,0 @@ -//===--- UndefinedArgChecker.h - Undefined arguments 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 BadCallChecker, a builtin check in GRExprEngine that performs -// checks for undefined arguments. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_UNDEFARGCHECKER -#define LLVM_CLANG_UNDEFARGCHECKER - -#include "clang/Analysis/PathSensitive/CheckerVisitor.h" - -namespace clang { - -class UndefinedArgChecker : public CheckerVisitor<UndefinedArgChecker> { - BugType *BT; - -public: - UndefinedArgChecker() : BT(0) {} - - static void *getTag(); - - void PreVisitCallExpr(CheckerContext &C, const CallExpr *CE); -}; - -} -#endif 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, |