forked from OSchip/llvm-project
[analyzer] Migrate OSAtomicChecker to CheckerV2.
llvm-svn: 126610
This commit is contained in:
parent
0a9ce3ec8f
commit
b2cf708395
|
@ -93,6 +93,11 @@ def MacOSXAPIChecker : Checker<"API">,
|
|||
HelpText<"Check for proper uses of various Mac OS X APIs">,
|
||||
DescFile<"MacOSXAPIChecker.cpp">;
|
||||
|
||||
def OSAtomicChecker : Checker<"AtomicCAS">,
|
||||
InPackage<MacOSX>,
|
||||
HelpText<"Evaluate calls to OSAtomic functions">,
|
||||
DescFile<"OSAtomicChecker.cpp">;
|
||||
|
||||
def CFNumberCreateChecker : Checker<"CFNumber">,
|
||||
InPackage<MacOSX>,
|
||||
HelpText<"Check for proper uses of CFNumberCreate">,
|
||||
|
|
|
@ -337,7 +337,6 @@ static void RegisterInternalChecks(ExprEngine &Eng) {
|
|||
// This is not a checker yet.
|
||||
RegisterNoReturnFunctionChecker(Eng);
|
||||
RegisterBuiltinFunctionChecker(Eng);
|
||||
RegisterOSAtomicChecker(Eng);
|
||||
}
|
||||
|
||||
ExprEngine::ExprEngine(AnalysisManager &mgr, TransferFuncs *tf)
|
||||
|
|
|
@ -37,9 +37,6 @@ void RegisterUndefinedArraySubscriptChecker(ExprEngine &Eng);
|
|||
void RegisterUndefinedAssignmentChecker(ExprEngine &Eng);
|
||||
void RegisterVLASizeChecker(ExprEngine &Eng);
|
||||
|
||||
// API checks.
|
||||
void RegisterOSAtomicChecker(ExprEngine &Eng);
|
||||
|
||||
} // end GR namespace
|
||||
|
||||
} // end clang namespace
|
||||
|
|
|
@ -11,8 +11,10 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "InternalChecks.h"
|
||||
#include "clang/StaticAnalyzer/Core/PathSensitive/Checker.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/Basic/Builtins.h"
|
||||
|
||||
using namespace clang;
|
||||
|
@ -20,22 +22,17 @@ using namespace ento;
|
|||
|
||||
namespace {
|
||||
|
||||
class OSAtomicChecker : public Checker {
|
||||
class OSAtomicChecker : public CheckerV2<eval::Call> {
|
||||
public:
|
||||
static void *getTag() { static int tag = 0; return &tag; }
|
||||
virtual bool evalCallExpr(CheckerContext &C, const CallExpr *CE);
|
||||
bool evalCall(const CallExpr *CE, CheckerContext &C) const;
|
||||
|
||||
private:
|
||||
bool evalOSAtomicCompareAndSwap(CheckerContext &C, const CallExpr *CE);
|
||||
static bool evalOSAtomicCompareAndSwap(CheckerContext &C, const CallExpr *CE);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void ento::RegisterOSAtomicChecker(ExprEngine &Eng) {
|
||||
Eng.registerCheck(new OSAtomicChecker());
|
||||
}
|
||||
|
||||
bool OSAtomicChecker::evalCallExpr(CheckerContext &C,const CallExpr *CE) {
|
||||
bool OSAtomicChecker::evalCall(const CallExpr *CE, CheckerContext &C) const {
|
||||
const GRState *state = C.getState();
|
||||
const Expr *Callee = CE->getCallee();
|
||||
SVal L = state->getSVal(Callee);
|
||||
|
@ -201,3 +198,7 @@ bool OSAtomicChecker::evalOSAtomicCompareAndSwap(CheckerContext &C,
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ento::registerOSAtomicChecker(CheckerManager &mgr) {
|
||||
mgr.registerChecker<OSAtomicChecker>();
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-checker=core.experimental -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s
|
||||
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-checker=core.experimental -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
|
||||
// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-checker=core.experimental -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s
|
||||
// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-checker=core.experimental -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
|
||||
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg,macosx.AtomicCAS,core.experimental -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s
|
||||
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg,macosx.AtomicCAS,core.experimental -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
|
||||
// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg,macosx.AtomicCAS,core.experimental -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s
|
||||
// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg,macosx.AtomicCAS,core.experimental -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
|
||||
|
||||
// ==-- FIXME: -analyzer-store=basic fails on this file (false negatives). --==
|
||||
// NOTWORK: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-checker=core.experimental -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s &&
|
||||
// NOTWORK: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-checker=core.experimental -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
|
||||
// NOTWORK: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-checker=core.experimental -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
|
||||
// NOTWORK: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-checker=core.experimental -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s
|
||||
// NOTWORK: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg,macosx.AtomicCAS,core.experimental -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s &&
|
||||
// NOTWORK: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg,macosx.AtomicCAS,core.experimental -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
|
||||
// NOTWORK: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg,macosx.AtomicCAS,core.experimental -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
|
||||
// NOTWORK: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg,macosx.AtomicCAS,core.experimental -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// The following code is reduced using delta-debugging from
|
||||
|
|
Loading…
Reference in New Issue