[PATCH] D53660: [analyzer] [RetainCountChecker] Do not invalidate references passed to constructors and operators
George Karpenkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 25 16:41:07 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL345340: [analyzer] [RetainCountChecker] Do not invalidate references passed to… (authored by george.karpenkov, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D53660?vs=170934&id=171226#toc
Repository:
rL LLVM
https://reviews.llvm.org/D53660
Files:
cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
cfe/trunk/test/Analysis/osobject-retain-release.cpp
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
===================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/RetainSummaryManager.h
@@ -139,7 +139,7 @@
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
};
Index: cfe/trunk/test/Analysis/osobject-retain-release.cpp
===================================================================
--- cfe/trunk/test/Analysis/osobject-retain-release.cpp
+++ cfe/trunk/test/Analysis/osobject-retain-release.cpp
@@ -43,6 +43,7 @@
struct OtherStruct {
static void doNothingToArray(OSArray *array);
+ OtherStruct(OSArray *arr);
};
struct OSMetaClassBase {
@@ -55,6 +56,12 @@
} // expected-warning{{Potential leak of an object stored into 'arr'}}
// expected-note at -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 at -1{{Object leaked}}
+}
+
void check_rc_consumed() {
OSArray *arr = OSArray::withCapacity(10);
OSArray::consumeArray(arr);
Index: cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
===================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/RetainSummaryManager.cpp
@@ -478,8 +478,12 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53660.171226.patch
Type: text/x-patch
Size: 2382 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181025/55cc9755/attachment.bin>
More information about the llvm-commits
mailing list