File indexing completed on 2026-05-10 08:36:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCONSUMER_H
0010 #define LLVM_CLANG_FRONTEND_CHAINEDDIAGNOSTICCONSUMER_H
0011
0012 #include "clang/Basic/Diagnostic.h"
0013 #include <memory>
0014
0015 namespace clang {
0016 class LangOptions;
0017
0018
0019
0020
0021
0022 class ChainedDiagnosticConsumer : public DiagnosticConsumer {
0023 virtual void anchor();
0024 std::unique_ptr<DiagnosticConsumer> OwningPrimary;
0025 DiagnosticConsumer *Primary;
0026 std::unique_ptr<DiagnosticConsumer> Secondary;
0027
0028 public:
0029 ChainedDiagnosticConsumer(std::unique_ptr<DiagnosticConsumer> Primary,
0030 std::unique_ptr<DiagnosticConsumer> Secondary)
0031 : OwningPrimary(std::move(Primary)), Primary(OwningPrimary.get()),
0032 Secondary(std::move(Secondary)) {}
0033
0034
0035 ChainedDiagnosticConsumer(DiagnosticConsumer *Primary,
0036 std::unique_ptr<DiagnosticConsumer> Secondary)
0037 : Primary(Primary), Secondary(std::move(Secondary)) {}
0038
0039 void BeginSourceFile(const LangOptions &LO,
0040 const Preprocessor *PP) override {
0041 Primary->BeginSourceFile(LO, PP);
0042 Secondary->BeginSourceFile(LO, PP);
0043 }
0044
0045 void EndSourceFile() override {
0046 Secondary->EndSourceFile();
0047 Primary->EndSourceFile();
0048 }
0049
0050 void finish() override {
0051 Secondary->finish();
0052 Primary->finish();
0053 }
0054
0055 bool IncludeInDiagnosticCounts() const override {
0056 return Primary->IncludeInDiagnosticCounts();
0057 }
0058
0059 void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
0060 const Diagnostic &Info) override {
0061
0062 DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
0063
0064 Primary->HandleDiagnostic(DiagLevel, Info);
0065 Secondary->HandleDiagnostic(DiagLevel, Info);
0066 }
0067 };
0068
0069 }
0070
0071 #endif