[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / Analysis / std-c-library-functions-vs-stream-checker.c
blobb99cc30149c9123b95db0cdfe2d49c08d0d39fc8
1 // Check the case when only the StreamChecker is enabled.
2 // RUN: %clang_analyze_cc1 %s \
3 // RUN: -analyzer-checker=core,unix.Stream \
4 // RUN: -analyzer-config unix.Stream:Pedantic=true \
5 // RUN: -analyzer-checker=debug.ExprInspection \
6 // RUN: -analyzer-config eagerly-assume=false \
7 // RUN: -triple x86_64-unknown-linux \
8 // RUN: -verify=stream
10 // Check the case when only the StdLibraryFunctionsChecker is enabled.
11 // RUN: %clang_analyze_cc1 %s \
12 // RUN: -analyzer-checker=unix.StdCLibraryFunctions \
13 // RUN: -analyzer-config unix.StdCLibraryFunctions:DisplayLoadedSummaries=true \
14 // RUN: -analyzer-checker=debug.ExprInspection \
15 // RUN: -analyzer-config eagerly-assume=false \
16 // RUN: -triple x86_64-unknown-linux \
17 // RUN: -verify=stdLib 2>&1 | FileCheck %s
19 // Check the case when both the StreamChecker and the
20 // StdLibraryFunctionsChecker are enabled.
21 // RUN: %clang_analyze_cc1 %s \
22 // RUN: -analyzer-checker=core,unix.Stream \
23 // RUN: -analyzer-config unix.Stream:Pedantic=true \
24 // RUN: -analyzer-checker=unix.StdCLibraryFunctions \
25 // RUN: -analyzer-config unix.StdCLibraryFunctions:DisplayLoadedSummaries=true \
26 // RUN: -analyzer-checker=debug.ExprInspection \
27 // RUN: -analyzer-config eagerly-assume=false \
28 // RUN: -triple x86_64-unknown-linux \
29 // RUN: -verify=both 2>&1 | FileCheck %s
31 // Verify that the summaries are loaded when the StdLibraryFunctionsChecker is
32 // enabled.
33 // CHECK: Loaded summary for: int getchar(void)
34 // CHECK-NEXT: Loaded summary for: unsigned long fread(void *restrict, size_t, size_t, FILE *restrict)
35 // CHECK-NEXT: Loaded summary for: unsigned long fwrite(const void *restrict, size_t, size_t, FILE *restrict)
37 #include "Inputs/system-header-simulator.h"
39 void clang_analyzer_eval(int);
41 void test_fread_fwrite(FILE *fp, int *buf) {
42 fp = fopen("foo", "r");
43 if (!fp)
44 return;
45 size_t x = fwrite(buf, sizeof(int), 10, fp);
47 clang_analyzer_eval(x <= 10); // \
48 // stream-warning{{TRUE}} \
49 // stdLib-warning{{TRUE}} \
50 // both-warning{{TRUE}}
52 clang_analyzer_eval(x == 10); // \
53 // stream-warning{{TRUE}} \
54 // stream-warning{{FALSE}} \
55 // stdLib-warning{{TRUE}} \
56 // stdLib-warning{{FALSE}} \
57 // both-warning{{TRUE}} \
58 // both-warning{{FALSE}}
60 fclose(fp);