Rework the CIndex API for displaying diagnostics. Instead of printing
the diagnostics to a FILE*, return a CXString containing the formatted
diagnostic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96823 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/c-index-test/c-index-test.c b/tools/c-index-test/c-index-test.c
index 2207364..34bb990 100644
--- a/tools/c-index-test/c-index-test.c
+++ b/tools/c-index-test/c-index-test.c
@@ -198,14 +198,18 @@
void PrintDiagnostic(CXDiagnostic Diagnostic) {
FILE *out = stderr;
CXFile file;
+ CXString Msg;
unsigned display_opts = CXDiagnostic_DisplaySourceLocation
| CXDiagnostic_DisplayColumn | CXDiagnostic_DisplaySourceRanges;
unsigned i, num_fixits;
-
- clang_displayDiagnostic(Diagnostic, out, display_opts);
+
if (clang_getDiagnosticSeverity(Diagnostic) == CXDiagnostic_Ignored)
return;
+ Msg = clang_formatDiagnostic(Diagnostic, display_opts);
+ fprintf(stderr, "%s\n", clang_getCString(Msg));
+ clang_disposeString(Msg);
+
clang_getInstantiationLocation(clang_getDiagnosticLocation(Diagnostic),
&file, 0, 0, 0);
if (!file)