r348531 - [analyzer] Fix an infinite recursion bug while checking parent methods in RetainCountChecker

George Karpenkov via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 6 14:06:44 PST 2018


Author: george.karpenkov
Date: Thu Dec  6 14:06:44 2018
New Revision: 348531

URL: http://llvm.org/viewvc/llvm-project?rev=348531&view=rev
Log:
[analyzer] Fix an infinite recursion bug while checking parent methods in RetainCountChecker

Differential Revision: https://reviews.llvm.org/D55351

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
    cfe/trunk/test/Analysis/osobject-retain-release.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=348531&r1=348530&r2=348531&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Thu Dec  6 14:06:44 2018
@@ -730,7 +730,7 @@ bool applyFunctionParamAnnotationEffect(
     if (const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
       for (const auto *OD : MD->overridden_methods()) {
         const ParmVarDecl *OP = OD->parameters()[parm_idx];
-        if (applyFunctionParamAnnotationEffect(OP, parm_idx, MD, AF, Template))
+        if (applyFunctionParamAnnotationEffect(OP, parm_idx, OD, AF, Template))
           return true;
       }
     }

Modified: cfe/trunk/test/Analysis/osobject-retain-release.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/osobject-retain-release.cpp?rev=348531&r1=348530&r2=348531&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/osobject-retain-release.cpp (original)
+++ cfe/trunk/test/Analysis/osobject-retain-release.cpp Thu Dec  6 14:06:44 2018
@@ -45,6 +45,8 @@ struct OSArray : public OSObject {
 
   OSObject *identity() override;
 
+  virtual OSObject *generateObject(OSObject *input);
+
   virtual void consumeReference(OS_CONSUME OSArray *other);
 
   static OSArray *generateArrayHasCode() {
@@ -68,6 +70,8 @@ struct MyArray : public OSArray {
   void consumeReference(OSArray *other) override;
 
   OSObject *identity() override;
+
+  OSObject *generateObject(OSObject *input) override;
 };
 
 struct OtherStruct {
@@ -79,6 +83,14 @@ struct OSMetaClassBase {
   static OSObject *safeMetaCast(const OSObject *inst, const OSMetaClass *meta);
 };
 
+void test_no_infinite_check_recursion(MyArray *arr) {
+  OSObject *input = new OSObject;
+  OSObject *o = arr->generateObject(input);
+  o->release();
+  input->release();
+}
+
+
 void check_param_attribute_propagation(MyArray *parent) {
   OSArray *arr = new OSArray;
   parent->consumeReference(arr);




More information about the cfe-commits mailing list