BugType BT_IllegalWhence{this, "Illegal whence argument",
"Stream handling error"};
BugType BT_StreamEof{this, "Stream already in EOF", "Stream handling error"};
- BugType BT_ResourceLeak{this, "Resource leak", "Stream handling error"};
+ BugType BT_ResourceLeak{this, "Resource leak", "Stream handling error",
+ /*SuppressOnSink =*/true};
public:
void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
ExplodedNode *
StreamChecker::reportLeaks(const SmallVector<SymbolRef, 2> &LeakedSyms,
CheckerContext &C, ExplodedNode *Pred) const {
- // Do not warn for non-closed stream at program exit.
- // FIXME: Use BugType::SuppressOnSink instead.
- if (Pred && Pred->getCFGBlock() && Pred->getCFGBlock()->hasNoReturnElement())
- return Pred;
-
ExplodedNode *Err = C.generateNonFatalErrorNode(C.getState(), Pred);
if (!Err)
return Pred;
if (!F1)
return;
if (Test == 1) {
- return; // expected-warning {{Opened stream never closed. Potential resource leak}}
+ return; // no warning
}
rewind(F1);
-} // no warning
+} // expected-warning {{Opened stream never closed. Potential resource leak}}
+// FIXME: This warning should be placed at the `return` above.
+// See https://reviews.llvm.org/D83120 about details.