summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-01-14 22:31:31 +0000
committerTed Kremenek <kremenek@apple.com>2011-01-14 22:31:31 +0000
commitf6ab5ff7d7770a96c5940cff4662f258a2ed9e25 (patch)
tree79f7b714ead8fc28c2a56c2b6c987ef76c19cc07 /clang/lib/Driver/Tools.cpp
parent3e2f6cf7aeebc930c95cd5ac0de567f5be927faa (diff)
downloadbcm5719-llvm-f6ab5ff7d7770a96c5940cff4662f258a2ed9e25.tar.gz
bcm5719-llvm-f6ab5ff7d7770a96c5940cff4662f258a2ed9e25.zip
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. llvm-svn: 123481
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r--clang/lib/Driver/Tools.cpp35
1 files changed, 25 insertions, 10 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 50f32958d58..ba2d32328ce 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -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
OpenPOWER on IntegriCloud