1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
struct Data1;
struct Data1
{
int val;
Data1 *ptrval;
int arr[3];
};
struct Data2 : public Data1
{
};
int k;
void paranuckerInternalTest(const char *action, const char *collection, const char *values);
class Object1
{
Data1 *tmp1;
Data1 *tmp2;
Data1 *getData()
{
return tmp1;
}
void func1(Data1 *ptr1)
{
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "ptr1");
// null || 9 -> return
// null || 10 -> return
// 123 || 9 -> continue
// 123 || 10 -> return
if (!ptr1 || ptr1->val == 10)
{
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "ptr1");
return;
}
else
{
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "ptr1");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "");
}
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "ptr1");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "");
}
void func2(Data1 *ptr1)
{
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "ptr1");
// null && 9 -> continue
// null && 10 -> return
// 123 && 9 -> continue
// 123 && 10 -> continue
if (!ptr1 && ptr1->val == 10)
{
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "");
paranuckerInternalTest("=", "knownNullVars", "ptr1");
paranuckerInternalTest("=", "needCheckNullVars", "ptr1");
return;
}
else
{
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "ptr1");
}
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "ptr1");
}
void func3(Data1 *ptr1)
{
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "ptr1");
// null && 9 -> continue
// null && 10 -> continue
// 123 && 9 -> continue
// 123 && 10 -> return
if (ptr1 && ptr1->val == 10)
{
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "ptr1");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "");
return;
}
else
{
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "ptr1");
}
paranuckerInternalTest("=", "knownVars", "ptr1");
paranuckerInternalTest("=", "knownNonNullVars", "");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "ptr1");
}
void func4(Data1 *ptr1, Data1 *ptr2) __attribute__((nonnull (3)))
{
paranuckerInternalTest("=", "knownVars", "ptr1 ptr2");
paranuckerInternalTest("=", "knownNonNullVars", "ptr2");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "ptr1");
if (!ptr2)
return;
paranuckerInternalTest("=", "knownVars", "ptr1 ptr2");
paranuckerInternalTest("=", "knownNonNullVars", "ptr2");
paranuckerInternalTest("=", "knownNullVars", "");
paranuckerInternalTest("=", "needCheckNullVars", "ptr1");
}
};
|