зеркало из https://github.com/microsoft/clang-1.git
[analyzer] Use the new registration mechanism on the apple checkers:
NilArgChecker CFNumberCreateChecker NSAutoreleasePoolChecker CFRetainReleaseChecker ClassReleaseChecker git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125636 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
d98abd8c68
Коммит
0b1ba6227c
|
@ -50,7 +50,6 @@ void CheckObjCInstMethSignature(const ObjCImplementationDecl *ID,
|
||||||
|
|
||||||
void CheckObjCUnusedIvar(const ObjCImplementationDecl *D, BugReporter& BR);
|
void CheckObjCUnusedIvar(const ObjCImplementationDecl *D, BugReporter& BR);
|
||||||
|
|
||||||
void RegisterAppleChecks(ExprEngine& Eng, const Decl &D);
|
|
||||||
void RegisterExperimentalChecks(ExprEngine &Eng);
|
void RegisterExperimentalChecks(ExprEngine &Eng);
|
||||||
void RegisterExperimentalInternalChecks(ExprEngine &Eng);
|
void RegisterExperimentalInternalChecks(ExprEngine &Eng);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "BasicObjCFoundationChecks.h"
|
#include "BasicObjCFoundationChecks.h"
|
||||||
|
|
||||||
|
#include "ClangSACheckers.h"
|
||||||
#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
|
#include "clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h"
|
||||||
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
|
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
|
||||||
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
|
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
|
||||||
|
@ -486,11 +487,18 @@ void ClassReleaseChecker::preVisitObjCMessage(CheckerContext &C,
|
||||||
// Check registration.
|
// Check registration.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
void ento::RegisterAppleChecks(ExprEngine& Eng, const Decl &D) {
|
void ento::registerNilArgChecker(ExprEngine& Eng) {
|
||||||
Eng.registerCheck(new NilArgChecker());
|
Eng.registerCheck(new NilArgChecker());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ento::registerCFNumberCreateChecker(ExprEngine& Eng) {
|
||||||
Eng.registerCheck(new CFNumberCreateChecker());
|
Eng.registerCheck(new CFNumberCreateChecker());
|
||||||
RegisterNSErrorChecks(Eng.getBugReporter(), Eng, D);
|
}
|
||||||
RegisterNSAutoreleasePoolChecks(Eng);
|
|
||||||
|
void ento::registerCFRetainReleaseChecker(ExprEngine& Eng) {
|
||||||
Eng.registerCheck(new CFRetainReleaseChecker());
|
Eng.registerCheck(new CFRetainReleaseChecker());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ento::registerClassReleaseChecker(ExprEngine& Eng) {
|
||||||
Eng.registerCheck(new ClassReleaseChecker());
|
Eng.registerCheck(new ClassReleaseChecker());
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ class BugReporter;
|
||||||
class ExprEngine;
|
class ExprEngine;
|
||||||
|
|
||||||
void RegisterNSErrorChecks(BugReporter& BR, ExprEngine &Eng, const Decl &D);
|
void RegisterNSErrorChecks(BugReporter& BR, ExprEngine &Eng, const Decl &D);
|
||||||
void RegisterNSAutoreleasePoolChecks(ExprEngine &Eng);
|
|
||||||
|
|
||||||
} // end GR namespace
|
} // end GR namespace
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,18 @@ def ObjCAtSyncChecker : Checker<"AtSync">,
|
||||||
HelpText<"Check for null pointers used as mutexes for @synchronized">,
|
HelpText<"Check for null pointers used as mutexes for @synchronized">,
|
||||||
DescFile<"ObjCAtSyncChecker.cpp">;
|
DescFile<"ObjCAtSyncChecker.cpp">;
|
||||||
|
|
||||||
|
def NilArgChecker : Checker<"NilArg">,
|
||||||
|
HelpText<"Check for prohibited nil arguments to ObjC method calls">,
|
||||||
|
DescFile<"BasicObjCFoundationChecks.cpp">;
|
||||||
|
|
||||||
|
def ClassReleaseChecker : Checker<"ClassRelease">,
|
||||||
|
HelpText<"Check for sending 'retain', 'release', or 'autorelease' directly to a Class">,
|
||||||
|
DescFile<"BasicObjCFoundationChecks.cpp">;
|
||||||
|
|
||||||
|
def NSAutoreleasePoolChecker : Checker<"NSAutoreleasePool">,
|
||||||
|
HelpText<"Warn for subpar uses of NSAutoreleasePool">,
|
||||||
|
DescFile<"NSAutoreleasePoolChecker.cpp">;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def StackAddrLeakChecker : Checker<"StackAddrLeak">,
|
def StackAddrLeakChecker : Checker<"StackAddrLeak">,
|
||||||
|
@ -62,6 +74,16 @@ def MacOSXAPIChecker : Checker<"API">,
|
||||||
HelpText<"Check calls to various MacOSXAPIChecker">,
|
HelpText<"Check calls to various MacOSXAPIChecker">,
|
||||||
DescFile<"MacOSXAPIChecker.cpp">;
|
DescFile<"MacOSXAPIChecker.cpp">;
|
||||||
|
|
||||||
|
def CFNumberCreateChecker : Checker<"CFNumber">,
|
||||||
|
InPackage<MacOSX>,
|
||||||
|
HelpText<"Check for CFNumberCreate">,
|
||||||
|
DescFile<"BasicObjCFoundationChecks.cpp">;
|
||||||
|
|
||||||
|
def CFRetainReleaseChecker : Checker<"CFRetainRelease">,
|
||||||
|
InPackage<MacOSX>,
|
||||||
|
HelpText<"Check for null arguments to CFRetain/CFRelease">,
|
||||||
|
DescFile<"BasicObjCFoundationChecks.cpp">;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Hidden experimental checkers.
|
// Hidden experimental checkers.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#include "ClangSACheckers.h"
|
||||||
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
|
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
|
||||||
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
|
#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
|
||||||
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
|
#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerVisitor.h"
|
||||||
#include "BasicObjCFoundationChecks.h"
|
|
||||||
#include "clang/AST/DeclObjC.h"
|
#include "clang/AST/DeclObjC.h"
|
||||||
#include "clang/AST/Decl.h"
|
#include "clang/AST/Decl.h"
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public:
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
void ento::RegisterNSAutoreleasePoolChecks(ExprEngine &Eng) {
|
void ento::registerNSAutoreleasePoolChecker(ExprEngine &Eng) {
|
||||||
ASTContext &Ctx = Eng.getContext();
|
ASTContext &Ctx = Eng.getContext();
|
||||||
if (Ctx.getLangOptions().getGCMode() != LangOptions::NonGC) {
|
if (Ctx.getLangOptions().getGCMode() != LangOptions::NonGC) {
|
||||||
Eng.registerCheck(new NSAutoreleasePoolChecker(GetNullarySelector("release",
|
Eng.registerCheck(new NSAutoreleasePoolChecker(GetNullarySelector("release",
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "../Checkers/ClangSACheckers.h"
|
#include "../Checkers/ClangSACheckers.h"
|
||||||
#include "../Checkers/ExperimentalChecks.h"
|
#include "../Checkers/ExperimentalChecks.h"
|
||||||
#include "../Checkers/InternalChecks.h"
|
#include "../Checkers/InternalChecks.h"
|
||||||
|
#include "../Checkers/BasicObjCFoundationChecks.h"
|
||||||
|
|
||||||
#include "clang/Basic/FileManager.h"
|
#include "clang/Basic/FileManager.h"
|
||||||
#include "clang/Basic/SourceManager.h"
|
#include "clang/Basic/SourceManager.h"
|
||||||
|
@ -349,7 +350,7 @@ static void ActionExprEngine(AnalysisConsumer &C, AnalysisManager& mgr,
|
||||||
if (C.Opts.EnableExperimentalInternalChecks)
|
if (C.Opts.EnableExperimentalInternalChecks)
|
||||||
RegisterExperimentalInternalChecks(Eng);
|
RegisterExperimentalInternalChecks(Eng);
|
||||||
|
|
||||||
RegisterAppleChecks(Eng, *D);
|
RegisterNSErrorChecks(Eng.getBugReporter(), Eng, *D);
|
||||||
|
|
||||||
if (C.Opts.EnableExperimentalChecks)
|
if (C.Opts.EnableExperimentalChecks)
|
||||||
RegisterExperimentalChecks(Eng);
|
RegisterExperimentalChecks(Eng);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s
|
// RUN: %clang_cc1 -analyze -analyzer-checker=macosx.CFNumber -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s
|
||||||
// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s
|
// RUN: %clang_cc1 -analyze -analyzer-checker=macosx.CFNumber -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s
|
||||||
// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s
|
// RUN: %clang_cc1 -analyze -analyzer-checker=macosx.CFNumber -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s
|
||||||
// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s
|
// RUN: %clang_cc1 -analyze -analyzer-checker=macosx.CFNumber -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s
|
||||||
|
|
||||||
typedef signed long CFIndex;
|
typedef signed long CFIndex;
|
||||||
typedef const struct __CFAllocator * CFAllocatorRef;
|
typedef const struct __CFAllocator * CFAllocatorRef;
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -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-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s
|
||||||
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
|
// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
|
||||||
// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -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-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -verify %s
|
||||||
// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -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-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
|
||||||
|
|
||||||
// ==-- FIXME: -analyzer-store=basic fails on this file (false negatives). --==
|
// ==-- FIXME: -analyzer-store=basic fails on this file (false negatives). --==
|
||||||
// NOTWORK: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -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-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s &&
|
||||||
// NOTWORK: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
|
// NOTWORK: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
|
||||||
// NOTWORK: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -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-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
|
||||||
// NOTWORK: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s
|
// NOTWORK: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=cocoa.NilArg -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -verify %s
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// The following code is reduced using delta-debugging from
|
// The following code is reduced using delta-debugging from
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=basic -verify -fobjc-gc-only -fblocks %s
|
// RUN: %clang_cc1 -analyze -analyzer-checker=cocoa.NSAutoreleasePool -analyzer-check-objc-mem -analyzer-store=basic -verify -fobjc-gc-only -fblocks %s
|
||||||
// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-store=region -fobjc-gc-only -fblocks -verify %s
|
// RUN: %clang_cc1 -analyze -analyzer-checker=cocoa.NSAutoreleasePool -analyzer-check-objc-mem -analyzer-store=region -fobjc-gc-only -fblocks -verify %s
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Header stuff.
|
// Header stuff.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-check-objc-mem -analyzer-store=basic -fblocks -verify %s
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=macosx.CFRetainRelease -analyzer-checker=cocoa.ClassRelease -analyzer-check-objc-mem -analyzer-store=basic -fblocks -verify %s
|
||||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-check-objc-mem -analyzer-store=region -fblocks -verify %s
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=macosx.CFRetainRelease -analyzer-checker=cocoa.ClassRelease -analyzer-check-objc-mem -analyzer-store=region -fblocks -verify %s
|
||||||
|
|
||||||
#if __has_feature(attribute_ns_returns_retained)
|
#if __has_feature(attribute_ns_returns_retained)
|
||||||
#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
|
#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
|
||||||
|
|
Загрузка…
Ссылка в новой задаче