Ted Kremenek | a7e8a83 | 2011-11-11 00:46:43 +0000 | [diff] [blame] | 1 | void foo() { |
| 2 | int voodoo; |
| 3 | voodoo = voodoo + 1; |
| 4 | } |
| 5 | |
| 6 | void bar() { |
| 7 | int dragon; |
| 8 | dragon = dragon + 1 |
| 9 | } |
| 10 | |
Ted Kremenek | 952538d | 2011-11-29 00:30:52 +0000 | [diff] [blame] | 11 | // Test handling of FixIts that only remove text. |
| 12 | int baz(); |
| 13 | void qux(int x) { |
| 14 | if ((x == baz())) |
| 15 | return; |
| 16 | } |
| 17 | |
Ted Kremenek | 2a76410 | 2011-12-17 05:26:11 +0000 | [diff] [blame] | 18 | // Test handling of macros. |
| 19 | void taz(int x, int y); |
| 20 | #define false 0 |
| 21 | void testMacro() { |
| 22 | taz(0, 0, false); |
| 23 | } |
| 24 | |
| 25 | // Test handling of issues from #includes. |
| 26 | #include "serialized-diags.h" |
| 27 | |
Ted Kremenek | 3739b32 | 2012-03-20 20:49:45 +0000 | [diff] [blame] | 28 | // Test handling of warnings that have empty fixits. |
| 29 | void rdar11040133() { |
| 30 | unsigned x; |
| 31 | } |
| 32 | |
NAKAMURA Takumi | 6edae59 | 2011-11-11 05:12:45 +0000 | [diff] [blame] | 33 | // RUN: rm -f %t |
Richard Smith | 9867eba | 2012-12-05 22:33:14 +0000 | [diff] [blame] | 34 | // RUN: not %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.diag > /dev/null 2>&1 |
Ted Kremenek | 3739b32 | 2012-03-20 20:49:45 +0000 | [diff] [blame] | 35 | // RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1 |
| 36 | // RUN: FileCheck --input-file=%t %s |
Ted Kremenek | a7e8a83 | 2011-11-11 00:46:43 +0000 | [diff] [blame] | 37 | |
| 38 | // This test case tests that we can handle multiple diagnostics which contain |
| 39 | // FIXITs at different levels (one at the note, another at the main diagnostic). |
| 40 | |
NAKAMURA Takumi | 6edae59 | 2011-11-11 05:12:45 +0000 | [diff] [blame] | 41 | // CHECK: {{.*[/\\]}}serialized-diags.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized] |
| 42 | // CHECK: Range: {{.*[/\\]}}serialized-diags.c:3:12 {{.*[/\\]}}serialized-diags.c:3:18 |
| 43 | // CHECK: +-{{.*[/\\]}}serialized-diags.c:2:13: note: initialize the variable 'voodoo' to silence this warning [] |
NAKAMURA Takumi | 40f6975 | 2011-11-11 07:27:33 +0000 | [diff] [blame] | 44 | // CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:2:13 - {{.*[/\\]}}serialized-diags.c:2:13): " = 0" |
NAKAMURA Takumi | 6edae59 | 2011-11-11 05:12:45 +0000 | [diff] [blame] | 45 | // CHECK: {{.*[/\\]}}serialized-diags.c:8:22: error: expected ';' after expression [] |
| 46 | // CHECK: FIXIT: ({{.*[/\\]}}serialized-diags.c:8:22 - {{.*[/\\]}}serialized-diags.c:8:22): ";" |
Ted Kremenek | 952538d | 2011-11-29 00:30:52 +0000 | [diff] [blame] | 47 | // CHECK: {{.*[/\\]}}serialized-diags.c:14:10: warning: equality comparison with extraneous parentheses [-Wparentheses-equality] |
| 48 | // CHECK: Range: {{.*[/\\]}}serialized-diags.c:14:8 {{.*[/\\]}}serialized-diags.c:14:18 |
| 49 | // CHECK: +-{{.*[/\\]}}serialized-diags.c:14:10: note: remove extraneous parentheses around the comparison to silence this warning [] |
| 50 | // CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:7 - {{.*[/\\]}}serialized-diags.c:14:8): "" |
| 51 | // CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:18 - {{.*[/\\]}}serialized-diags.c:14:19): "" |
| 52 | // CHECK: +-{{.*[/\\]}}serialized-diags.c:14:10: note: use '=' to turn this equality comparison into an assignment [] |
| 53 | // CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:14:10 - {{.*[/\\]}}serialized-diags.c:14:12): "=" |
Ted Kremenek | 2a76410 | 2011-12-17 05:26:11 +0000 | [diff] [blame] | 54 | // CHECK: {{.*[/\\]}}serialized-diags.c:22:13: error: too many arguments to function call, expected 2, have 3 [] |
| 55 | // CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:3 {{.*[/\\]}}serialized-diags.c:22:6 |
| 56 | // CHECK: Range: {{.*[/\\]}}serialized-diags.c:22:13 {{.*[/\\]}}serialized-diags.c:22:18 |
| 57 | // CHECK: +-{{.*[/\\]}}serialized-diags.c:20:15: note: expanded from macro 'false' [] |
| 58 | // CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:22:3 {{.*[/\\]}}serialized-diags.c:22:6 |
| 59 | // CHECK: +-Range: {{.*[/\\]}}serialized-diags.c:20:15 {{.*[/\\]}}serialized-diags.c:20:16 |
| 60 | // CHECK: +-{{.*[/\\]}}serialized-diags.c:19:1: note: 'taz' declared here [] |
Richard Smith | ff34d40 | 2012-04-12 05:08:17 +0000 | [diff] [blame] | 61 | // CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion] |
Ted Kremenek | 2a76410 | 2011-12-17 05:26:11 +0000 | [diff] [blame] | 62 | // CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 {{.*[/\\]}}serialized-diags.h:5:17 |
| 63 | // CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from {{.*[/\\]}}serialized-diags.c:26: [] |
Ted Kremenek | 3739b32 | 2012-03-20 20:49:45 +0000 | [diff] [blame] | 64 | // CHECK: Number FIXITs = 0 |
| 65 | // CHECK: {{.*[/\\]}}serialized-diags.c:30:12: warning: unused variable 'x' |
| 66 | // CHECK: Number FIXITs = 0 |
| 67 | // CHECK: Number of diagnostics: 6 |