]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/blob - contrib/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticClient.h
Copy head to stable/9 as part of 9.0-RELEASE release cycle.
[FreeBSD/stable/9.git] / contrib / llvm / tools / clang / include / clang / Frontend / ChainedDiagnosticClient.h
1 //===--- ChainedDiagnosticClient.h - Chain Diagnostic Clients ---*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCLIENT_H
11 #define LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCLIENT_H
12
13 #include "clang/Basic/Diagnostic.h"
14 #include "llvm/ADT/OwningPtr.h"
15
16 namespace clang {
17 class LangOptions;
18
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;
26
27 public:
28   ChainedDiagnosticClient(DiagnosticClient *_Primary,
29                           DiagnosticClient *_Secondary) {
30     Primary.reset(_Primary);
31     Secondary.reset(_Secondary);
32   }
33
34   virtual void BeginSourceFile(const LangOptions &LO,
35                                const Preprocessor *PP) {
36     Primary->BeginSourceFile(LO, PP);
37     Secondary->BeginSourceFile(LO, PP);
38   }
39
40   virtual void EndSourceFile() {
41     Secondary->EndSourceFile();
42     Primary->EndSourceFile();
43   }
44
45   virtual bool IncludeInDiagnosticCounts() const {
46     return Primary->IncludeInDiagnosticCounts();
47   }
48
49   virtual void HandleDiagnostic(Diagnostic::Level DiagLevel,
50                                 const DiagnosticInfo &Info) {
51     // Default implementation (Warnings/errors count).
52     DiagnosticClient::HandleDiagnostic(DiagLevel, Info);
53
54     Primary->HandleDiagnostic(DiagLevel, Info);
55     Secondary->HandleDiagnostic(DiagLevel, Info);
56   }
57 };
58
59 } // end namspace clang
60
61 #endif