1 // Copyright (C) 2018 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef DIAGNOSTIC_CONSUMER_H_
16 #define DIAGNOSTIC_CONSUMER_H_
17 
18 #include <clang/Basic/Diagnostic.h>
19 
20 
21 namespace header_checker {
22 namespace dumper {
23 
24 
25 class HeaderCheckerDiagnosticConsumer : public clang::DiagnosticConsumer {
26  private:
27   std::unique_ptr<clang::DiagnosticConsumer> wrapped_;
28 
29  public:
30   HeaderCheckerDiagnosticConsumer(
31       std::unique_ptr<clang::DiagnosticConsumer> wrapped);
32   void clear() override;
33   void BeginSourceFile(const clang::LangOptions &lang_opts,
34                        const clang::Preprocessor *preprocessor) override;
35   void EndSourceFile() override;
36   void finish() override;
37   bool IncludeInDiagnosticCounts() const override;
38   void HandleDiagnostic(clang::DiagnosticsEngine::Level level,
39                         const clang::Diagnostic &info) override;
40 };
41 
42 
43 }  // namespace dumper
44 }  // namespace header_checker
45 
46 
47 #endif  // DIAGNOSTIC_CONSUMER_H_
48