blob: dedc3b5b21df25cc5c0031858797b276af07c130 [file] [log] [blame]
Dominic Chen184c6242017-03-03 18:02:02 +00001// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -analyzer-config graph-trim-interval=5 -analyzer-config suppress-null-return-paths=false -verify %s
George Karpenkov39165092018-06-12 19:07:41 +00002// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config graph-trim-interval=5 -analyzer-config suppress-null-return-paths=false %s -o %t.plist
Mikhail Maltsevc704f4d2018-09-17 10:19:46 +00003// RUN: cat %t.plist | %diff_plist %S/Inputs/expected-plists/eager-reclamation-path-notes.cpp.plist
Jordan Rosebce05832013-03-08 23:30:56 +00004
5typedef struct {
6 int getValue();
7} IntWrapper;
8
9IntWrapper *getNullWrapper() {
10 return 0;
11 // expected-note@-1 {{Returning null pointer}}
12}
13
14int memberCallBaseDisappears() {
15 // In this case, we need the lvalue-to-rvalue cast for 'ptr' to disappear,
16 // which means we need to trigger reclamation between that and the ->
17 // operator.
18 //
19 // Note that this test is EXTREMELY brittle because it's a negative test:
20 // we want to show that even if the node for the rvalue of 'ptr' disappears,
21 // we get the same results as if it doesn't. The test should never fail even
22 // if our node reclamation policy changes, but it could easily not be testing
23 // anything at that point.
24 IntWrapper *ptr = getNullWrapper();
25 // expected-note@-1 {{Calling 'getNullWrapper'}}
26 // expected-note@-2 {{Returning from 'getNullWrapper'}}
27 // expected-note@-3 {{'ptr' initialized to a null pointer value}}
28
29 // Burn some nodes to trigger reclamation.
30 int unused = 1;
31 (void)unused;
32
33 return ptr->getValue(); // expected-warning {{Called C++ object pointer is null}}
34 // expected-note@-1 {{Called C++ object pointer is null}}
35}
36