[RISCV] Match vcompress during shuffle lowering (#117748)
[llvm-project.git] / clang / test / Analysis / diagnostics / undef-value-param.c
blobe88e3c98ecfc595b8506ca07929b4fb689723b14
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) {
6 if (c)
7 return;
8 c++;
9 return;
11 void foo(int c, int *x) {
12 if (c)
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'}}
16 *x = 5;
19 int use(int c) {
20 int xx; //expected-note {{'xx' declared without an initial value}}
21 int *y = &xx;
22 foo (c, y);
23 //expected-note@-1{{Calling 'foo'}}
24 //expected-note@-2{{Returning from 'foo'}}
25 foo_irrelevant(c);
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}}
33 return;
34 XYZ[0] = 1;
35 XYZ[1] = 1;
36 XYZ[2] = 1;
38 int testPassingParentRegionArray(int x) {
39 double XYZ[3];
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);
47 struct WithFields {
48 double *f1;
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) {
58 struct WithFields st;
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')}}