1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=text -verify %s
2 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-multi-file %s -o %t.plist
3 // RUN: %normalize_plist <%t.plist | diff -ub %S/Inputs/expected-plists/undef-value-param.c.plist -
5 void foo_irrelevant(int c
) {
11 void foo(int c
, int *x
) {
13 //expected-note@-1{{Assuming 'c' is not equal to 0}}
14 //expected-note@-2{{Taking true branch}}
15 return; // expected-note{{Returning without writing to '*x'}}
20 int xx
; //expected-note {{'xx' declared without an initial value}}
23 //expected-note@-1{{Calling 'foo'}}
24 //expected-note@-2{{Returning from 'foo'}}
26 return xx
+3; //expected-warning{{The left operand of '+' is a garbage value}}
27 //expected-note@-1{{The left operand of '+' is a garbage value}}
30 void initArray(int x
, double XYZ
[3]) {
31 if (x
<= 0) //expected-note {{Taking true branch}}
32 //expected-note@-1 {{Assuming 'x' is <= 0}}
38 int testPassingParentRegionArray(int x
) {
40 initArray(x
, XYZ
); //expected-note {{Calling 'initArray'}}
41 //expected-note@-1 {{Returning from 'initArray'}}
42 return 1 * XYZ
[1]; //expected-warning {{The right operand of '*' is a garbage value}}
43 //expected-note@-1 {{The right operand of '*' is a garbage value}}
46 double *getValidPtr(void);
50 void initStruct(int x
, struct WithFields
*X
) {
51 if (x
<= 0) //expected-note {{Taking true branch}}
52 //expected-note@-1 {{Assuming 'x' is <= 0}}
54 return; //expected-note{{Returning without writing to 'X->f1'}}
55 X
->f1
= getValidPtr();
57 double testPassingParentRegionStruct(int x
) {
59 st
.f1
= 0; // expected-note {{Null pointer value stored to 'st.f1'}}
60 initStruct(x
, &st
); //expected-note {{Calling 'initStruct'}}
61 //expected-note@-1 {{Returning from 'initStruct'}}
62 return (*st
.f1
); //expected-warning {{Dereference of null pointer}}
63 //expected-note@-1{{Dereference of null pointer (loaded from field 'f1')}}