clang  6.0.0svn
TextDiagnosticBuffer.cpp
Go to the documentation of this file.
1 //===--- TextDiagnosticBuffer.cpp - Buffer Text Diagnostics ---------------===//
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 
15 #include "llvm/ADT/SmallString.h"
16 #include "llvm/Support/ErrorHandling.h"
17 using namespace clang;
18 
19 /// HandleDiagnostic - Store the errors, warnings, and notes that are
20 /// reported.
21 ///
23  const Diagnostic &Info) {
24  // Default implementation (Warnings/errors count).
26 
27  SmallString<100> Buf;
28  Info.FormatDiagnostic(Buf);
29  switch (Level) {
30  default: llvm_unreachable(
31  "Diagnostic not handled during diagnostic buffering!");
33  Notes.emplace_back(Info.getLocation(), Buf.str());
34  break;
36  Warnings.emplace_back(Info.getLocation(), Buf.str());
37  break;
39  Remarks.emplace_back(Info.getLocation(), Buf.str());
40  break;
43  Errors.emplace_back(Info.getLocation(), Buf.str());
44  break;
45  }
46 }
47 
49  // FIXME: Flush the diagnostics in order.
50  for (const_iterator it = err_begin(), ie = err_end(); it != ie; ++it)
52  << it->second;
53  for (const_iterator it = warn_begin(), ie = warn_end(); it != ie; ++it)
55  << it->second;
56  for (const_iterator it = remark_begin(), ie = remark_end(); it != ie; ++it)
58  << it->second;
59  for (const_iterator it = note_begin(), ie = note_end(); it != ie; ++it)
61  << it->second;
62 }
63 
const_iterator remark_end() const
void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) override
HandleDiagnostic - Store the errors, warnings, and notes that are reported.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1205
const_iterator err_end() const
const_iterator note_begin() const
for(const auto &A :T->param_types())
const_iterator note_end() const
const SourceLocation & getLocation() const
Definition: Diagnostic.h:1236
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:147
const_iterator err_begin() const
DiagList::const_iterator const_iterator
virtual void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info)
Handle this diagnostic, reporting it to the user or capturing it to a log as needed.
Definition: Diagnostic.cpp:435
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
Definition: Diagnostic.h:689
const_iterator warn_end() const
Dataflow Directional Tag Classes.
const_iterator warn_begin() const
Level
The level of the diagnostic, after it has been through mapping.
Definition: Diagnostic.h:150
const_iterator remark_begin() const
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
Definition: Diagnostic.h:1225
void FlushDiagnostics(DiagnosticsEngine &Diags) const
FlushDiagnostics - Flush the buffered diagnostics to an given diagnostic engine.
void FormatDiagnostic(SmallVectorImpl< char > &OutStr) const
Format this diagnostic into a string, substituting the formal arguments into the %0 slots...
Definition: Diagnostic.cpp:667