Coverage Report

Created: 2018-12-11 17:59

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Frontend/ChainedDiagnosticConsumer.h
Line
Count
Source (jump to first uncovered line)
1
//===- ChainedDiagnosticConsumer.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_CHAINEDDIAGNOSTICCONSUMER_H
11
#define LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCONSUMER_H
12
13
#include "clang/Basic/Diagnostic.h"
14
#include <memory>
15
16
namespace clang {
17
class LangOptions;
18
19
/// ChainedDiagnosticConsumer - 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 ChainedDiagnosticConsumer : public DiagnosticConsumer {
24
  virtual void anchor();
25
  std::unique_ptr<DiagnosticConsumer> OwningPrimary;
26
  DiagnosticConsumer *Primary;
27
  std::unique_ptr<DiagnosticConsumer> Secondary;
28
29
public:
30
  ChainedDiagnosticConsumer(std::unique_ptr<DiagnosticConsumer> Primary,
31
                            std::unique_ptr<DiagnosticConsumer> Secondary)
32
      : OwningPrimary(std::move(Primary)), Primary(OwningPrimary.get()),
33
33
        Secondary(std::move(Secondary)) {}
34
35
  /// Construct without taking ownership of \c Primary.
36
  ChainedDiagnosticConsumer(DiagnosticConsumer *Primary,
37
                            std::unique_ptr<DiagnosticConsumer> Secondary)
38
0
      : Primary(Primary), Secondary(std::move(Secondary)) {}
39
40
  void BeginSourceFile(const LangOptions &LO,
41
24
                       const Preprocessor *PP) override {
42
24
    Primary->BeginSourceFile(LO, PP);
43
24
    Secondary->BeginSourceFile(LO, PP);
44
24
  }
45
46
24
  void EndSourceFile() override {
47
24
    Secondary->EndSourceFile();
48
24
    Primary->EndSourceFile();
49
24
  }
50
51
33
  void finish() override {
52
33
    Secondary->finish();
53
33
    Primary->finish();
54
33
  }
55
56
204
  bool IncludeInDiagnosticCounts() const override {
57
204
    return Primary->IncludeInDiagnosticCounts();
58
204
  }
59
60
  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
61
85
                        const Diagnostic &Info) override {
62
85
    // Default implementation (Warnings/errors count).
63
85
    DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
64
85
65
85
    Primary->HandleDiagnostic(DiagLevel, Info);
66
85
    Secondary->HandleDiagnostic(DiagLevel, Info);
67
85
  }
68
};
69
70
} // end namspace clang
71
72
#endif