mkmvzlb created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mkmvzlb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes #39713


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150552

Files:
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/test/Analysis/Inputs/qt-simulator.h
  clang/test/Analysis/qt_malloc.cpp


Index: clang/test/Analysis/qt_malloc.cpp
===================================================================
--- clang/test/Analysis/qt_malloc.cpp
+++ clang/test/Analysis/qt_malloc.cpp
@@ -19,3 +19,8 @@
                    new QtPrivate::QSlotObjectBase(), (Qt::ConnectionType)0,
                    nullptr, nullptr);
 }
+
+void singleShot(QTimer *timer) {
+  timer->singleShotImpl(0, (Qt::TimerType)0, nullptr,
+                        new QtPrivate::QSlotObjectBase());
+}
Index: clang/test/Analysis/Inputs/qt-simulator.h
===================================================================
--- clang/test/Analysis/Inputs/qt-simulator.h
+++ clang/test/Analysis/Inputs/qt-simulator.h
@@ -6,6 +6,7 @@
 
 namespace Qt {
 enum ConnectionType {};
+enum TimerType {};
 }
 
 struct QMetaObject {
@@ -31,3 +32,8 @@
 };
 
 struct QApplication : public QCoreApplication {};
+
+struct QTimer {
+  static void singleShotImpl(int, Qt::TimerType, const QObject *,
+                             QtPrivate::QSlotObjectBase *);
+};
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -3259,6 +3259,11 @@
     return true;
   }
 
+  if (FName == "singleShotImpl" &&
+      FD->getQualifiedNameAsString() == "QTimer::singleShotImpl") {
+    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


Index: clang/test/Analysis/qt_malloc.cpp
===================================================================
--- clang/test/Analysis/qt_malloc.cpp
+++ clang/test/Analysis/qt_malloc.cpp
@@ -19,3 +19,8 @@
                    new QtPrivate::QSlotObjectBase(), (Qt::ConnectionType)0,
                    nullptr, nullptr);
 }
+
+void singleShot(QTimer *timer) {
+  timer->singleShotImpl(0, (Qt::TimerType)0, nullptr,
+                        new QtPrivate::QSlotObjectBase());
+}
Index: clang/test/Analysis/Inputs/qt-simulator.h
===================================================================
--- clang/test/Analysis/Inputs/qt-simulator.h
+++ clang/test/Analysis/Inputs/qt-simulator.h
@@ -6,6 +6,7 @@
 
 namespace Qt {
 enum ConnectionType {};
+enum TimerType {};
 }
 
 struct QMetaObject {
@@ -31,3 +32,8 @@
 };
 
 struct QApplication : public QCoreApplication {};
+
+struct QTimer {
+  static void singleShotImpl(int, Qt::TimerType, const QObject *,
+                             QtPrivate::QSlotObjectBase *);
+};
Index: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -3259,6 +3259,11 @@
     return true;
   }
 
+  if (FName == "singleShotImpl" &&
+      FD->getQualifiedNameAsString() == "QTimer::singleShotImpl") {
+    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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to