Valeriy Savchenko | e63b488f | 2020-07-07 11:36:20 +0300 | [diff] [blame] | 1 | // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s |
| 2 | |
| 3 | // rdar://problem/56586853 |
| 4 | // expected-no-diagnostics |
| 5 | |
| 6 | struct Data { |
| 7 | int x; |
| 8 | Data *data; |
| 9 | }; |
| 10 | |
| 11 | int compare(Data &a, Data &b) { |
| 12 | Data *aData = a.data; |
| 13 | Data *bData = b.data; |
| 14 | |
| 15 | // Covers the cases where both pointers are null as well as both pointing to the same buffer. |
| 16 | if (aData == bData) |
| 17 | return 0; |
| 18 | |
| 19 | if (aData && !bData) |
| 20 | return 1; |
| 21 | |
| 22 | if (!aData && bData) |
| 23 | return -1; |
| 24 | |
| 25 | return compare(*aData, *bData); // no-warning |
| 26 | } |