diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-11-11 08:13:24 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-11 08:13:24 +0000 |
commit | dbf75feeb6e1b0015b72fa42c80b45497e9ffefc (patch) | |
tree | c0c8246aa1a129cbe7a9d664697b44fc9875225c /tools | |
parent | 56749087b5818f323e9e71a514274cdc5e7bfd46 (diff) |
Turn LoggingDiagnosticClient into a more general ChainedDiagnosticClient and
move to libFrontend.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/clang-cc/clang-cc.cpp | 46 |
1 files changed, 4 insertions, 42 deletions
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index df15e5b173..ddd8d3100c 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -19,6 +19,7 @@ #include "clang/Frontend/AnalysisConsumer.h" #include "clang/Frontend/ASTConsumers.h" #include "clang/Frontend/ASTUnit.h" +#include "clang/Frontend/ChainedDiagnosticClient.h" #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/DiagnosticOptions.h" #include "clang/Frontend/FixItRewriter.h" @@ -811,48 +812,9 @@ DumpBuildInformation("dump-build-information", static llvm::raw_ostream *BuildLogFile = 0; -/// LoggingDiagnosticClient - This is a simple diagnostic client that forwards -/// all diagnostics to both BuildLogFile and a chained DiagnosticClient. -namespace { -class LoggingDiagnosticClient : public DiagnosticClient { - llvm::OwningPtr<DiagnosticClient> Chain1; - llvm::OwningPtr<DiagnosticClient> Chain2; -public: - - LoggingDiagnosticClient(const DiagnosticOptions &DiagOpts, - DiagnosticClient *Normal) { - // Output diags both where requested... - Chain1.reset(Normal); - // .. and to our log file. - Chain2.reset(new TextDiagnosticPrinter(*BuildLogFile, DiagOpts)); - } - - virtual void BeginSourceFile(const LangOptions &LO) { - Chain1->BeginSourceFile(LO); - Chain2->BeginSourceFile(LO); - } - - virtual void EndSourceFile() { - Chain1->EndSourceFile(); - Chain2->EndSourceFile(); - } - - virtual bool IncludeInDiagnosticCounts() const { - return Chain1->IncludeInDiagnosticCounts(); - } - - virtual void HandleDiagnostic(Diagnostic::Level DiagLevel, - const DiagnosticInfo &Info) { - Chain1->HandleDiagnostic(DiagLevel, Info); - Chain2->HandleDiagnostic(DiagLevel, Info); - } -}; -} // end anonymous namespace. - static void SetUpBuildDumpLog(const DiagnosticOptions &DiagOpts, unsigned argc, char **argv, llvm::OwningPtr<DiagnosticClient> &DiagClient) { - std::string ErrorInfo; BuildLogFile = new llvm::raw_fd_ostream(DumpBuildInformation.c_str(), ErrorInfo); @@ -871,9 +833,9 @@ static void SetUpBuildDumpLog(const DiagnosticOptions &DiagOpts, (*BuildLogFile) << argv[i] << ' '; (*BuildLogFile) << '\n'; - // LoggingDiagnosticClient - Insert a new logging diagnostic client in between - // the diagnostic producers and the normal receiver. - DiagClient.reset(new LoggingDiagnosticClient(DiagOpts, DiagClient.take())); + // Chain in a diagnostic client which will log the diagnostics. + DiagnosticClient *Logger = new TextDiagnosticPrinter(*BuildLogFile, DiagOpts); + DiagClient.reset(new ChainedDiagnosticClient(DiagClient.take(), Logger)); } |