[PATCH] D83120: [Analyzer][StreamChecker] Using BugType::SuppressOnSink at resource leak report.
Balázs Kéri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 3 01:35:28 PDT 2020
balazske created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, gamesh411, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a project: clang.
The previous check at report create is not needed, the similar built-in
functionality in BugType is used instead.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83120
Files:
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
clang/test/Analysis/stream.c
Index: clang/test/Analysis/stream.c
===================================================================
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -278,7 +278,7 @@
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}}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -204,7 +204,7 @@
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", true};
public:
void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -965,11 +965,6 @@
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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83120.275323.patch
Type: text/x-patch
Size: 1657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200703/a96165ff/attachment-0001.bin>
More information about the cfe-commits
mailing list