File indexing completed on 2026-05-10 08:36:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_FRONTEND_LOGDIAGNOSTICPRINTER_H
0010 #define LLVM_CLANG_FRONTEND_LOGDIAGNOSTICPRINTER_H
0011
0012 #include "clang/Basic/Diagnostic.h"
0013 #include "clang/Basic/SourceLocation.h"
0014 #include "llvm/ADT/SmallVector.h"
0015 #include "llvm/ADT/StringRef.h"
0016
0017 namespace clang {
0018 class DiagnosticOptions;
0019 class LangOptions;
0020
0021 class LogDiagnosticPrinter : public DiagnosticConsumer {
0022 struct DiagEntry {
0023
0024 std::string Message;
0025
0026
0027 std::string Filename;
0028
0029
0030 unsigned Line;
0031
0032
0033 unsigned Column;
0034
0035
0036 unsigned DiagnosticID;
0037
0038
0039 std::string WarningOption;
0040
0041
0042 DiagnosticsEngine::Level DiagnosticLevel;
0043 };
0044
0045 void EmitDiagEntry(llvm::raw_ostream &OS,
0046 const LogDiagnosticPrinter::DiagEntry &DE);
0047
0048
0049
0050
0051 raw_ostream &OS;
0052 std::unique_ptr<raw_ostream> StreamOwner;
0053 const LangOptions *LangOpts;
0054 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
0055
0056 SourceLocation LastWarningLoc;
0057 FullSourceLoc LastLoc;
0058
0059 SmallVector<DiagEntry, 8> Entries;
0060
0061 std::string MainFilename;
0062 std::string DwarfDebugFlags;
0063
0064 public:
0065 LogDiagnosticPrinter(raw_ostream &OS, DiagnosticOptions *Diags,
0066 std::unique_ptr<raw_ostream> StreamOwner);
0067
0068 void setDwarfDebugFlags(StringRef Value) {
0069 DwarfDebugFlags = std::string(Value);
0070 }
0071
0072 void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override {
0073 LangOpts = &LO;
0074 }
0075
0076 void EndSourceFile() override;
0077
0078 void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
0079 const Diagnostic &Info) override;
0080 };
0081
0082 }
0083
0084 #endif