From 139ca9630d2f4978e3ec97ab57097dcf6991bbe7 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Mon, 28 Feb 2011 01:28:05 +0000 Subject: [PATCH] [analyzer] Migrate AdjustedReturnValueChecker to CheckerV2. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126624 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Checkers/AdjustedReturnValueChecker.cpp | 29 ++++++++----------- lib/StaticAnalyzer/Checkers/Checkers.td | 4 +++ lib/StaticAnalyzer/Checkers/ExprEngine.cpp | 1 - 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 { + public CheckerV2< check::PostStmt > { 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(); +} 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); -- 2.40.0