Index: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td =================================================================== --- clang/include/clang/StaticAnalyzer/Checkers/Checkers.td +++ clang/include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -1109,13 +1109,15 @@ def DirectIvarAssignment : Checker<"DirectIvarAssignment">, HelpText<"Check for direct assignments to instance variables">, - Documentation; - -def DirectIvarAssignmentForAnnotatedFunctions : - Checker<"DirectIvarAssignmentForAnnotatedFunctions">, - HelpText<"Check for direct assignments to instance variables in the methods " - "annotated with objc_no_direct_instance_variable_assignment">, - Dependencies<[DirectIvarAssignment]>, + CheckerOptions<[ + CmdLineOption + ]>, Documentation; } // end "alpha.osx.cocoa" Index: clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp =================================================================== --- clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp +++ clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp @@ -219,19 +219,12 @@ // Register the checker that checks for direct accesses in all functions, // except for the initialization and copy routines. void ento::registerDirectIvarAssignment(CheckerManager &mgr) { - mgr.registerChecker(); + auto Chk = mgr.registerChecker(); + if (mgr.getAnalyzerOptions().getCheckerBooleanOption(Chk, + "AnnotatedFunctions")) + Chk->ShouldSkipMethod = &AttrFilter; } bool ento::shouldRegisterDirectIvarAssignment(const CheckerManager &mgr) { return true; } - -void ento::registerDirectIvarAssignmentForAnnotatedFunctions( - CheckerManager &mgr) { - mgr.getChecker()->ShouldSkipMethod = &AttrFilter; -} - -bool ento::shouldRegisterDirectIvarAssignmentForAnnotatedFunctions( - const CheckerManager &mgr) { - return true; -} Index: clang/test/Analysis/analyzer-config.c =================================================================== --- clang/test/Analysis/analyzer-config.c +++ clang/test/Analysis/analyzer-config.c @@ -8,6 +8,7 @@ // CHECK-NEXT: alpha.clone.CloneChecker:MinimumCloneComplexity = 50 // CHECK-NEXT: alpha.clone.CloneChecker:ReportNormalClones = true // CHECK-NEXT: alpha.cplusplus.STLAlgorithmModeling:AggressiveStdFindModeling = false +// CHECK-NEXT: alpha.osx.cocoa.DirectIvarAssignment:AnnotatedFunctions = false // CHECK-NEXT: alpha.security.MmapWriteExec:MmapProtExec = 0x04 // CHECK-NEXT: alpha.security.MmapWriteExec:MmapProtRead = 0x01 // CHECK-NEXT: alpha.security.taint.TaintPropagation:Config = "" @@ -106,4 +107,4 @@ // CHECK-NEXT: unroll-loops = false // CHECK-NEXT: widen-loops = false // CHECK-NEXT: [stats] -// CHECK-NEXT: num-entries = 103 +// CHECK-NEXT: num-entries = 104 Index: clang/test/Analysis/objc/direct-ivar-assignment-in-annotated-functions.m =================================================================== --- clang/test/Analysis/objc/direct-ivar-assignment-in-annotated-functions.m +++ clang/test/Analysis/objc/direct-ivar-assignment-in-annotated-functions.m @@ -1,4 +1,8 @@ -// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.osx.cocoa.DirectIvarAssignmentForAnnotatedFunctions -verify -fblocks %s +// RUN: %clang_analyze_cc1 -verify -fblocks %s \ +// RUN: -analyzer-checker=core \ +// RUN: -analyzer-checker=alpha.osx.cocoa.DirectIvarAssignment \ +// RUN: -analyzer-config \ +// RUN: alpha.osx.cocoa.DirectIvarAssignment:AnnotatedFunctions=true typedef signed char BOOL; @protocol NSObject - (BOOL)isEqual:(id)object; @end @@ -60,4 +64,4 @@ _nonSynth = 0; // no-warning } -@end \ No newline at end of file +@end