[PATCH] D14170: Fix false positive warning about memory leak for QApplication::postEvent
Evgeniy Dushistov via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 28 18:28:26 PDT 2015
Dushistov created this revision.
Dushistov added reviewers: Ayal, zaks.anna, dcoughlin, xazax.hun.
Dushistov added a subscriber: cfe-commits.
Recent version of clang (3.7) start complain about such code:
void send(QObject *obj)
{
QKeyEvent *event = new QKeyEvent(QEvent::KeyRelease, Qt::Key_Tab, Qt::NoModifier);
qApp->postEvent(obj, event);
}
warning: Potential leak of memory pointed to by 'event'
This is false positive, because of according to Qt documentation Qt take care about memory allocated for QEvent:
http://doc.qt.io/qt-4.8/qcoreapplication.html#postEvent
Because of Qt popular enought I suggest to handle postEvent case in MallocChecker
http://reviews.llvm.org/D14170
Files:
lib/StaticAnalyzer/Checkers/MallocChecker.cpp
Index: lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===================================================================
--- lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -2511,6 +2511,10 @@
return true;
}
+ if (FName.endswith("postEvent") || FD->getQualifiedNameAsString() == "QCoreApplication::postEvent") {
+ return true;
+ }
+
// Handle cases where we know a buffer's /address/ can escape.
// Note that the above checks handle some special cases where we know that
// even though the address escapes, it's still our responsibility to free the
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14170.38705.patch
Type: text/x-patch
Size: 624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151029/7a839421/attachment.bin>
More information about the cfe-commits
mailing list