diff options
author | Anna Zaks <ganna@apple.com> | 2013-03-06 20:25:59 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2013-03-06 20:25:59 +0000 |
commit | 6fe2fc633aa736253317340154127329bee73fe7 (patch) | |
tree | 14c1212a2090d0ed57b22c974558135cd479d900 /clang/lib/StaticAnalyzer | |
parent | f58b12d8ebc6721956d1a873e9d775746dfd6fd0 (diff) | |
download | bcm5719-llvm-6fe2fc633aa736253317340154127329bee73fe7.tar.gz bcm5719-llvm-6fe2fc633aa736253317340154127329bee73fe7.zip |
[analyzer] IDC: Add config option; perform the idc check on first “null node” rather than last “non-null”.
The second modification does not lead to any visible result, but, theoretically, is what we should
have been looking at to begin with since we are checking if the node was assumed to be null in
an inlined function.
llvm-svn: 176576
Diffstat (limited to 'clang/lib/StaticAnalyzer')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp | 6 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 9 |
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp index 5198f4973ad..dca68f71ab5 100644 --- a/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp +++ b/clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp @@ -152,6 +152,12 @@ bool AnalyzerOptions::shouldAvoidSuppressingNullArgumentPaths() { /* Default = */ false); } +bool AnalyzerOptions::shouldSuppressInlinedDefensiveChecks() { + return getBooleanOption(SuppressInlinedDefensiveChecks, + "suppress-inlined-defensive-checks", + /* Default = */ true); +} + int AnalyzerOptions::getOptionAsInteger(StringRef Name, int DefaultVal) { SmallString<10> StrBuf; llvm::raw_svector_ostream OS(StrBuf); diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index b4ba2d47890..248f21cb719 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -690,7 +690,12 @@ SuppressInlineDefensiveChecksVisitor::VisitNode(const ExplodedNode *N, BugReport &BR) { if (IsSatisfied) return 0; - + + AnalyzerOptions &Options = + BRC.getBugReporter().getEngine().getAnalysisManager().options; + if (!Options.shouldSuppressInlinedDefensiveChecks()) + return 0; + // Check if in the previous state it was feasible for this value // to *not* be null. if (PrevN->getState()->assume(V, true)) { @@ -700,7 +705,7 @@ SuppressInlineDefensiveChecksVisitor::VisitNode(const ExplodedNode *N, // is non-null in N could lead to false negatives. // Check if this is inline defensive checks. - const LocationContext *CurLC = PrevN->getLocationContext(); + const LocationContext *CurLC = N->getLocationContext(); const LocationContext *ReportLC = BR.getErrorNode()->getLocationContext(); if (CurLC != ReportLC && !CurLC->isParentOf(ReportLC)) BR.markInvalid("Suppress IDC", CurLC); |