[cfe-commits] r123481 - /cfe/trunk/lib/Driver/Tools.cpp

Ted Kremenek kremenek at apple.com
Fri Jan 14 14:31:31 PST 2011


Author: kremenek
Date: Fri Jan 14 16:31:31 2011
New Revision: 123481

URL: http://llvm.org/viewvc/llvm-project?rev=123481&view=rev
Log:
Driver: tweak handling of '--analyze' to invoke
analyzer -cc1 options that are tailored to the
input type.  If the input type is "C++", we should
only run the dead stores checker (for now).  Similarly,
checks specific to Objective-C should only run
on Objective-C Code.

Modified:
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=123481&r1=123480&r2=123481&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jan 14 16:31:31 2011
@@ -901,17 +901,32 @@
 
     // Add default argument set.
     if (!Args.hasArg(options::OPT__analyzer_no_default_checks)) {
+      types::ID InputType = Inputs[0].getType();
+
+      // Checks to perform for all language types.
       CmdArgs.push_back("-analyzer-check-dead-stores");
-      // Do not enable the security-syntatic check since it
-      // it needs to be refined (known issues).
-      // CmdArgs.push_back("-analyzer-check-security-syntactic");
-      CmdArgs.push_back("-analyzer-check-objc-mem");
-      CmdArgs.push_back("-analyzer-eagerly-assume");
-      CmdArgs.push_back("-analyzer-check-objc-methodsigs");
-      // Do not enable the missing -dealloc check.
-      // '-analyzer-check-objc-missing-dealloc',
-      CmdArgs.push_back("-analyzer-check-objc-unused-ivars");
-      CmdArgs.push_back("-analyzer-check-idempotent-operations");
+
+      // Checks to perform for Objective-C/Objective-C++.
+      if (types::isObjC(InputType)) {
+        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");
+
+        CmdArgs.push_back("-analyzer-eagerly-assume");
+        CmdArgs.push_back("-analyzer-check-idempotent-operations");
+      }
     }
 
     // Set the output format. The default is plist, for (lame) historical





More information about the cfe-commits mailing list