]> granicus.if.org Git - clang/commitdiff
Driver: tweak handling of '--analyze' to invoke
authorTed Kremenek <kremenek@apple.com>
Fri, 14 Jan 2011 22:31:31 +0000 (22:31 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 14 Jan 2011 22:31:31 +0000 (22:31 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123481 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp

index 50f32958d5843f9492b96780198ad90c2f64bba0..ba2d32328ce00b0b29a18f9f3e44d938b338c8c0 100644 (file)
@@ -901,17 +901,32 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
 
     // 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