clang 8.0.0

LogDiagnosticPrinter.h
Go to the documentation of this file.
1 //===--- LogDiagnosticPrinter.h - Log Diagnostic Client ---------*- 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_LOGDIAGNOSTICPRINTER_H
11 #define LLVM_CLANG_FRONTEND_LOGDIAGNOSTICPRINTER_H
12
13 #include "clang/Basic/Diagnostic.h"
14 #include "clang/Basic/SourceLocation.h"
15 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/ADT/StringRef.h"
17
18 namespace clang {
19 class DiagnosticOptions;
20 class LangOptions;
21
22 class LogDiagnosticPrinter : public DiagnosticConsumer {
23 struct DiagEntry {
24 /// The primary message line of the diagnostic.
25 std::string Message;
26
27 /// The source file name, if available.
28 std::string Filename;
29
30 /// The source file line number, if available.
31 unsigned Line;
32
33 /// The source file column number, if available.
34 unsigned Column;
35
36 /// The ID of the diagnostic.
37 unsigned DiagnosticID;
38
39 /// The Option Flag for the diagnostic
40 std::string WarningOption;
41
42 /// The level of the diagnostic.
43 DiagnosticsEngine::Level DiagnosticLevel;
44 };
45
46 void EmitDiagEntry(llvm::raw_ostream &OS,
47 const LogDiagnosticPrinter::DiagEntry &DE);
48
49 // Conditional ownership (when StreamOwner is non-null, it's keeping OS
50 // alive). We might want to replace this with a wrapper for conditional
51 // ownership eventually - it seems to pop up often enough.
52 raw_ostream &OS;
53 std::unique_ptr<raw_ostream> StreamOwner;
54 const LangOptions *LangOpts;
55 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts;
56
57 SourceLocation LastWarningLoc;
58 FullSourceLoc LastLoc;
59
60 SmallVector<DiagEntry, 8> Entries;
61
62 std::string MainFilename;
63 std::string DwarfDebugFlags;
64
65 public:
66 LogDiagnosticPrinter(raw_ostream &OS, DiagnosticOptions *Diags,
67 std::unique_ptr<raw_ostream> StreamOwner);
68
69 void setDwarfDebugFlags(StringRef Value) {
70 DwarfDebugFlags = Value;
71 }
72
73 void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override {
74 LangOpts = &LO;
75 }
76
77 void EndSourceFile() override;
78
79 void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
80 const Diagnostic &Info) override;
81 };
82
83 } // end namespace clang
84
85 #endif
clang::LogDiagnosticPrinter::EndSourceFile
void EndSourceFile() override
Callback to inform the diagnostic client that processing of a source file has ended.
Definition: LogDiagnosticPrinter.cpp:77
clang::LogDiagnosticPrinter::BeginSourceFile
void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override
Callback to inform the diagnostic client that processing of a source file is beginning.
Definition: LogDiagnosticPrinter.h:73
Value
Value
Definition: UninitializedValues.cpp:102
clang::DiagnosticConsumer
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
Definition: Diagnostic.h:1488
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:50
clang::LogDiagnosticPrinter::setDwarfDebugFlags
void setDwarfDebugFlags(StringRef Value)
Definition: LogDiagnosticPrinter.h:69
Diagnostic.h
Defines the Diagnostic-related interfaces.
Filename
StringRef Filename
Definition: Format.cpp:1629
Line
const AnnotatedLine * Line
Definition: UsingDeclarationsSorter.cpp:69
clang::LogDiagnosticPrinter::HandleDiagnostic
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) override
Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
Definition: LogDiagnosticPrinter.cpp:112
llvm::IntrusiveRefCntPtr
Definition: LLVM.h:45
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:88
clang::DiagnosticOptions
Options for controlling the compiler diagnostics engine.
Definition: DiagnosticOptions.h:64
llvm::SmallVector
Definition: LLVM.h:36
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::LogDiagnosticPrinter::LogDiagnosticPrinter
LogDiagnosticPrinter(raw_ostream &OS, DiagnosticOptions *Diags, std::unique_ptr< raw_ostream > StreamOwner)
Definition: LogDiagnosticPrinter.cpp:21
SourceLocation.h
Defines the clang::SourceLocation class and associated facilities.
clang::DiagnosticsEngine::Level
Level
The level of the diagnostic, after it has been through mapping.
Definition: Diagnostic.h:152
clang::Diagnostic
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
Definition: Diagnostic.h:1316
clang::FullSourceLoc
A SourceLocation and its associated SourceManager.
Definition: SourceLocation.h:340
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:125
clang::LogDiagnosticPrinter
Definition: LogDiagnosticPrinter.h:22