]> granicus.if.org Git - clang/commitdiff
[analyzer] Resolve another bug where the name of the leaked object was not printed...
authorGeorge Karpenkov <ekarpenkov@apple.com>
Tue, 11 Dec 2018 01:13:20 +0000 (01:13 +0000)
committerGeorge Karpenkov <ekarpenkov@apple.com>
Tue, 11 Dec 2018 01:13:20 +0000 (01:13 +0000)
Differential Revision: https://reviews.llvm.org/D55528

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348819 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
test/Analysis/osobject-retain-release.cpp

index b5828dbab2878c9e6cebe6d90e51e05069f4faa0..d2dbcbdcd33a4f41766422fdaed7e8e0c35c1f32 100644 (file)
@@ -405,11 +405,11 @@ static AllocationInfo GetAllocationSite(ProgramStateManager &StateMgr,
 
     if (FB) {
       const MemRegion *R = FB.getRegion();
-      const VarRegion *VR = R->getBaseRegion()->getAs<VarRegion>();
       // Do not show local variables belonging to a function other than
       // where the error is reported.
-      if (!VR || VR->getStackFrame() == LeakContext->getStackFrame())
-        FirstBinding = R;
+      if (auto MR = dyn_cast<StackSpaceRegion>(R->getMemorySpace()))
+        if (MR->getStackFrame() == LeakContext->getStackFrame())
+          FirstBinding = R;
     }
 
     // AllocationNode is the last node in which the symbol was tracked.
index 68529e9e972c09b1541fb3996dc6352e87cdf714..b7a299da91de7db9c0c02075a2bf4c326df3584e 100644 (file)
@@ -153,8 +153,8 @@ void check_free_use_after_free() {
 
 unsigned int check_leak_explicit_new() {
   OSArray *arr = new OSArray; // expected-note{{Operator new returns an OSObject of type OSArray with a +1 retain count}}
-  return arr->getCount(); // expected-note{{Object leaked: allocated object of type OSArray is not referenced later in this execution path and has a retain count of +1}}
-                          // expected-warning@-1{{Potential leak of an object of type OSArray}}
+  return arr->getCount(); // expected-note{{Object leaked: object allocated and stored into 'arr' is not referenced later in this execution path and has a retain count of +1}}
+                          // expected-warning@-1{{Potential leak of an object stored into 'arr'}}
 }
 
 unsigned int check_leak_factory() {