Author: george.karpenkov Date: Thu Oct 25 16:38:41 2018 New Revision: 345340
URL: http://llvm.org/viewvc/llvm-project?rev=345340&view=rev Log: [analyzer] [RetainCountChecker] Do not invalidate references passed to constructors and operators Differential Revision: https://reviews.llvm.org/D53660 Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp cfe/trunk/test/Analysis/osobject-retain-release.cpp Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h?rev=345340&r1=345339&r2=345340&view=diff ============================================================================== --- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h (original) +++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h Thu Oct 25 16:38:41 2018 @@ -139,7 +139,7 @@ public: OwnedWhenTrackedReceiver, // Treat this function as returning a non-tracked symbol even if // the function has been inlined. This is used where the call - // site summary is more presise than the summary indirectly produced + // site summary is more precise than the summary indirectly produced // by inlining the function NoRetHard }; Modified: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp?rev=345340&r1=345339&r2=345340&view=diff ============================================================================== --- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp (original) +++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp Thu Oct 25 16:38:41 2018 @@ -478,8 +478,12 @@ RetainSummaryManager::getSummary(const C Summ = getFunctionSummary(cast<CXXMemberCall>(Call).getDecl()); break; case CE_CXXMemberOperator: - case CE_Block: + Summ = getFunctionSummary(cast<CXXMemberOperatorCall>(Call).getDecl()); + break; case CE_CXXConstructor: + Summ = getFunctionSummary(cast<CXXConstructorCall>(Call).getDecl()); + break; + case CE_Block: case CE_CXXDestructor: case CE_CXXAllocator: // FIXME: These calls are currently unsupported. 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=345340&r1=345339&r2=345340&view=diff ============================================================================== --- cfe/trunk/test/Analysis/osobject-retain-release.cpp (original) +++ cfe/trunk/test/Analysis/osobject-retain-release.cpp Thu Oct 25 16:38:41 2018 @@ -43,6 +43,7 @@ struct OSArray : public OSObject { struct OtherStruct { static void doNothingToArray(OSArray *array); + OtherStruct(OSArray *arr); }; struct OSMetaClassBase { @@ -55,6 +56,12 @@ void check_no_invalidation() { } // expected-warning{{Potential leak of an object stored into 'arr'}} // expected-note@-1{{Object leaked}} +void check_no_invalidation_other_struct() { + OSArray *arr = OSArray::withCapacity(10); // expected-note{{Call to function 'withCapacity' returns an OSObject of type struct OSArray * with a +1 retain count}} + OtherStruct other(arr); // expected-warning{{Potential leak}} + // expected-note@-1{{Object leaked}} +} + void check_rc_consumed() { OSArray *arr = OSArray::withCapacity(10); OSArray::consumeArray(arr); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits