summaryrefslogtreecommitdiffstats
path: root/clang/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
commit52de8eec01df6f5e9807ad8854ae794975426da1 (patch)
tree06bc2cd7f9bcf591b8c46d4016c256e3989acd2f /clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
parent4ac7cba404966f2fe44e94d2109480fe1bb94f6b (diff)
downloadbcm5719-llvm-52de8eec01df6f5e9807ad8854ae794975426da1.tar.gz
bcm5719-llvm-52de8eec01df6f5e9807ad8854ae794975426da1.zip
[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). llvm-svn: 164449
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
index 04eb0ad97b0..1ffd1057665 100644
--- a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ b/clang/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())
OpenPOWER on IntegriCloud