[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / test / Analysis / errno-notes.c
blob711acc0f5db81ad84de364ccb5f38e8f2fd3eff2
1 // RUN: %clang_analyze_cc1 -verify -analyzer-output text %s \
2 // RUN: -analyzer-checker=core \
3 // RUN: -analyzer-checker=apiModeling.Errno \
4 // RUN: -analyzer-checker=debug.ExprInspection \
5 // RUN: -analyzer-checker=debug.ErrnoTest \
6 // RUN: -analyzer-checker=alpha.unix.Errno \
7 // RUN: -DERRNO_VAR
9 // RUN: %clang_analyze_cc1 -verify -analyzer-output text %s \
10 // RUN: -analyzer-checker=core \
11 // RUN: -analyzer-checker=apiModeling.Errno \
12 // RUN: -analyzer-checker=debug.ExprInspection \
13 // RUN: -analyzer-checker=debug.ErrnoTest \
14 // RUN: -analyzer-checker=alpha.unix.Errno \
15 // RUN: -DERRNO_FUNC
17 #include "Inputs/errno_var.h"
18 #include "Inputs/system-header-simulator.h"
19 #ifdef ERRNO_VAR
20 #include "Inputs/errno_var.h"
21 #endif
22 #ifdef ERRNO_FUNC
23 #include "Inputs/errno_func.h"
24 #endif
26 int ErrnoTesterChecker_setErrnoCheckState();
28 void something();
30 void testErrnoCheckUndefRead() {
31 int X = ErrnoTesterChecker_setErrnoCheckState();
32 something();
33 X = ErrnoTesterChecker_setErrnoCheckState(); // expected-note{{Assuming that this function succeeds but sets 'errno' to an unspecified value}}
34 if (X == 0) { // expected-note{{'X' is equal to 0}}
35 // expected-note@-1{{Taking true branch}}
36 if (errno) {
37 } // expected-warning@-1{{An undefined value may be read from 'errno'}}
38 // expected-note@-2{{An undefined value may be read from 'errno'}}
42 void testErrnoCheckOverwrite() {
43 int X = ErrnoTesterChecker_setErrnoCheckState();
44 something();
45 X = ErrnoTesterChecker_setErrnoCheckState(); // expected-note{{Assuming that this function returns 2. 'errno' should be checked to test for failure}}
46 if (X == 2) { // expected-note{{'X' is equal to 2}}
47 // expected-note@-1{{Taking true branch}}
48 errno = 0; // expected-warning{{Value of 'errno' was not checked and is overwritten here}}
49 // expected-note@-1{{Value of 'errno' was not checked and is overwritten here}}
53 void testErrnoCheckOverwriteStdCall() {
54 int X = ErrnoTesterChecker_setErrnoCheckState();
55 something();
56 X = ErrnoTesterChecker_setErrnoCheckState(); // expected-note{{Assuming that this function returns 2. 'errno' should be checked to test for failure}}
57 if (X == 2) { // expected-note{{'X' is equal to 2}}
58 // expected-note@-1{{Taking true branch}}
59 printf(""); // expected-warning{{Value of 'errno' was not checked and may be overwritten by function 'printf'}}
60 // expected-note@-1{{Value of 'errno' was not checked and may be overwritten by function 'printf'}}