1 // 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
2 // 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
3 // RUN: %normalize_plist <%t.plist | diff -ub %S/Inputs/expected-plists/eager-reclamation-path-notes.cpp.plist -
4
5 struct IntWrapper {
6 int getValue();
7 };
8
getNullWrapper()9 IntWrapper *getNullWrapper() {
10 return 0;
11 // expected-note@-1 {{Returning null pointer}}
12 }
13
memberCallBaseDisappears()14 int 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
37