25 lines · cpp
1// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s2// expected-no-diagnostics3 4struct Data {5 int x;6 Data *data;7};8 9int 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-warning24}25