From: Ted Kremenek Date: Wed, 7 Dec 2011 02:08:00 +0000 (+0000) Subject: Tweak serialized diagnostics to support errors with no categories. Fixes . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146011 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Misc/serialized-diags-no-category.c b/test/Misc/serialized-diags-no-category.c new file mode 100644 index 0000000000..9c92ac3330 --- /dev/null +++ b/test/Misc/serialized-diags-no-category.c @@ -0,0 +1,12 @@ +#error foo +#error bar + +// RUN: rm -f %t +// RUN: %clang -ferror-limit=1 -fsyntax-only %s --serialize-diagnostics %t > /dev/null 2>&1 || true +// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s + +// This test case tests that we can handle both fatal errors and errors without categories. + +// CHECK: {{.*[/\\]}}serialized-diags-no-category.c:1:2: error: #error foo [] +// CHECK: Number of diagnostics: 2 + diff --git a/test/Misc/serialized-diags.c b/test/Misc/serialized-diags.c index 7cdac53b84..b5b619d655 100644 --- a/test/Misc/serialized-diags.c +++ b/test/Misc/serialized-diags.c @@ -16,7 +16,7 @@ void qux(int x) { } // RUN: rm -f %t -// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t 2>&1 /dev/null || true +// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t > /dev/null 2>&1 || true // RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s // This test case tests that we can handle multiple diagnostics which contain diff --git a/tools/libclang/CXLoadedDiagnostic.cpp b/tools/libclang/CXLoadedDiagnostic.cpp index 61b9e33c2d..b95515e6e2 100644 --- a/tools/libclang/CXLoadedDiagnostic.cpp +++ b/tools/libclang/CXLoadedDiagnostic.cpp @@ -595,7 +595,8 @@ LoadResult DiagLoader::readDiagnosticBlock(llvm::BitstreamCursor &Stream, continue; case serialized_diags::RECORD_CATEGORY: if (readString(TopDiags, TopDiags.Categories, "category", Record, - BlobStart, BlobLen)) + BlobStart, BlobLen, + /* allowEmptyString */ true)) return Failure; continue;