1 //===--- ChainedDiagnosticClient.h - Chain Diagnostic Clients ---*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCLIENT_H
11 #define LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCLIENT_H
13 #include "clang/Basic/Diagnostic.h"
14 #include "llvm/ADT/OwningPtr.h"
19 /// ChainedDiagnosticClient - Chain two diagnostic clients so that diagnostics
20 /// go to the first client and then the second. The first diagnostic client
21 /// should be the "primary" client, and will be used for computing whether the
22 /// diagnostics should be included in counts.
23 class ChainedDiagnosticClient : public DiagnosticClient {
24 llvm::OwningPtr<DiagnosticClient> Primary;
25 llvm::OwningPtr<DiagnosticClient> Secondary;
28 ChainedDiagnosticClient(DiagnosticClient *_Primary,
29 DiagnosticClient *_Secondary) {
30 Primary.reset(_Primary);
31 Secondary.reset(_Secondary);
34 virtual void BeginSourceFile(const LangOptions &LO,
35 const Preprocessor *PP) {
36 Primary->BeginSourceFile(LO, PP);
37 Secondary->BeginSourceFile(LO, PP);
40 virtual void EndSourceFile() {
41 Secondary->EndSourceFile();
42 Primary->EndSourceFile();
45 virtual bool IncludeInDiagnosticCounts() const {
46 return Primary->IncludeInDiagnosticCounts();
49 virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
50 const DiagnosticInfo &Info) {
51 // Default implementation (Warnings/errors count).
52 DiagnosticClient::HandleDiagnostic(DiagLevel, Info);
54 Primary->HandleDiagnostic(DiagLevel, Info);
55 Secondary->HandleDiagnostic(DiagLevel, Info);
59 } // end namspace clang