Debian Codegraph @

clang/test/Analysis/mutually_exclusive_null_fp.cpp

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