[analyzer] Enable the self-init checker under command-line option '-analyzer-check-objc-self-init' which by default

is enabled by the driver for '--analyze'.

llvm-svn: 124266
This commit is contained in:
Argyrios Kyrtzidis 2011-01-26 01:26:50 +00:00
parent 7e71884ecb
commit c7ffd35cb7
7 changed files with 12 additions and 2 deletions

View File

@ -64,6 +64,8 @@ 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_WarnObjCSelfInit : Flag<"-analyzer-check-objc-self-init">,
HelpText<"Warn about missing initialization of 'self' in an initializer">;
def analysis_WarnSizeofPointer : Flag<"-warn-sizeof-pointer">,
HelpText<"Warn about unintended use of sizeof() on pointer expressions">;
def analysis_WarnIdempotentOps : Flag<"-analyzer-check-idempotent-operations">,

View File

@ -68,6 +68,7 @@ public:
unsigned AnalyzerStats : 1;
unsigned EagerlyAssume : 1;
unsigned IdempotentOps : 1;
unsigned ObjCSelfInitCheck : 1;
unsigned BufferOverflows : 1;
unsigned PurgeDead : 1;
unsigned TrimGraph : 1;
@ -91,6 +92,7 @@ public:
AnalyzerStats = 0;
EagerlyAssume = 0;
IdempotentOps = 0;
ObjCSelfInitCheck = 0;
BufferOverflows = 0;
PurgeDead = 1;
TrimGraph = 0;

View File

@ -910,6 +910,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (types::isObjC(InputType)) {
CmdArgs.push_back("-analyzer-check-objc-methodsigs");
CmdArgs.push_back("-analyzer-check-objc-unused-ivars");
CmdArgs.push_back("-analyzer-check-objc-self-init");
// Do not enable the missing -dealloc check.
// '-analyzer-check-objc-missing-dealloc',
}

View File

@ -118,6 +118,8 @@ static void AnalyzerOptsToArgs(const AnalyzerOptions &Opts,
Res.push_back("-analyzer-experimental-internal-checks");
if (Opts.IdempotentOps)
Res.push_back("-analyzer-check-idempotent-operations");
if (Opts.ObjCSelfInitCheck)
Res.push_back("-analyzer-check-objc-self-init");
if (Opts.BufferOverflows)
Res.push_back("-analyzer-check-buffer-overflows");
}
@ -868,6 +870,7 @@ static void ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args,
Opts.MaxLoop = Args.getLastArgIntValue(OPT_analyzer_max_loop, 4, Diags);
Opts.InlineCall = Args.hasArg(OPT_analyzer_inline_call);
Opts.IdempotentOps = Args.hasArg(OPT_analysis_WarnIdempotentOps);
Opts.ObjCSelfInitCheck = Args.hasArg(OPT_analysis_WarnObjCSelfInit);
Opts.BufferOverflows = Args.hasArg(OPT_analysis_WarnBufferOverflows);
}

View File

@ -357,6 +357,9 @@ static void ActionExprEngine(AnalysisConsumer &C, AnalysisManager& mgr,
if (C.Opts.EnableExperimentalChecks)
RegisterExperimentalChecks(Eng);
if (C.Opts.ObjCSelfInitCheck && isa<ObjCMethodDecl>(D))
registerObjCSelfInitChecker(Eng);
// Enable idempotent operation checking if it was explicitly turned on, or if
// we are running experimental checks (i.e. everything)
if (C.Opts.IdempotentOps || C.Opts.EnableExperimentalChecks

View File

@ -309,7 +309,6 @@ static void RegisterInternalChecks(ExprEngine &Eng) {
RegisterUndefResultChecker(Eng);
RegisterStackAddrLeakChecker(Eng);
RegisterObjCAtSyncChecker(Eng);
registerObjCSelfInitChecker(Eng);
// This is not a checker yet.
RegisterNoReturnFunctionChecker(Eng);

View File

@ -1,4 +1,4 @@
// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem %s -verify
// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-check-objc-self-init %s -verify
@class NSZone, NSCoder;
@protocol NSObject