[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / ctu-on-demand-parsing.c
blob07a72a1046467a35ff64ac1512985c5dd4a15771
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: cp "%s" "%t/ctu-on-demand-parsing.c"
4 // RUN: cp "%S/Inputs/ctu-other.c" "%t/ctu-other.c"
5 //
6 // Path substitutions on Windows platform could contain backslashes. These are escaped in the json file.
7 // compile_commands.json is only needed for extdef_mapping, not for the analysis itself.
8 // RUN: echo '[{"directory":"%t","command":"gcc -std=c89 -Wno-visibility ctu-other.c","file":"ctu-other.c"}]' | sed -e 's/\\/\\\\/g' > %t/compile_commands.json
9 //
10 // RUN: echo '"%t/ctu-other.c": ["gcc", "-std=c89", "-Wno-visibility", "ctu-other.c"]' | sed -e 's/\\/\\\\/g' > %t/invocations.yaml
12 // RUN: cd "%t" && %clang_extdef_map "%t/ctu-other.c" > externalDefMap.txt
14 // RUN: cd "%t" && %clang_cc1 -fsyntax-only -std=c89 -analyze \
15 // RUN: -analyzer-checker=core,debug.ExprInspection \
16 // RUN: -analyzer-config experimental-enable-naive-ctu-analysis=true \
17 // RUN: -analyzer-config ctu-dir=. \
18 // RUN: -analyzer-config ctu-invocation-list=invocations.yaml \
19 // RUN: -verify ctu-on-demand-parsing.c
21 // FIXME: Path handling should work on all platforms.
22 // REQUIRES: system-linux
24 void clang_analyzer_eval(int);
26 // Test typedef and global variable in function.
27 typedef struct {
28 int a;
29 int b;
30 } FooBar;
31 extern FooBar fb;
32 int f(int);
33 void testGlobalVariable() {
34 clang_analyzer_eval(f(5) == 1); // expected-warning{{TRUE}}
37 // Test enums.
38 int enumCheck(void);
39 enum A { x,
41 z };
42 void testEnum() {
43 clang_analyzer_eval(x == 0); // expected-warning{{TRUE}}
44 clang_analyzer_eval(enumCheck() == 42); // expected-warning{{TRUE}}
47 // Test that asm import does not fail.
48 int inlineAsm();
49 int testInlineAsm() { return inlineAsm(); }
51 // Test reporting error in a macro.
52 struct S;
53 int g(struct S *);
54 void testMacro(void) {
55 g(0);
56 // expected-warning@ctu-other.c:29 {{Access to field 'a' results in a dereference of a null pointer (loaded from variable 'ctx')}}
59 // The external function prototype is incomplete.
60 // warning:implicit functions are prohibited by c99
61 void testImplicit() {
62 int res = identImplicit(6); // external implicit functions are not inlined
63 clang_analyzer_eval(res == 6); // expected-warning{{TRUE}}
64 // Call something with uninitialized from the same function in which the
65 // implicit was called. This is necessary to reproduce a special bug in
66 // NoStoreFuncVisitor.
67 int uninitialized;
68 h(uninitialized); // expected-warning{{1st function call argument is an uninitialized value}}
71 // Tests the import of functions that have a struct parameter
72 // defined in its prototype.
73 struct DataType {
74 int a;
75 int b;
77 int structInProto(struct DataType *d);
78 void testStructDefInArgument() {
79 struct DataType d;
80 d.a = 1;
81 d.b = 0;
82 clang_analyzer_eval(structInProto(&d) == 0); // expected-warning{{TRUE}} expected-warning{{FALSE}}