Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:55

0001 //===--- TextDiagnosticPrinter.h - Text Diagnostic Client -------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This is a concrete diagnostic client, which prints the diagnostics to
0010 // standard error.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICPRINTER_H
0015 #define LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICPRINTER_H
0016 
0017 #include "clang/Basic/Diagnostic.h"
0018 #include "clang/Basic/LLVM.h"
0019 #include "llvm/ADT/IntrusiveRefCntPtr.h"
0020 #include <memory>
0021 
0022 namespace clang {
0023 class DiagnosticOptions;
0024 class LangOptions;
0025 class TextDiagnostic;
0026 
0027 class TextDiagnosticPrinter : public DiagnosticConsumer {
0028   raw_ostream &OS;
0029   IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
0030 
0031   /// Handle to the currently active text diagnostic emitter.
0032   std::unique_ptr<TextDiagnostic> TextDiag;
0033 
0034   /// A string to prefix to error messages.
0035   std::string Prefix;
0036 
0037   LLVM_PREFERRED_TYPE(bool)
0038   unsigned OwnsOutputStream : 1;
0039 
0040 public:
0041   TextDiagnosticPrinter(raw_ostream &os, DiagnosticOptions *diags,
0042                         bool OwnsOutputStream = false);
0043   ~TextDiagnosticPrinter() override;
0044 
0045   /// setPrefix - Set the diagnostic printer prefix string, which will be
0046   /// printed at the start of any diagnostics. If empty, no prefix string is
0047   /// used.
0048   void setPrefix(std::string Value) { Prefix = std::move(Value); }
0049 
0050   void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override;
0051   void EndSourceFile() override;
0052   void HandleDiagnostic(DiagnosticsEngine::Level Level,
0053                         const Diagnostic &Info) override;
0054 };
0055 
0056 } // end namespace clang
0057 
0058 #endif