// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=text -analyzer-config graph-trim-interval=5 -analyzer-config suppress-null-return-paths=false -verify %s // RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist-multi-file -analyzer-config graph-trim-interval=5 -analyzer-config suppress-null-return-paths=false -analyzer-config path-diagnostics-alternate=false %s -o %t.plist // RUN: FileCheck --input-file=%t.plist %s typedef struct { int getValue(); } IntWrapper; IntWrapper *getNullWrapper() { return 0; // expected-note@-1 {{Returning null pointer}} } int memberCallBaseDisappears() { // In this case, we need the lvalue-to-rvalue cast for 'ptr' to disappear, // which means we need to trigger reclamation between that and the -> // operator. // // Note that this test is EXTREMELY brittle because it's a negative test: // we want to show that even if the node for the rvalue of 'ptr' disappears, // we get the same results as if it doesn't. The test should never fail even // if our node reclamation policy changes, but it could easily not be testing // anything at that point. IntWrapper *ptr = getNullWrapper(); // expected-note@-1 {{Calling 'getNullWrapper'}} // expected-note@-2 {{Returning from 'getNullWrapper'}} // expected-note@-3 {{'ptr' initialized to a null pointer value}} // Burn some nodes to trigger reclamation. int unused = 1; (void)unused; return ptr->getValue(); // expected-warning {{Called C++ object pointer is null}} // expected-note@-1 {{Called C++ object pointer is null}} } // CHECK: diagnostics // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: path // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol // CHECK-NEXT: edges // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: start // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col3 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col12 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: end // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col21 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col34 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindevent // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col21 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: ranges // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col21 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col36 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message // CHECK-NEXT: Calling 'getNullWrapper' // CHECK-NEXT: message // CHECK-NEXT: Calling 'getNullWrapper' // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindevent // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line9 // CHECK-NEXT: col1 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: depth1 // CHECK-NEXT: extended_message // CHECK-NEXT: Entered call from 'memberCallBaseDisappears' // CHECK-NEXT: message // CHECK-NEXT: Entered call from 'memberCallBaseDisappears' // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol // CHECK-NEXT: edges // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: start // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line9 // CHECK-NEXT: col1 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line9 // CHECK-NEXT: col10 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: end // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line10 // CHECK-NEXT: col3 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line10 // CHECK-NEXT: col8 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindevent // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line10 // CHECK-NEXT: col3 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: ranges // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line10 // CHECK-NEXT: col3 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line10 // CHECK-NEXT: col10 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: depth1 // CHECK-NEXT: extended_message // CHECK-NEXT: Returning null pointer // CHECK-NEXT: message // CHECK-NEXT: Returning null pointer // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindevent // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col21 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: ranges // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col21 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col36 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message // CHECK-NEXT: Returning from 'getNullWrapper' // CHECK-NEXT: message // CHECK-NEXT: Returning from 'getNullWrapper' // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol // CHECK-NEXT: edges // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: start // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col21 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col34 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: end // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col3 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col12 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindevent // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col3 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: ranges // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col3 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col17 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message // CHECK-NEXT: 'ptr' initialized to a null pointer value // CHECK-NEXT: message // CHECK-NEXT: 'ptr' initialized to a null pointer value // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol // CHECK-NEXT: edges // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: start // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col3 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line24 // CHECK-NEXT: col12 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: end // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line33 // CHECK-NEXT: col3 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line33 // CHECK-NEXT: col8 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindcontrol // CHECK-NEXT: edges // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: start // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line33 // CHECK-NEXT: col3 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line33 // CHECK-NEXT: col8 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: end // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line33 // CHECK-NEXT: col10 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line33 // CHECK-NEXT: col12 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: kindevent // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line33 // CHECK-NEXT: col10 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: ranges // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line33 // CHECK-NEXT: col10 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: line33 // CHECK-NEXT: col12 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: depth0 // CHECK-NEXT: extended_message // CHECK-NEXT: Called C++ object pointer is null // CHECK-NEXT: message // CHECK-NEXT: Called C++ object pointer is null // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: descriptionCalled C++ object pointer is null // CHECK-NEXT: categoryLogic error // CHECK-NEXT: typeCalled C++ object pointer is null // CHECK-NEXT: issue_context_kindfunction // CHECK-NEXT: issue_contextmemberCallBaseDisappears // CHECK-NEXT: issue_hash19 // CHECK-NEXT: location // CHECK-NEXT: // CHECK-NEXT: line33 // CHECK-NEXT: col10 // CHECK-NEXT: file0 // CHECK-NEXT: // CHECK-NEXT: // CHECK-NEXT: