1 // RUN: %clang_analyze_cc1 -std=c++14 -w -analyzer-checker=core,cplusplus -analyzer-output=text -verify %s
3 namespace no_crash_on_delete_dtor
{
4 // We were crashing when producing diagnostics for this code, but not for the
5 // report that it currently emits. Instead, Static Analyzer was thinking that
6 // p.get()->foo() is a null dereference because it was dropping
7 // constraints over x too early and took a different branch next time
19 return (x
|| 0) ? nullptr : s
; // expected-note{{Field 'x' is 0}}
20 // expected-note@-1{{Left side of '||' is false}}
21 // expected-note@-2{{'?' condition is false}}
22 // expected-warning@-3{{Use of memory after it is freed}}
23 // expected-note@-4{{Use of memory after it is freed}}
27 void bar(smart_ptr p
) {
28 delete p
.get(); // expected-note{{Memory is released}}
29 p
.get()->foo(); // expected-note{{Calling 'smart_ptr::get'}}
31 } // namespace no_crash_on_delete_dtor