Back to home page

EIC code displayed by LXR

 
 

    


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

0001 //===- TextDiagnosticBuffer.h - Buffer Text Diagnostics ---------*- 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 buffers the diagnostic messages.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICBUFFER_H
0014 #define LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICBUFFER_H
0015 
0016 #include "clang/Basic/Diagnostic.h"
0017 #include "clang/Basic/SourceLocation.h"
0018 #include <cstddef>
0019 #include <string>
0020 #include <utility>
0021 #include <vector>
0022 
0023 namespace clang {
0024 
0025 class TextDiagnosticBuffer : public DiagnosticConsumer {
0026 public:
0027   using DiagList = std::vector<std::pair<SourceLocation, std::string>>;
0028   using iterator = DiagList::iterator;
0029   using const_iterator = DiagList::const_iterator;
0030 
0031 private:
0032   DiagList Errors, Warnings, Remarks, Notes;
0033 
0034   /// All - All diagnostics in the order in which they were generated.  That
0035   /// order likely doesn't correspond to user input order, but it at least
0036   /// keeps notes in the right places.  Each pair in the vector is a diagnostic
0037   /// level and an index into the corresponding DiagList above.
0038   std::vector<std::pair<DiagnosticsEngine::Level, size_t>> All;
0039 
0040 public:
0041   const_iterator err_begin() const { return Errors.begin(); }
0042   const_iterator err_end() const { return Errors.end(); }
0043 
0044   const_iterator warn_begin() const { return Warnings.begin(); }
0045   const_iterator warn_end() const { return Warnings.end(); }
0046 
0047   const_iterator remark_begin() const { return Remarks.begin(); }
0048   const_iterator remark_end() const { return Remarks.end(); }
0049 
0050   const_iterator note_begin() const { return Notes.begin(); }
0051   const_iterator note_end() const { return Notes.end(); }
0052 
0053   void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
0054                         const Diagnostic &Info) override;
0055 
0056   /// FlushDiagnostics - Flush the buffered diagnostics to an given
0057   /// diagnostic engine.
0058   void FlushDiagnostics(DiagnosticsEngine &Diags) const;
0059 };
0060 
0061 } // namespace clang
0062 
0063 #endif // LLVM_CLANG_FRONTEND_TEXTDIAGNOSTICBUFFER_H