From e61e24a5e30997ff6baf5c7e35375bab385844f1 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sun, 21 Feb 2010 20:15:42 +0000 Subject: [PATCH] Attempt to fix the MSVC9 failure with c-indext-test, where the CIndex DLL and the c-index-test executable end up getting different copies of stderr, causing non-deterministic ordering of output. Fixed by flushing the file after printing a diagnostic (only on Windows). llvm-svn: 96754 --- clang/test/Index/cindex-on-invalid.m | 1 - clang/tools/CIndex/CIndexDiagnostic.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/test/Index/cindex-on-invalid.m b/clang/test/Index/cindex-on-invalid.m index 626f566202ad..7e190eb07940 100644 --- a/clang/test/Index/cindex-on-invalid.m +++ b/clang/test/Index/cindex-on-invalid.m @@ -1,6 +1,5 @@ // RUN: not c-index-test -test-load-source local %s > %t 2> %t.err // RUN: FileCheck %s < %t.err -// XFAIL: win32 // CHECK: error: expected identifier or '(' // CHECK: Unable to load translation unit! diff --git a/clang/tools/CIndex/CIndexDiagnostic.cpp b/clang/tools/CIndex/CIndexDiagnostic.cpp index 97d501707748..75da335afc29 100644 --- a/clang/tools/CIndex/CIndexDiagnostic.cpp +++ b/clang/tools/CIndex/CIndexDiagnostic.cpp @@ -116,6 +116,13 @@ void clang_displayDiagnostic(CXDiagnostic Diagnostic, FILE *Out, else fprintf(Out, "\n"); clang_disposeString(Text); + +#ifdef LLVM_ON_WIN32 + // On Windows, force a flush, since there may be multiple copies of + // stderr and stdout in the file system, all with different buffers + // but writing to the same device. + fflush(Out); +#endif } unsigned clang_defaultDiagnosticDisplayOptions() {