diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2019-05-14 21:58:59 +0000 |
commit | b35a2aa71f76a334a9c98c0a3c3995b5d902d2b9 (patch) | |
tree | cdff4a5d1a715d4ad622fd8f190128b54bebe440 /test/Analysis/diagnostics/dtors.cpp | |
parent | 3748d41833787fcbf59cc5624e8d2b042a8991bc (diff) | |
parent | 741e05796da92b46d4f7bcbee00702ff37df6489 (diff) |
Creating branches/google/stable and tags/google/stable/2019-05-14 from r360103upstream/google/stable
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/google/stable@360714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/diagnostics/dtors.cpp')
-rw-r--r-- | test/Analysis/diagnostics/dtors.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/test/Analysis/diagnostics/dtors.cpp b/test/Analysis/diagnostics/dtors.cpp index 094917e432..b3fe7ec803 100644 --- a/test/Analysis/diagnostics/dtors.cpp +++ b/test/Analysis/diagnostics/dtors.cpp @@ -1,9 +1,11 @@ -// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,cplusplus -verify %s - -// expected-no-diagnostics +// RUN: %clang_analyze_cc1 -w -analyzer-checker=core,cplusplus -analyzer-output=text -verify %s namespace no_crash_on_delete_dtor { -// We were crashing when producing diagnostics for this code. +// We were crashing when producing diagnostics for this code, but not for the +// report that it currently emits. Instead, Static Analyzer was thinking that +// p.get()->foo() is a null dereference because it was dropping +// constraints over x too early and took a different branch next time +// we call .get(). struct S { void foo(); ~S(); @@ -14,12 +16,15 @@ struct smart_ptr { S *s; smart_ptr(S *); S *get() { - return (x || 0) ? nullptr : s; + return (x || 0) ? nullptr : s; // expected-note{{Left side of '||' is false}} + // expected-note@-1{{'?' condition is false}} + // expected-warning@-2{{Use of memory after it is freed}} + // expected-note@-3{{Use of memory after it is freed}} } }; void bar(smart_ptr p) { - delete p.get(); - p.get()->foo(); + delete p.get(); // expected-note{{Memory is released}} + p.get()->foo(); // expected-note{{Calling 'smart_ptr::get'}} } } // namespace no_crash_on_delete_dtor |