1 // RUN: %clang_analyze_cc1 -verify -analyzer-output text %s \
2 // RUN: -analyzer-checker=core \
3 // RUN: -analyzer-checker=debug.ExprInspection \
4 // RUN: -analyzer-checker=apiModeling.StdCLibraryFunctions \
5 // RUN: -analyzer-checker=apiModeling.Errno \
6 // RUN: -analyzer-checker=alpha.unix.Errno \
7 // RUN: -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true
9 #include "Inputs/errno_var.h"
11 int access(const char *path
, int amode
);
13 void clang_analyzer_warnIfReached();
16 access("path", 0); // no note here
18 // expected-note@-1{{Assuming that function 'access' is successful, in this case the value 'errno' may be undefined after the call and should not be used}}
20 // expected-warning@-1{{An undefined value may be read from 'errno'}}
21 // expected-note@-2{{An undefined value may be read from 'errno'}}
26 if (access("path", 0) == -1) {
27 // expected-note@-1{{Taking true branch}}
30 // expected-note@-1{{'errno' is not equal to 0}}
31 // expected-note@-2{{Taking true branch}}
32 clang_analyzer_warnIfReached(); // expected-note {{REACHABLE}} expected-warning {{REACHABLE}}
34 clang_analyzer_warnIfReached(); // no-warning: We are on the failure path.
40 if (access("path", 0) != -1) {
42 // expected-note@-2{{Assuming that function 'access' is successful, in this case the value 'errno' may be undefined after the call and should not be used}}
43 // expected-note@-3{{Taking true branch}}
45 // expected-warning@-1{{An undefined value may be read from 'errno'}}
46 // expected-note@-2{{An undefined value may be read from 'errno'}}