[cfe-commits] r144349 - in /cfe/trunk: test/Misc/serialized-diags-no-issue.c test/Misc/serialized-diags-single-issue.c test/Misc/serialized-diags.c tools/c-index-test/c-index-test.c

Ted Kremenek kremenek at apple.com
Thu Nov 10 16:46:43 PST 2011


Author: kremenek
Date: Thu Nov 10 18:46:43 2011
New Revision: 144349

URL: http://llvm.org/viewvc/llvm-project?rev=144349&view=rev
Log:
[serialized diagnostics]: add test cases for serialized diagnostics, including a test case for no issues, multiple issues, and
a single issue.  Along the way, tweak c-index-test -read-diagnostics output so it is easier to tell what diagnostics are
child diagnostics.

Added:
    cfe/trunk/test/Misc/serialized-diags-no-issue.c
    cfe/trunk/test/Misc/serialized-diags-single-issue.c
    cfe/trunk/test/Misc/serialized-diags.c
Modified:
    cfe/trunk/tools/c-index-test/c-index-test.c

Added: cfe/trunk/test/Misc/serialized-diags-no-issue.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/serialized-diags-no-issue.c?rev=144349&view=auto
==============================================================================
--- cfe/trunk/test/Misc/serialized-diags-no-issue.c (added)
+++ cfe/trunk/test/Misc/serialized-diags-no-issue.c Thu Nov 10 18:46:43 2011
@@ -0,0 +1,10 @@
+void foo();
+
+// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t
+// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s
+// RUN: rm -f  %t
+
+// NOTE: it is important that this test case contains no issues.  It tests
+// that serialize diagnostics work in the absence of any issues.
+
+// CHECK: Number of diagnostics: 0

Added: cfe/trunk/test/Misc/serialized-diags-single-issue.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/serialized-diags-single-issue.c?rev=144349&view=auto
==============================================================================
--- cfe/trunk/test/Misc/serialized-diags-single-issue.c (added)
+++ cfe/trunk/test/Misc/serialized-diags-single-issue.c Thu Nov 10 18:46:43 2011
@@ -0,0 +1,16 @@
+void foo() {
+  int voodoo;
+  voodoo = voodoo + 1;
+}
+
+// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t
+// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s
+// RUN: rm -f %t
+
+// NOTE: it is important that this test case only contain a single issue.  This test case checks
+// if we can handle serialized diagnostics that contain only one diagnostic.
+
+// CHECK: {{.*}}serialized-diags-single-issue.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
+// CHECK: Range: {{.*}}serialized-diags-single-issue.c:3:12 {{.*}}serialized-diags-single-issue.c:3:18
+// CHECK: +-{{.*}}serialized-diags-single-issue.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
+// CHECK: +-FIXIT: {{.*}}serialized-diags-single-issue.c:2:13 - {{.*}}serialized-diags-single-issue.c:2:13): " = 0"
\ No newline at end of file

Added: cfe/trunk/test/Misc/serialized-diags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/serialized-diags.c?rev=144349&view=auto
==============================================================================
--- cfe/trunk/test/Misc/serialized-diags.c (added)
+++ cfe/trunk/test/Misc/serialized-diags.c Thu Nov 10 18:46:43 2011
@@ -0,0 +1,23 @@
+void foo() {
+  int voodoo;
+  voodoo = voodoo + 1;
+}
+
+void bar() {
+  int dragon;
+  dragon = dragon + 1
+}
+
+// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t 2>&1 /dev/null || true
+// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s
+// RUN: rm -f %t
+
+// This test case tests that we can handle multiple diagnostics which contain
+// FIXITs at different levels (one at the note, another at the main diagnostic).
+
+// CHECK: {{.*}}/serialized-diags.c:3:12: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
+// CHECK: Range: {{.*}}/serialized-diags.c:3:12 {{.*}}/serialized-diags.c:3:18
+// CHECK: +-{{.*}}/serialized-diags.c:2:13: note: initialize the variable 'voodoo' to silence this warning []
+// CHECK: +-FIXIT: ({{.*}}/serialized-diags.c:2:13 - {{.*}}/serialized-diags.c:2:13): " = 0Parse Issueexpected ';' after expression"
+// CHECK: {{.*}}/serialized-diags.c:8:22: error: expected ';' after expression []
+// CHECK: FIXIT: ({{.*}}/serialized-diags.c:8:22 - {{.*}}/serialized-diags.c:8:22): ";"
\ No newline at end of file

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=144349&r1=144348&r2=144349&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Thu Nov 10 18:46:43 2011
@@ -2307,8 +2307,12 @@
 }
 
 static void printIndent(unsigned indent) {
+  if (indent == 0)
+    return;
+  fprintf(stderr, "+");
+  --indent;
   while (indent > 0) {
-    fprintf(stderr, " ");
+    fprintf(stderr, "-");
     --indent;
   }
 }
@@ -2366,8 +2370,6 @@
   if (!Diags)
     return;
   
-  fprintf(stderr, "\n");
-
   n = clang_getNumDiagnosticsInSet(Diags);
   for (i = 0; i < n; ++i) {
     CXSourceLocation DiagLoc;
@@ -2427,6 +2429,8 @@
   }
   
   printDiagnosticSet(Diags, 0);
+  fprintf(stderr, "Number of diagnostics: %d\n",
+          clang_getNumDiagnosticsInSet(Diags));
   clang_disposeDiagnosticSet(Diags);
   return 0;
 }





More information about the cfe-commits mailing list