diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-28 01:28:05 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-02-28 01:28:05 +0000 |
commit | 139ca9630d2f4978e3ec97ab57097dcf6991bbe7 (patch) | |
tree | b6623a9262fd51d257f0cf87a0a28a3091997a27 | |
parent | bd90076671c8012244bb7e3fd84b6789e47cb199 (diff) |
[analyzer] Migrate AdjustedReturnValueChecker to CheckerV2.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126624 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/StaticAnalyzer/Checkers/AdjustedReturnValueChecker.cpp | 29 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Checkers/Checkers.td | 4 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Checkers/ExprEngine.cpp | 1 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Checkers/InternalChecks.h | 1 |
4 files changed, 16 insertions, 19 deletions
diff --git a/lib/StaticAnalyzer/Checkers/AdjustedReturnValueChecker.cpp b/lib/StaticAnalyzer/Checkers/AdjustedReturnValueChecker.cpp index 8832b053db..cddd35895c 100644 --- a/lib/StaticAnalyzer/Checkers/AdjustedReturnValueChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/AdjustedReturnValueChecker.cpp @@ -13,34 +13,25 @@ // //===----------------------------------------------------------------------===// -#include "InternalChecks.h" +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/CheckerV2.h" +#include "clang/StaticAnalyzer/Core/CheckerManager.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" -#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h" using namespace clang; using namespace ento; namespace { class AdjustedReturnValueChecker : - public CheckerVisitor<AdjustedReturnValueChecker> { + public CheckerV2< check::PostStmt<CallExpr> > { public: - AdjustedReturnValueChecker() {} - - void PostVisitCallExpr(CheckerContext &C, const CallExpr *CE); - - static void *getTag() { - static int x = 0; return &x; - } + void checkPostStmt(const CallExpr *CE, CheckerContext &C) const; }; } -void ento::RegisterAdjustedReturnValueChecker(ExprEngine &Eng) { - Eng.registerCheck(new AdjustedReturnValueChecker()); -} - -void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C, - const CallExpr *CE) { +void AdjustedReturnValueChecker::checkPostStmt(const CallExpr *CE, + CheckerContext &C) const { // Get the result type of the call. QualType expectedResultTy = CE->getType(); @@ -94,3 +85,7 @@ void AdjustedReturnValueChecker::PostVisitCallExpr(CheckerContext &C, C.generateNode(state->BindExpr(CE, V)); } } + +void ento::registerAdjustedReturnValueChecker(CheckerManager &mgr) { + mgr.registerChecker<AdjustedReturnValueChecker>(); +} diff --git a/lib/StaticAnalyzer/Checkers/Checkers.td b/lib/StaticAnalyzer/Checkers/Checkers.td index f3f6e8c10b..3edc3c247a 100644 --- a/lib/StaticAnalyzer/Checkers/Checkers.td +++ b/lib/StaticAnalyzer/Checkers/Checkers.td @@ -75,6 +75,10 @@ def ObjCUnusedIvarsChecker : Checker<"UnusedIvars">, let ParentPackage = Core in { +def AdjustedReturnValueChecker : Checker<"AdjustRet">, + HelpText<"Check to see if the return value of a function call is different than the caller expects">, + DescFile<"AdjustedReturnValueChecker.cpp">; + def AttrNonNullChecker : Checker<"AttrNonNull">, HelpText<"Check for arguments declared to have nonnull attribute">, DescFile<"AttrNonNullChecker.cpp">; diff --git a/lib/StaticAnalyzer/Checkers/ExprEngine.cpp b/lib/StaticAnalyzer/Checkers/ExprEngine.cpp index 6af8c679fe..eb8d9def07 100644 --- a/lib/StaticAnalyzer/Checkers/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Checkers/ExprEngine.cpp @@ -319,7 +319,6 @@ static void RegisterInternalChecks(ExprEngine &Eng) { // their associated BugType will get registered with the BugReporter // automatically. Note that the check itself is owned by the ExprEngine // object. - RegisterAdjustedReturnValueChecker(Eng); // CallAndMessageChecker should be registered before AttrNonNullChecker, // where we assume arguments are not undefined. RegisterCallAndMessageChecker(Eng); diff --git a/lib/StaticAnalyzer/Checkers/InternalChecks.h b/lib/StaticAnalyzer/Checkers/InternalChecks.h index 493d535924..640a191f71 100644 --- a/lib/StaticAnalyzer/Checkers/InternalChecks.h +++ b/lib/StaticAnalyzer/Checkers/InternalChecks.h @@ -22,7 +22,6 @@ namespace ento { class ExprEngine; // Foundational checks that handle basic semantics. -void RegisterAdjustedReturnValueChecker(ExprEngine &Eng); void RegisterCallAndMessageChecker(ExprEngine &Eng); void RegisterDereferenceChecker(ExprEngine &Eng); |