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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176576
91177308-0d34-0410-b5e6-
96231b3b80d8
/// \sa shouldAvoidSuppressingNullArgumentPaths
Optional<bool> AvoidSuppressingNullArgumentPaths;
+ /// \sa shouldSuppressInlinedDefensiveChecks
+ Optional<bool> SuppressInlinedDefensiveChecks;
+
/// \sa getGraphTrimInterval
Optional<unsigned> GraphTrimInterval;
/// option, which accepts the values "true" and "false".
bool shouldAvoidSuppressingNullArgumentPaths();
+ /// Returns whether or not diagnostics containing inlined defensive NULL
+ /// checks should be suppressed.
+ ///
+ /// This is controlled by the 'suppress-inlined-defensive-checks' config
+ /// option, which accepts the values "true" and "false".
+ bool shouldSuppressInlinedDefensiveChecks();
+
/// Returns whether irrelevant parts of a bug report path should be pruned
/// out of the final output.
///
/* 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);
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)) {
// 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);
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-inlined-defensive-checks=true -verify %s
// Perform inline defensive checks.
void idc(int *p) {