[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / Analysis / method-call-path-notes.cpp
blobc3d1a99fc9219bca7f80a24ad8e4b5c9f43f0ce7
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s
2 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file %s -o %t.plist
3 // RUN: %normalize_plist <%t.plist | diff -ub %S/Inputs/expected-plists/method-call-path-notes.cpp.plist -
5 // Test warning about null or uninitialized pointer values used as instance member
6 // calls.
7 class TestInstanceCall {
8 public:
9 void foo() {}
12 void test_ic() {
13 TestInstanceCall *p; // expected-note {{'p' declared without an initial value}}
14 p->foo(); // expected-warning {{Called C++ object pointer is uninitialized}} expected-note {{Called C++ object pointer is uninitialized}}
17 void test_ic_null() {
18 TestInstanceCall *p = 0; // expected-note {{'p' initialized to a null pointer value}}
19 p->foo(); // expected-warning {{Called C++ object pointer is null}} expected-note {{Called C++ object pointer is null}}
22 void test_ic_set_to_null() {
23 TestInstanceCall *p;
24 p = 0; // expected-note {{Null pointer value stored to 'p'}}
25 p->foo(); // expected-warning {{Called C++ object pointer is null}} expected-note {{Called C++ object pointer is null}}
28 void test_ic_null(TestInstanceCall *p) {
29 if (!p) // expected-note {{Assuming 'p' is null}} expected-note {{Taking true branch}}
30 p->foo(); // expected-warning {{Called C++ object pointer is null}} expected-note{{Called C++ object pointer is null}}
33 void test_ic_member_ptr() {
34 TestInstanceCall *p = 0; // expected-note {{'p' initialized to a null pointer value}}
35 typedef void (TestInstanceCall::*IC_Ptr)();
36 IC_Ptr bar = &TestInstanceCall::foo;
37 (p->*bar)(); // expected-warning {{Called C++ object pointer is null}} expected-note{{Called C++ object pointer is null}}
40 void test_cast(const TestInstanceCall *p) {
41 if (!p) // expected-note {{Assuming 'p' is null}} expected-note {{Taking true branch}}
42 const_cast<TestInstanceCall *>(p)->foo(); // expected-warning {{Called C++ object pointer is null}} expected-note {{Called C++ object pointer is null}}