FLANG
TextDiagnosticBuffer.h
1//===- TextDiagnosticBuffer.h - Buffer Text Diagnostics ---------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This is a concrete diagnostic client. The diagnostics are buffered rather
10// than printed. In order to print them, use the FlushDiagnostics method.
11// Pretty-printing is not supported.
12//
13//===----------------------------------------------------------------------===//
14//
15// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
16//
17//===----------------------------------------------------------------------===//
18
19#ifndef FORTRAN_FRONTEND_TEXTDIAGNOSTICBUFFER_H
20#define FORTRAN_FRONTEND_TEXTDIAGNOSTICBUFFER_H
21
22#include "clang/Basic/Diagnostic.h"
23#include "clang/Basic/SourceLocation.h"
24#include <cstddef>
25#include <string>
26#include <utility>
27#include <vector>
28
29namespace Fortran::frontend {
30
31class TextDiagnosticBuffer : public clang::DiagnosticConsumer {
32public:
33 using DiagList = std::vector<std::pair<clang::SourceLocation, std::string>>;
34 using DiagnosticsLevelAndIndexPairs =
35 std::vector<std::pair<clang::DiagnosticsEngine::Level, size_t>>;
36
37private:
38 DiagList errors, warnings, remarks, notes;
39
44 DiagnosticsLevelAndIndexPairs all;
45
46public:
47 void HandleDiagnostic(clang::DiagnosticsEngine::Level diagLevel,
48 const clang::Diagnostic &info) override;
49
51 void flushDiagnostics(clang::DiagnosticsEngine &diags) const;
52};
53
54} // namespace Fortran::frontend
55
56#endif // FORTRAN_FRONTEND_TEXTDIAGNOSTICBUFFER_H
Definition: TextDiagnosticBuffer.h:31
void flushDiagnostics(clang::DiagnosticsEngine &diags) const
Flush the buffered diagnostics to a given diagnostic engine.
Definition: TextDiagnosticBuffer.cpp:56
void HandleDiagnostic(clang::DiagnosticsEngine::Level diagLevel, const clang::Diagnostic &info) override
Definition: TextDiagnosticBuffer.cpp:26