From 5102e3767fb7090532615bccb126a2db0e73a424 Mon Sep 17 00:00:00 2001 From: Argiris Kirtzidis Date: Thu, 17 Feb 2011 21:39:33 +0000 Subject: [PATCH] [analyzer] Use the new registration mechanism on the non-path-sensitive-checkers: DeadStoresChecker ObjCMethSigsChecker ObjCUnusedIvarsChecker SizeofPointerChecker ObjCDeallocChecker SecuritySyntaxChecker git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125779 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Driver/CC1Options.td | 12 ------- include/clang/Frontend/Analyses.def | 20 ----------- .../clang/StaticAnalyzer/Checkers/LocalCheckers.h | 14 -------- lib/Driver/Tools.cpp | 11 ------ lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp | 28 +++++++++++++-- .../Checkers/CheckObjCInstMethSignature.cpp | 26 ++++++++++++-- .../Checkers/CheckSecuritySyntaxOnly.cpp | 23 +++++++++---- lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp | 23 ++++++++++--- lib/StaticAnalyzer/Checkers/Checkers.td | 31 +++++++++++++++++ lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp | 31 +++++++++++++---- .../Checkers/ObjCUnusedIVarsChecker.cpp | 24 +++++++++++-- lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp | 40 ---------------------- test/Analysis/MissingDealloc.m | 2 +- test/Analysis/NSWindow.m | 8 ++--- test/Analysis/ObjCRetSigs.m | 2 +- test/Analysis/PR2978.m | 2 +- test/Analysis/analyzer-stats.c | 2 +- test/Analysis/conditional-op-missing-lhs.c | 2 +- test/Analysis/dead-stores.c | 10 +++--- test/Analysis/dead-stores.cpp | 10 +++--- test/Analysis/dead-stores.m | 2 +- test/Analysis/rdar-6540084.m | 2 +- test/Analysis/security-syntax-checks-no-emit.c | 2 +- test/Analysis/security-syntax-checks.m | 2 +- test/Analysis/sizeofpointer.c | 2 +- test/Analysis/unreachable-code-path.c | 2 +- test/Analysis/unused-ivars.m | 2 +- 27 files changed, 188 insertions(+), 147 deletions(-) diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index 0fb2dfe36..2abbf4016 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -48,22 +48,10 @@ def analysis_CFGAddInitializers : Flag<"-cfg-add-initializers">, HelpText<"Add C++ initializers to CFGs for all analyses">; def analysis_DisplayLiveVariables : Flag<"-dump-live-variables">, HelpText<"Print results of live variable analysis">; -def analysis_SecuritySyntacticChecks : Flag<"-analyzer-check-security-syntactic">, - HelpText<"Perform quick security checks that require no data flow">; -def analysis_WarnDeadStores : Flag<"-analyzer-check-dead-stores">, - HelpText<"Warn about stores to dead variables">; def analysis_WarnUninitVals : Flag<"-warn-uninit-values">, HelpText<"Warn about uses of uninitialized variables">; -def analysis_WarnObjCMethSigs : Flag<"-analyzer-check-objc-methodsigs">, - HelpText<"Warn about Objective-C method signatures with type incompatibilities">; -def analysis_WarnObjCDealloc : Flag<"-analyzer-check-objc-missing-dealloc">, - HelpText<"Warn about Objective-C classes that lack a correct implementation of -dealloc">; -def analysis_WarnObjCUnusedIvars : Flag<"-analyzer-check-objc-unused-ivars">, - HelpText<"Warn about private ivars that are never used">; def analysis_ObjCMemChecker : Flag<"-analyzer-check-objc-mem">, HelpText<"Run the [Core] Foundation reference count checker">; -def analysis_WarnSizeofPointer : Flag<"-warn-sizeof-pointer">, - HelpText<"Warn about unintended use of sizeof() on pointer expressions">; def analysis_AnalyzerStats : Flag<"-analyzer-stats">, HelpText<"Emit warnings with analyzer statistics">; def analysis_WarnBufferOverflows : Flag<"-analyzer-check-buffer-overflows">, diff --git a/include/clang/Frontend/Analyses.def b/include/clang/Frontend/Analyses.def index 9e9d6f8c5..289ac83cc 100644 --- a/include/clang/Frontend/Analyses.def +++ b/include/clang/Frontend/Analyses.def @@ -24,32 +24,12 @@ ANALYSIS(CFGView, "cfg-view", ANALYSIS(DisplayLiveVariables, "dump-live-variables", "Print results of live variable analysis", Code) -ANALYSIS(SecuritySyntacticChecks, "analyzer-check-security-syntactic", - "Perform quick security checks that require no data flow", Code) - -ANALYSIS(WarnDeadStores, "analyzer-check-dead-stores", - "Warn about stores to dead variables", Code) - ANALYSIS(WarnUninitVals, "warn-uninit-values", "Warn about uses of uninitialized variables", Code) - -ANALYSIS(WarnObjCMethSigs, "analyzer-check-objc-methodsigs", - "Warn about Objective-C method signatures with type incompatibilities", - ObjCImplementation) - -ANALYSIS(WarnObjCDealloc, "analyzer-check-objc-missing-dealloc", -"Warn about Objective-C classes that lack a correct implementation of -dealloc", - ObjCImplementation) -ANALYSIS(WarnObjCUnusedIvars, "analyzer-check-objc-unused-ivars", - "Warn about private ivars that are never used", ObjCImplementation) - ANALYSIS(ObjCMemChecker, "analyzer-check-objc-mem", "Run the [Core] Foundation reference count checker", Code) -ANALYSIS(WarnSizeofPointer, "warn-sizeof-pointer", - "Warn about unintended use of sizeof() on pointer expressions", Code) - #ifndef ANALYSIS_STORE #define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN) #endif diff --git a/include/clang/StaticAnalyzer/Checkers/LocalCheckers.h b/include/clang/StaticAnalyzer/Checkers/LocalCheckers.h index 5e5756c4d..42feb78b4 100644 --- a/include/clang/StaticAnalyzer/Checkers/LocalCheckers.h +++ b/include/clang/StaticAnalyzer/Checkers/LocalCheckers.h @@ -36,26 +36,12 @@ class BugType; class BugReporter; class ExprEngine; -void CheckDeadStores(CFG &cfg, LiveVariables &L, ParentMap &map, - BugReporter& BR); - TransferFuncs* MakeCFRefCountTF(ASTContext& Ctx, bool GCEnabled, const LangOptions& lopts); -void CheckObjCDealloc(const ObjCImplementationDecl* D, const LangOptions& L, - BugReporter& BR); - -void CheckObjCInstMethSignature(const ObjCImplementationDecl *ID, - BugReporter& BR); - -void CheckObjCUnusedIvar(const ObjCImplementationDecl *D, BugReporter& BR); - void RegisterExperimentalChecks(ExprEngine &Eng); void RegisterExperimentalInternalChecks(ExprEngine &Eng); -void CheckSecuritySyntaxOnly(const Decl *D, BugReporter &BR); -void CheckSizeofPointer(const Decl *D, BugReporter &BR); - void RegisterCallInliner(ExprEngine &Eng); } // end GR namespace diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index fe8ebb130..5233e2bcf 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -928,25 +928,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, if (getToolChain().getTriple().getVendor() == llvm::Triple::Apple) CmdArgs.push_back("-analyzer-checker=macosx"); - CmdArgs.push_back("-analyzer-check-dead-stores"); - // Checks to perform for Objective-C/Objective-C++. if (types::isObjC(InputType)) { // Enable all checkers in 'cocoa' package. CmdArgs.push_back("-analyzer-checker=cocoa"); - - CmdArgs.push_back("-analyzer-check-objc-methodsigs"); - CmdArgs.push_back("-analyzer-check-objc-unused-ivars"); - // Do not enable the missing -dealloc check. - // '-analyzer-check-objc-missing-dealloc', } // Checks to perform for all languages *except* C++. if (!types::isCXX(InputType)) { - // Do not enable the security-syntatic check since it - // it needs to be refined (known issues). - // CmdArgs.push_back("-analyzer-check-security-syntactic"); - // NOTE: Leaving -analyzer-check-objc-mem here is intentional. // It also checks C code. CmdArgs.push_back("-analyzer-check-objc-mem"); diff --git a/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp b/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp index 26e627e5d..ad3bab6f7 100644 --- a/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp +++ b/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp @@ -13,7 +13,9 @@ // //===----------------------------------------------------------------------===// -#include "clang/StaticAnalyzer/Checkers/LocalCheckers.h" +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/CheckerV2.h" +#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/AST/ExprObjC.h" @@ -94,8 +96,8 @@ static bool scan_ivar_release(Stmt* S, ObjCIvarDecl* ID, return false; } -void ento::CheckObjCDealloc(const ObjCImplementationDecl* D, - const LangOptions& LOpts, BugReporter& BR) { +static void checkObjCDealloc(const ObjCImplementationDecl* D, + const LangOptions& LOpts, BugReporter& BR) { assert (LOpts.getGCMode() != LangOptions::GCOnly); @@ -260,3 +262,23 @@ void ento::CheckObjCDealloc(const ObjCImplementationDecl* D, } } +//===----------------------------------------------------------------------===// +// ObjCDeallocChecker +//===----------------------------------------------------------------------===// + +namespace { +class ObjCDeallocChecker : public CheckerV2< + check::ASTDecl > { +public: + void checkASTDecl(const ObjCImplementationDecl *D, AnalysisManager& mgr, + BugReporter &BR) const { + if (mgr.getLangOptions().getGCMode() == LangOptions::GCOnly) + return; + checkObjCDealloc(cast(D), mgr.getLangOptions(), BR); + } +}; +} + +void ento::registerObjCDeallocChecker(CheckerManager &mgr) { + mgr.registerChecker(); +} diff --git a/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp b/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp index bc0da2858..369ba0bbb 100644 --- a/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp +++ b/lib/StaticAnalyzer/Checkers/CheckObjCInstMethSignature.cpp @@ -13,7 +13,8 @@ // //===----------------------------------------------------------------------===// -#include "clang/StaticAnalyzer/Checkers/LocalCheckers.h" +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/CheckerV2.h" #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/AST/DeclObjC.h" @@ -70,8 +71,8 @@ static void CompareReturnTypes(const ObjCMethodDecl *MethDerived, } } -void ento::CheckObjCInstMethSignature(const ObjCImplementationDecl* ID, - BugReporter& BR) { +static void CheckObjCInstMethSignature(const ObjCImplementationDecl* ID, + BugReporter& BR) { const ObjCInterfaceDecl* D = ID->getClassInterface(); const ObjCInterfaceDecl* C = D->getSuperClass(); @@ -118,3 +119,22 @@ void ento::CheckObjCInstMethSignature(const ObjCImplementationDecl* ID, C = C->getSuperClass(); } } + +//===----------------------------------------------------------------------===// +// ObjCMethSigsChecker +//===----------------------------------------------------------------------===// + +namespace { +class ObjCMethSigsChecker : public CheckerV2< + check::ASTDecl > { +public: + void checkASTDecl(const ObjCImplementationDecl *D, AnalysisManager& mgr, + BugReporter &BR) const { + CheckObjCInstMethSignature(D, BR); + } +}; +} + +void ento::registerObjCMethSigsChecker(CheckerManager &mgr) { + mgr.registerChecker(); +} diff --git a/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp b/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp index 013f001c2..185520c8d 100644 --- a/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp +++ b/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp @@ -11,9 +11,10 @@ // //===----------------------------------------------------------------------===// -#include "clang/Basic/TargetInfo.h" +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/CheckerV2.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" -#include "clang/StaticAnalyzer/Checkers/LocalCheckers.h" +#include "clang/Basic/TargetInfo.h" #include "clang/AST/StmtVisitor.h" #include "llvm/Support/raw_ostream.h" @@ -497,10 +498,20 @@ void WalkAST::CheckUncheckedReturnValue(CallExpr *CE) { } //===----------------------------------------------------------------------===// -// Entry point for check. +// SecuritySyntaxChecker //===----------------------------------------------------------------------===// -void ento::CheckSecuritySyntaxOnly(const Decl *D, BugReporter &BR) { - WalkAST walker(BR); - walker.Visit(D->getBody()); +namespace { +class SecuritySyntaxChecker : public CheckerV2 { +public: + void checkASTCodeBody(const Decl *D, AnalysisManager& mgr, + BugReporter &BR) const { + WalkAST walker(BR); + walker.Visit(D->getBody()); + } +}; +} + +void ento::registerSecuritySyntaxChecker(CheckerManager &mgr) { + mgr.registerChecker(); } diff --git a/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp b/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp index d5f6dd033..d46ac8121 100644 --- a/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp +++ b/lib/StaticAnalyzer/Checkers/CheckSizeofPointer.cpp @@ -12,9 +12,10 @@ // //===----------------------------------------------------------------------===// +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/CheckerV2.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/AST/StmtVisitor.h" -#include "clang/StaticAnalyzer/Checkers/LocalCheckers.h" using namespace clang; using namespace ento; @@ -66,7 +67,21 @@ void WalkAST::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) { } } -void ento::CheckSizeofPointer(const Decl *D, BugReporter &BR) { - WalkAST walker(BR); - walker.Visit(D->getBody()); +//===----------------------------------------------------------------------===// +// SizeofPointerChecker +//===----------------------------------------------------------------------===// + +namespace { +class SizeofPointerChecker : public CheckerV2 { +public: + void checkASTCodeBody(const Decl *D, AnalysisManager& mgr, + BugReporter &BR) const { + WalkAST walker(BR); + walker.Visit(D->getBody()); + } +}; +} + +void ento::registerSizeofPointerChecker(CheckerManager &mgr) { + mgr.registerChecker(); } diff --git a/lib/StaticAnalyzer/Checkers/Checkers.td b/lib/StaticAnalyzer/Checkers/Checkers.td index 234c23f29..aabf07a1f 100644 --- a/lib/StaticAnalyzer/Checkers/Checkers.td +++ b/lib/StaticAnalyzer/Checkers/Checkers.td @@ -21,6 +21,9 @@ def MacOSX : Package<"macosx">; def CoreExperimental : Package<"experimental">, InPackage, Hidden; +def CocoaExperimental : Package<"experimental">, + InPackage, Hidden; + def UnixExperimental : Package<"experimental">, InPackage, Hidden; @@ -59,6 +62,14 @@ def NSAutoreleasePoolChecker : Checker<"NSAutoreleasePool">, HelpText<"Warn for subpar uses of NSAutoreleasePool">, DescFile<"NSAutoreleasePoolChecker.cpp">; +def ObjCMethSigsChecker : Checker<"MethodSigs">, + HelpText<"Warn about Objective-C method signatures with type incompatibilities">, + DescFile<"CheckObjCInstMethSignature.cpp">; + +def ObjCUnusedIvarsChecker : Checker<"UnusedIvars">, + HelpText<"Warn about private ivars that are never used">, + DescFile<"ObjCUnusedIVarsChecker.cpp">; + } def StackAddrLeakChecker : Checker<"StackAddrLeak">, @@ -66,6 +77,11 @@ def StackAddrLeakChecker : Checker<"StackAddrLeak">, HelpText<"Check that addresses to stack memory are not leaked outside the function">, DescFile<"StackAddrLeakChecker.cpp">; +def DeadStoresChecker : Checker<"DeadStores">, + InPackage, + HelpText<"Check for stores to dead variables">, + DescFile<"DeadStoresChecker.cpp">; + def UnixAPIChecker : Checker<"API">, InPackage, HelpText<"Check calls to various UNIX/Posix functions">, @@ -132,6 +148,21 @@ def PointerSubChecker : Checker<"PointerSub">, HelpText<"Check for pointer subtractions on two pointers pointing to different memory chunks">, DescFile<"PointerSubChecker">; +def SizeofPointerChecker : Checker<"SizeofPtr">, + InPackage, + HelpText<"Warn about unintended use of sizeof() on pointer expressions">, + DescFile<"CheckSizeofPointer.cpp">; + +def SecuritySyntaxChecker : Checker<"SecuritySyntactic">, + InPackage, + HelpText<"Perform quick security checks that require no data flow">, + DescFile<"CheckSecuritySyntaxOnly.cpp">; + +def ObjCDeallocChecker : Checker<"Dealloc">, + InPackage, + HelpText<"Warn about Objective-C classes that lack a correct implementation of -dealloc">, + DescFile<"CheckObjCDealloc.cpp">; + def ChrootChecker : Checker<"Chroot">, InPackage, HelpText<"Check improper use of chroot">, diff --git a/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp b/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp index a6c0ea315..3b3937272 100644 --- a/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/CheckerV2.h" #include "clang/StaticAnalyzer/Checkers/LocalCheckers.h" #include "clang/Analysis/Analyses/LiveVariables.h" #include "clang/Analysis/Visitors/CFGRecStmtVisitor.h" @@ -335,10 +337,27 @@ public: } // end anonymous namespace -void ento::CheckDeadStores(CFG &cfg, LiveVariables &L, ParentMap &pmap, - BugReporter& BR) { - FindEscaped FS(&cfg); - FS.getCFG().VisitBlockStmts(FS); - DeadStoreObs A(cfg, BR.getContext(), BR, pmap, FS.Escaped); - L.runOnAllBlocks(cfg, &A); +//===----------------------------------------------------------------------===// +// DeadStoresChecker +//===----------------------------------------------------------------------===// + +namespace { +class DeadStoresChecker : public CheckerV2 { +public: + void checkASTCodeBody(const Decl *D, AnalysisManager& mgr, + BugReporter &BR) const { + if (LiveVariables *L = mgr.getLiveVariables(D)) { + CFG &cfg = *mgr.getCFG(D); + ParentMap &pmap = mgr.getParentMap(D); + FindEscaped FS(&cfg); + FS.getCFG().VisitBlockStmts(FS); + DeadStoreObs A(cfg, BR.getContext(), BR, pmap, FS.Escaped); + L->runOnAllBlocks(cfg, &A); + } + } +}; +} + +void ento::registerDeadStoresChecker(CheckerManager &mgr) { + mgr.registerChecker(); } diff --git a/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp b/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp index dc8e127a5..6e9249876 100644 --- a/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ObjCUnusedIVarsChecker.cpp @@ -13,7 +13,8 @@ // //===----------------------------------------------------------------------===// -#include "clang/StaticAnalyzer/Checkers/LocalCheckers.h" +#include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Core/CheckerV2.h" #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" #include "clang/AST/ExprObjC.h" @@ -98,7 +99,7 @@ static void Scan(IvarUsageMap &M, const DeclContext *C, const FileID FID, } } -void ento::CheckObjCUnusedIvar(const ObjCImplementationDecl *D, +static void checkObjCUnusedIvar(const ObjCImplementationDecl *D, BugReporter &BR) { const ObjCInterfaceDecl* ID = D->getClassInterface(); @@ -162,3 +163,22 @@ void ento::CheckObjCUnusedIvar(const ObjCImplementationDecl *D, os.str(), I->first->getLocation()); } } + +//===----------------------------------------------------------------------===// +// ObjCUnusedIvarsChecker +//===----------------------------------------------------------------------===// + +namespace { +class ObjCUnusedIvarsChecker : public CheckerV2< + check::ASTDecl > { +public: + void checkASTDecl(const ObjCImplementationDecl *D, AnalysisManager& mgr, + BugReporter &BR) const { + checkObjCUnusedIvar(D, BR); + } +}; +} + +void ento::registerObjCUnusedIvarsChecker(CheckerManager &mgr) { + mgr.registerChecker(); +} diff --git a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index b16e81899..a2003c313 100644 --- a/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -318,14 +318,6 @@ void AnalysisConsumer::HandleCode(Decl *D, Actions& actions) { // Analyses //===----------------------------------------------------------------------===// -static void ActionWarnDeadStores(AnalysisConsumer &C, AnalysisManager& mgr, - Decl *D) { - if (LiveVariables *L = mgr.getLiveVariables(D)) { - BugReporter BR(mgr); - CheckDeadStores(*mgr.getCFG(D), *L, mgr.getParentMap(D), BR); - } -} - static void ActionWarnUninitVals(AnalysisConsumer &C, AnalysisManager& mgr, Decl *D) { if (CFG* c = mgr.getCFG(D)) { @@ -434,38 +426,6 @@ static void ActionCFGView(AnalysisConsumer &C, AnalysisManager& mgr, Decl *D) { } } -static void ActionSecuritySyntacticChecks(AnalysisConsumer &C, - AnalysisManager &mgr, Decl *D) { - BugReporter BR(mgr); - CheckSecuritySyntaxOnly(D, BR); -} - -static void ActionWarnObjCDealloc(AnalysisConsumer &C, AnalysisManager& mgr, - Decl *D) { - if (mgr.getLangOptions().getGCMode() == LangOptions::GCOnly) - return; - BugReporter BR(mgr); - CheckObjCDealloc(cast(D), mgr.getLangOptions(), BR); -} - -static void ActionWarnObjCUnusedIvars(AnalysisConsumer &C, AnalysisManager& mgr, - Decl *D) { - BugReporter BR(mgr); - CheckObjCUnusedIvar(cast(D), BR); -} - -static void ActionWarnObjCMethSigs(AnalysisConsumer &C, AnalysisManager& mgr, - Decl *D) { - BugReporter BR(mgr); - CheckObjCInstMethSignature(cast(D), BR); -} - -static void ActionWarnSizeofPointer(AnalysisConsumer &C, AnalysisManager &mgr, - Decl *D) { - BugReporter BR(mgr); - CheckSizeofPointer(D, BR); -} - //===----------------------------------------------------------------------===// // AnalysisConsumer creation. //===----------------------------------------------------------------------===// diff --git a/test/Analysis/MissingDealloc.m b/test/Analysis/MissingDealloc.m index bfd968a9a..d7aaa99be 100644 --- a/test/Analysis/MissingDealloc.m +++ b/test/Analysis/MissingDealloc.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-missing-dealloc '-DIBOutlet=__attribute__((iboutlet))' %s -verify +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=cocoa.experimental.Dealloc '-DIBOutlet=__attribute__((iboutlet))' %s -verify typedef signed char BOOL; @protocol NSObject - (BOOL)isEqual:(id)object; diff --git a/test/Analysis/NSWindow.m b/test/Analysis/NSWindow.m index 34e6c68b8..c386adf3f 100644 --- a/test/Analysis/NSWindow.m +++ b/test/Analysis/NSWindow.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -analyzer-store=basic -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -analyzer-store=basic -analyzer-constraints=range -verify %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -analyzer-store=region -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -analyzer-store=region -analyzer-constraints=range -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -analyzer-store=basic -analyzer-constraints=basic -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -analyzer-store=basic -analyzer-constraints=range -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -analyzer-store=region -analyzer-constraints=basic -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -analyzer-store=region -analyzer-constraints=range -verify %s // These declarations were reduced using Delta-Debugging from Foundation.h // on Mac OS X. The test cases are below. diff --git a/test/Analysis/ObjCRetSigs.m b/test/Analysis/ObjCRetSigs.m index a76d7b979..5a912a808 100644 --- a/test/Analysis/ObjCRetSigs.m +++ b/test/Analysis/ObjCRetSigs.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-methodsigs -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=cocoa.MethodSigs -verify %s int printf(const char *, ...); diff --git a/test/Analysis/PR2978.m b/test/Analysis/PR2978.m index 1ed138e45..ac3ef790c 100644 --- a/test/Analysis/PR2978.m +++ b/test/Analysis/PR2978.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-missing-dealloc %s -verify +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=cocoa.experimental.Dealloc %s -verify // Tests for the checker which checks missing/extra ivar 'release' calls // in dealloc. diff --git a/test/Analysis/analyzer-stats.c b/test/Analysis/analyzer-stats.c index 0c502cd02..d8dde23d6 100644 --- a/test/Analysis/analyzer-stats.c +++ b/test/Analysis/analyzer-stats.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks -analyzer-stats %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks -analyzer-stats %s int foo(); diff --git a/test/Analysis/conditional-op-missing-lhs.c b/test/Analysis/conditional-op-missing-lhs.c index 86882a5ac..e73896419 100644 --- a/test/Analysis/conditional-op-missing-lhs.c +++ b/test/Analysis/conditional-op-missing-lhs.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-dead-stores -warn-uninit-values -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=core.DeadStores -warn-uninit-values -verify %s void f1() { diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c index 77e99568f..7fc0f0464 100644 --- a/test/Analysis/dead-stores.c +++ b/test/Analysis/dead-stores.c @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s -// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-check-dead-stores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -analyzer-checker=core.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -analyzer-checker=core.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -analyzer-checker=core.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s +// RUN: %clang_cc1 -Wunused-variable -analyze -analyzer-checker=core.experimental.IdempotentOps -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-checker=core.DeadStores -fblocks -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s void f1() { int k, y; // expected-warning{{unused variable 'k'}} expected-warning{{unused variable 'y'}} diff --git a/test/Analysis/dead-stores.cpp b/test/Analysis/dead-stores.cpp index 9648baceb..c384f9f5e 100644 --- a/test/Analysis/dead-stores.cpp +++ b/test/Analysis/dead-stores.cpp @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-dead-stores -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -analyzer-check-dead-stores -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -analyzer-check-dead-stores -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -analyzer-check-dead-stores -verify -Wno-unreachable-code %s -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-check-dead-stores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=basic -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=basic -analyzer-constraints=range -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=basic -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -analyzer-checker=core.DeadStores -verify -Wno-unreachable-code %s //===----------------------------------------------------------------------===// // Basic dead store checking (but in C++ mode). diff --git a/test/Analysis/dead-stores.m b/test/Analysis/dead-stores.m index 852e63afc..00c9e53d2 100644 --- a/test/Analysis/dead-stores.m +++ b/test/Analysis/dead-stores.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-dead-stores -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=core.DeadStores -verify %s typedef signed char BOOL; typedef unsigned int NSUInteger; diff --git a/test/Analysis/rdar-6540084.m b/test/Analysis/rdar-6540084.m index dd0181099..d6a03b6f9 100644 --- a/test/Analysis/rdar-6540084.m +++ b/test/Analysis/rdar-6540084.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-dead-stores -verify %s +// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-checker=core.DeadStores -verify %s // // This test exercises the live variables analysis (LiveVariables.cpp). // The case originally identified a non-termination bug. diff --git a/test/Analysis/security-syntax-checks-no-emit.c b/test/Analysis/security-syntax-checks-no-emit.c index 7a71235a2..f129e8a8e 100644 --- a/test/Analysis/security-syntax-checks-no-emit.c +++ b/test/Analysis/security-syntax-checks-no-emit.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i686-pc-linux-gnu -analyze -analyzer-check-security-syntactic %s -verify +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -analyze -analyzer-checker=core.experimental.SecuritySyntactic %s -verify // This file complements 'security-syntax-checks.m', but tests that we omit // specific checks on platforms where they don't make sense. diff --git a/test/Analysis/security-syntax-checks.m b/test/Analysis/security-syntax-checks.m index 8dd859a4c..bac6ee89d 100644 --- a/test/Analysis/security-syntax-checks.m +++ b/test/Analysis/security-syntax-checks.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-check-security-syntactic %s -verify +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core.experimental.SecuritySyntactic %s -verify // rule request: floating point used as loop // condition (FLP30-C, FLP-30-CPP) diff --git a/test/Analysis/sizeofpointer.c b/test/Analysis/sizeofpointer.c index 82fda0411..6d0a2c4d2 100644 --- a/test/Analysis/sizeofpointer.c +++ b/test/Analysis/sizeofpointer.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -warn-sizeof-pointer -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.SizeofPtr -verify %s struct s { }; diff --git a/test/Analysis/unreachable-code-path.c b/test/Analysis/unreachable-code-path.c index 9e560d55a..52e6d3df2 100644 --- a/test/Analysis/unreachable-code-path.c +++ b/test/Analysis/unreachable-code-path.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-check-dead-stores -verify -analyzer-opt-analyze-nested-blocks -Wno-unused-value %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -verify -analyzer-opt-analyze-nested-blocks -Wno-unused-value %s extern void foo(int a); diff --git a/test/Analysis/unused-ivars.m b/test/Analysis/unused-ivars.m index 20531efaa..b43ae1869 100644 --- a/test/Analysis/unused-ivars.m +++ b/test/Analysis/unused-ivars.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-nonfragile-abi -fblocks -analyze -analyzer-check-objc-unused-ivars %s -verify +// RUN: %clang_cc1 -fobjc-nonfragile-abi -fblocks -analyze -analyzer-checker=cocoa.UnusedIvars %s -verify //===--- BEGIN: Delta-debugging reduced headers. --------------------------===// -- 2.11.4.GIT