Home | History | Annotate | Download | only in Misc
      1 void foo() {
      2   int voodoo;
      3   voodoo = voodoo + 1;
      4 }
      5 
      6 void bar() {
      7   int dragon;
      8   dragon = dragon + 1
      9 }
     10 
     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 
     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 
     28 // Test handling of warnings that have empty fixits.
     29 void rdar11040133() {
     30   unsigned x;
     31 }
     32 
     33 // RUN: rm -f %t
     34 // RUN: not %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.diag > /dev/null 2>&1
     35 // RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1
     36 // RUN: FileCheck --input-file=%t %s
     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 
     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 []
     44 // CHECK: +-FIXIT: ({{.*[/\\]}}serialized-diags.c:2:13 - {{.*[/\\]}}serialized-diags.c:2:13): " = 0"
     45 // CHECK: {{.*[/\\]}}serialized-diags.c:8:22: error: expected ';' after expression []
     46 // CHECK: FIXIT: ({{.*[/\\]}}serialized-diags.c:8:22 - {{.*[/\\]}}serialized-diags.c:8:22): ";"
     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): "="
     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 []
     61 // CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int' [-Wint-conversion]
     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: []
     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
     68