aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-09-22 01:25:06 +0000
committerJordan Rose <jordan_rose@apple.com>2012-09-22 01:25:06 +0000
commitb9d4e5e3bb235f1149e99d3c833ff7cb3474c9f1 (patch)
tree99fbff9f24fa7164b0bde76e7a0c3c5af4cb0475 /lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
parent53221da865144db0ba6bd89ab30bcf81de0fe5d2 (diff)
[analyzer] Suppress bugs whose paths go through the return of a null pointer.
This is a heuristic intended to greatly reduce the number of false positives resulting from inlining, particularly inlining of generic, defensive C++ methods that live in header files. The suppression is triggered in the cases where we ask to track where a null pointer came from, and it turns out that the source of the null pointer was an inlined function call. This change brings the number of bug reports in LLVM from ~1500 down to around ~300, a much more manageable number. Yes, some true positives may be hidden as well, but from what I looked at the vast majority of silenced reports are false positives, and many of the true issues found by the analyzer are still reported. I'm hoping to improve this heuristic further by adding some exceptions next week (cases in which a bug should still be reported). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/AnalyzerOptions.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/AnalyzerOptions.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
index 04eb0ad97b..1ffd105766 100644
--- a/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ b/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -90,6 +90,14 @@ bool AnalyzerOptions::mayInlineObjCMethod() const {
return *ObjCInliningMode;
}
+bool AnalyzerOptions::shouldPruneNullReturnPaths() const {
+ if (!PruneNullReturnPaths.hasValue())
+ const_cast<llvm::Optional<bool> &>(PruneNullReturnPaths) =
+ getBooleanOption("suppress-null-return-paths", /*Default=*/true);
+
+ return *PruneNullReturnPaths;
+}
+
int AnalyzerOptions::getOptionAsInteger(StringRef Name, int DefaultVal) const {
std::string OptStr = Config.lookup(Name);
if (OptStr.empty())