1 // Check that the more specific checkers report and not the generic
2 // StdCLibraryFunctions checker.
4 // RUN: %clang_analyze_cc1 %s \
5 // RUN: -analyzer-checker=core \
6 // RUN: -analyzer-checker=unix.Stream \
7 // RUN: -analyzer-checker=unix.StdCLibraryFunctions \
8 // RUN: -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true \
9 // RUN: -triple x86_64-unknown-linux-gnu \
13 // Make sure that all used functions have their summary loaded.
15 // RUN: %clang_analyze_cc1 %s \
16 // RUN: -analyzer-checker=core \
17 // RUN: -analyzer-checker=unix.StdCLibraryFunctions \
18 // RUN: -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true \
19 // RUN: -analyzer-config unix.StdCLibraryFunctions:DisplayLoadedSummaries=true \
20 // RUN: -triple x86_64-unknown-linux 2>&1 | FileCheck %s
22 // CHECK: Loaded summary for: int isalnum(int)
23 // CHECK: Loaded summary for: unsigned long fread(void *restrict, size_t, size_t, FILE *restrict) __attribute__((nonnull(1)))
24 // CHECK: Loaded summary for: int fileno(FILE *stream)
26 void initializeSummaryMap(void);
27 // We analyze this function first, and the call expression inside initializes
28 // the summary map. This way we force the loading of the summaries. The
29 // summaries would not be loaded without this because during the first bug
30 // report in WeakDependency::checkPreCall we stop further evaluation. And
31 // StdLibraryFunctionsChecker lazily initializes its summary map from its
33 void analyzeThisFirst(void) {
34 initializeSummaryMap();
37 typedef __typeof(sizeof(int)) size_t;
39 typedef struct FILE FILE;
42 size_t fread(void *restrict
, size_t, size_t, FILE *restrict
) __attribute__((nonnull(1)));
43 int fileno(FILE *stream
);
45 void test_uninit_arg(void) {
47 int r
= isalnum(v
); // \
48 // expected-warning{{1st function call argument is an uninitialized value [core.CallAndMessage]}}
52 void test_notnull_arg(FILE *F
) {
54 fread(p
, sizeof(int), 5, F
); // \
55 expected
-warning
{{Null pointer passed to
1st parameter expecting
'nonnull' [core
.NonNullParamChecker
]}}
58 void test_notnull_stream_arg(void) {
60 // expected-warning{{Stream pointer might be NULL [unix.Stream]}}