forked from OSchip/llvm-project
[analyzer] Migrate AdjustedReturnValueChecker to CheckerV2.
llvm-svn: 126624
This commit is contained in:
parent
6fff2e3d36
commit
0a5a41d799
|
@ -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>();
|
||||
}
|
||||
|
|
|
@ -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">;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue