• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
compare(Data & a,Data & b)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 }
27