clang 8.0.0

TextDiagnosticBuffer.h
Go to the documentation of this file.
1 //===- TextDiagnosticBuffer.h - Buffer Text Diagnostics ---------*- 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 // This is a concrete diagnostic client, which buffers the diagnostic messages.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICBUFFER_H
15 #define LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICBUFFER_H
16
17 #include "clang/Basic/Diagnostic.h"
18 #include "clang/Basic/SourceLocation.h"
19 #include <cstddef>
20 #include <string>
21 #include <utility>
22 #include <vector>
23
24 namespace clang {
25
26 class TextDiagnosticBuffer : public DiagnosticConsumer {
27 public:
28 using DiagList = std::vector<std::pair<SourceLocation, std::string>>;
29 using iterator = DiagList::iterator;
30 using const_iterator = DiagList::const_iterator;
31
32 private:
33 DiagList Errors, Warnings, Remarks, Notes;
34
35 /// All - All diagnostics in the order in which they were generated. That
36 /// order likely doesn't correspond to user input order, but it at least
37 /// keeps notes in the right places. Each pair in the vector is a diagnostic
38 /// level and an index into the corresponding DiagList above.
39 std::vector<std::pair<DiagnosticsEngine::Level, size_t>> All;
40
41 public:
42 const_iterator err_begin() const { return Errors.begin(); }
43 const_iterator err_end() const { return Errors.end(); }
44
45 const_iterator warn_begin() const { return Warnings.begin(); }
46 const_iterator warn_end() const { return Warnings.end(); }
47
48 const_iterator remark_begin() const { return Remarks.begin(); }
49 const_iterator remark_end() const { return Remarks.end(); }
50
51 const_iterator note_begin() const { return Notes.begin(); }
52 const_iterator note_end() const { return Notes.end(); }
53
54 void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
55 const Diagnostic &Info) override;
56
57 /// FlushDiagnostics - Flush the buffered diagnostics to an given
58 /// diagnostic engine.
59 void FlushDiagnostics(DiagnosticsEngine &Diags) const;
60 };
61
62 } // namespace clang
63
64 #endif // LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICBUFFER_H
clang::TextDiagnosticBuffer::remark_end
const_iterator remark_end() const
Definition: TextDiagnosticBuffer.h:49
clang::TextDiagnosticBuffer::HandleDiagnostic
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) override
HandleDiagnostic - Store the errors, warnings, and notes that are reported.
Definition: TextDiagnosticBuffer.cpp:24
clang::DiagnosticConsumer
Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...
Definition: Diagnostic.h:1488
clang::TextDiagnosticBuffer::err_end
const_iterator err_end() const
Definition: TextDiagnosticBuffer.h:43
clang::TextDiagnosticBuffer::note_begin
const_iterator note_begin() const
Definition: TextDiagnosticBuffer.h:51
clang::TextDiagnosticBuffer::note_end
const_iterator note_end() const
Definition: TextDiagnosticBuffer.h:52
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:149
Diagnostic.h
Defines the Diagnostic-related interfaces.
clang::TextDiagnosticBuffer::iterator
DiagList::iterator iterator
Definition: TextDiagnosticBuffer.h:29
clang::TextDiagnosticBuffer::err_begin
const_iterator err_begin() const
Definition: TextDiagnosticBuffer.h:42
clang::TextDiagnosticBuffer::const_iterator
DiagList::const_iterator const_iterator
Definition: TextDiagnosticBuffer.h:30
clang::TextDiagnosticBuffer::DiagList
std::vector< std::pair< SourceLocation, std::string > > DiagList
Definition: TextDiagnosticBuffer.h:28
clang::TextDiagnosticBuffer
Definition: TextDiagnosticBuffer.h:26
clang::TextDiagnosticBuffer::warn_end
const_iterator warn_end() const
Definition: TextDiagnosticBuffer.h:46
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::TextDiagnosticBuffer::warn_begin
const_iterator warn_begin() const
Definition: TextDiagnosticBuffer.h:45
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::TextDiagnosticBuffer::remark_begin
const_iterator remark_begin() const
Definition: TextDiagnosticBuffer.h:48
clang::Diagnostic
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
Definition: Diagnostic.h:1316
clang::TextDiagnosticBuffer::FlushDiagnostics
void FlushDiagnostics(DiagnosticsEngine &Diags) const
FlushDiagnostics - Flush the buffered diagnostics to an given diagnostic engine.
Definition: TextDiagnosticBuffer.cpp:54