[cfe-commits] r124266 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Frontend/AnalyzerOptions.h lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp lib/StaticAnalyzer/Checkers/AnalysisConsumer.cpp lib/StaticAnalyzer/Checkers/ExprEngine.cpp test/Analysis/self-init.m

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Jan 25 17:26:50 PST 2011


Author: akirtzidis
Date: Tue Jan 25 19:26:50 2011
New Revision: 124266

URL: http://llvm.org/viewvc/llvm-project?rev=124266&view=rev
Log:
[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'.

Modified:
    cfe/trunk/include/clang/Driver/CC1Options.td
    cfe/trunk/include/clang/Frontend/AnalyzerOptions.h
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisConsumer.cpp
    cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
    cfe/trunk/test/Analysis/self-init.m

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=124266&r1=124265&r2=124266&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Jan 25 19:26:50 2011
@@ -64,6 +64,8 @@
   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">,

Modified: cfe/trunk/include/clang/Frontend/AnalyzerOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/AnalyzerOptions.h?rev=124266&r1=124265&r2=124266&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/AnalyzerOptions.h Tue Jan 25 19:26:50 2011
@@ -68,6 +68,7 @@
   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 @@
     AnalyzerStats = 0;
     EagerlyAssume = 0;
     IdempotentOps = 0;
+    ObjCSelfInitCheck = 0;
     BufferOverflows = 0;    
     PurgeDead = 1;
     TrimGraph = 0;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=124266&r1=124265&r2=124266&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jan 25 19:26:50 2011
@@ -910,6 +910,7 @@
       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',
       }

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=124266&r1=124265&r2=124266&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Jan 25 19:26:50 2011
@@ -118,6 +118,8 @@
     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 @@
   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);
 }
 

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisConsumer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisConsumer.cpp?rev=124266&r1=124265&r2=124266&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisConsumer.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/AnalysisConsumer.cpp Tue Jan 25 19:26:50 2011
@@ -357,6 +357,9 @@
   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

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp?rev=124266&r1=124265&r2=124266&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ExprEngine.cpp Tue Jan 25 19:26:50 2011
@@ -309,7 +309,6 @@
   RegisterUndefResultChecker(Eng);
   RegisterStackAddrLeakChecker(Eng);
   RegisterObjCAtSyncChecker(Eng);
-  registerObjCSelfInitChecker(Eng);
 
   // This is not a checker yet.
   RegisterNoReturnFunctionChecker(Eng);

Modified: cfe/trunk/test/Analysis/self-init.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/self-init.m?rev=124266&r1=124265&r2=124266&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/self-init.m (original)
+++ cfe/trunk/test/Analysis/self-init.m Tue Jan 25 19:26:50 2011
@@ -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





More information about the cfe-commits mailing list