Dominic Chen | 184c624 | 2017-03-03 18:02:02 +0000 | [diff] [blame] | 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 |
George Karpenkov | 3916509 | 2018-06-12 19:07:41 +0000 | [diff] [blame] | 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 |
Mikhail Maltsev | c704f4d | 2018-09-17 10:19:46 +0000 | [diff] [blame] | 3 | // RUN: cat %t.plist | %diff_plist %S/Inputs/expected-plists/eager-reclamation-path-notes.cpp.plist |
Jordan Rose | bce0583 | 2013-03-08 23:30:56 +0000 | [diff] [blame] | 4 | |
| 5 | typedef struct { |
| 6 | int getValue(); |
| 7 | } IntWrapper; |
| 8 | |
| 9 | IntWrapper *getNullWrapper() { |
| 10 | return 0; |
| 11 | // expected-note@-1 {{Returning null pointer}} |
| 12 | } |
| 13 | |
| 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 | |