[cfe-commits] r126624 - in /cfe/trunk/lib/StaticAnalyzer/Checkers: AdjustedReturnValueChecker.cpp Checkers.td ExprEngine.cpp InternalChecks.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Sun Feb 27 17:28:05 PST 2011
Author: akirtzidis
Date: Sun Feb 27 19:28:05 2011
New Revision: 126624
URL: http://llvm.org/viewvc/llvm-project?rev=126624&view=rev
Log:
[analyzer] Migrate AdjustedReturnValueChecker to CheckerV2.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/AdjustedReturnValueChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/InternalChecks.h
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/AdjustedReturnValueChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/AdjustedReturnValueChecker.cpp?rev=126624&r1=126623&r2=126624&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/AdjustedReturnValueChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/AdjustedReturnValueChecker.cpp Sun Feb 27 19:28:05 2011
@@ -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 @@
C.generateNode(state->BindExpr(CE, V));
}
}
+
+void ento::registerAdjustedReturnValueChecker(CheckerManager &mgr) {
+ mgr.registerChecker<AdjustedReturnValueChecker>();
+}
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td?rev=126624&r1=126623&r2=126624&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/Checkers.td Sun Feb 27 19:28:05 2011
@@ -75,6 +75,10 @@
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">;
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp?rev=126624&r1=126623&r2=126624&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp Sun Feb 27 19:28:05 2011
@@ -319,7 +319,6 @@
// 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);
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/InternalChecks.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/InternalChecks.h?rev=126624&r1=126623&r2=126624&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/InternalChecks.h (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/InternalChecks.h Sun Feb 27 19:28:05 2011
@@ -22,7 +22,6 @@
class ExprEngine;
// Foundational checks that handle basic semantics.
-void RegisterAdjustedReturnValueChecker(ExprEngine &Eng);
void RegisterCallAndMessageChecker(ExprEngine &Eng);
void RegisterDereferenceChecker(ExprEngine &Eng);
More information about the cfe-commits
mailing list