diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-02-22 23:17:23 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-02-22 23:17:23 +0000 |
commit | d770f73facd5cca11567b651c0dda86dc2bc96ea (patch) | |
tree | c581951ead3b9aedba3de080daab3ccb67e31e90 /clang/tools/CIndex/CIndex.cpp | |
parent | 45fceea0e45b5440675b3c18d6d1d26eacf606e1 (diff) | |
download | bcm5719-llvm-d770f73facd5cca11567b651c0dda86dc2bc96ea.tar.gz bcm5719-llvm-d770f73facd5cca11567b651c0dda86dc2bc96ea.zip |
Rework the CIndex API for displaying diagnostics. Instead of printing
the diagnostics to a FILE*, return a CXString containing the formatted
diagnostic.
llvm-svn: 96823
Diffstat (limited to 'clang/tools/CIndex/CIndex.cpp')
-rw-r--r-- | clang/tools/CIndex/CIndex.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp index f74daf8e889..d95aaee770c 100644 --- a/clang/tools/CIndex/CIndex.cpp +++ b/clang/tools/CIndex/CIndex.cpp @@ -1007,9 +1007,17 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx, DEnd = Unit->diag_end(); D != DEnd; ++D) { CXStoredDiagnostic Diag(*D, Unit->getASTContext().getLangOptions()); - clang_displayDiagnostic(&Diag, stderr, - clang_defaultDiagnosticDisplayOptions()); + CXString Msg = clang_formatDiagnostic(&Diag, + clang_defaultDiagnosticDisplayOptions()); + fprintf(stderr, "%s\n", clang_getCString(Msg)); + clang_disposeString(Msg); } +#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(stderr); +#endif } return 0; } @@ -1124,9 +1132,18 @@ clang_createTranslationUnitFromSourceFile(CXIndex CIdx, DEnd = Diags.end(); D != DEnd; ++D) { CXStoredDiagnostic Diag(*D, LangOpts); - clang_displayDiagnostic(&Diag, stderr, - clang_defaultDiagnosticDisplayOptions()); + CXString Msg = clang_formatDiagnostic(&Diag, + clang_defaultDiagnosticDisplayOptions()); + fprintf(stderr, "%s\n", clang_getCString(Msg)); + clang_disposeString(Msg); } + +#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(stderr); +#endif } if (ATU) { |