[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Analysis / std-c-library-functions-path-notes.c
blobbc4e9035b15fe367fce8cf82315fd4219f045cb5
1 // RUN: %clang_analyze_cc1 -verify %s \
2 // RUN: -analyzer-checker=core,apiModeling \
3 // RUN: -analyzer-output=text
5 #define NULL ((void *)0)
7 char *getenv(const char *);
8 int isalpha(int);
9 int isdigit(int);
10 int islower(int);
12 char test_getenv() {
13 char *env = getenv("VAR"); // \
14 // expected-note{{Assuming the environment variable does not exist}} \
15 // expected-note{{'env' initialized here}}
17 return env[0]; // \
18 // expected-warning{{Array access (from variable 'env') results in a null pointer dereference}} \
19 // expected-note {{Array access (from variable 'env') results in a null pointer dereference}}
22 int test_isalpha(int *x, char c) {
23 if (isalpha(c)) {// \
24 // expected-note{{Assuming the character is alphabetical}} \
25 // expected-note{{Taking true branch}}
26 x = NULL; // \
27 // expected-note{{Null pointer value stored to 'x'}}
30 return *x; // \
31 // expected-warning{{Dereference of null pointer (loaded from variable 'x')}} \
32 // expected-note {{Dereference of null pointer (loaded from variable 'x')}}
35 int test_isdigit(int *x, char c) {
36 if (!isdigit(c)) {// \
37 // expected-note{{Assuming the character is not a digit}} \
38 // expected-note{{Taking true branch}}
39 x = NULL; // \
40 // expected-note{{Null pointer value stored to 'x'}}
43 return *x; // \
44 // expected-warning{{Dereference of null pointer (loaded from variable 'x')}} \
45 // expected-note {{Dereference of null pointer (loaded from variable 'x')}}
48 int test_islower(int *x) {
49 char c = 'c';
50 // No "Assuming..." note. We aren't assuming anything. We *know*.
51 if (islower(c)) { // \
52 // expected-note{{Taking true branch}}
53 x = NULL; // \
54 // expected-note{{Null pointer value stored to 'x'}}
57 return *x; // \
58 // expected-warning{{Dereference of null pointer (loaded from variable 'x')}} \
59 // expected-note {{Dereference of null pointer (loaded from variable 'x')}}