Go to the documentation of this file.
14 #include "llvm/ADT/SmallString.h"
15 #include "llvm/Support/ErrorHandling.h"
16 #include "llvm/Support/raw_ostream.h"
17 using namespace clang;
18 using namespace markup;
22 std::unique_ptr<raw_ostream> StreamOwner)
23 : OS(os), StreamOwner(
std::move(StreamOwner)), LangOpts(nullptr),
35 llvm_unreachable(
"Invalid DiagnosticsEngine level!");
39 LogDiagnosticPrinter::EmitDiagEntry(llvm::raw_ostream &OS,
40 const LogDiagnosticPrinter::DiagEntry &DE) {
42 OS <<
" <key>level</key>\n"
45 if (!DE.Filename.empty()) {
46 OS <<
" <key>filename</key>\n"
51 OS <<
" <key>line</key>\n"
56 OS <<
" <key>column</key>\n"
60 if (!DE.Message.empty()) {
61 OS <<
" <key>message</key>\n"
65 OS <<
" <key>ID</key>\n"
68 if (!DE.WarningOption.empty()) {
69 OS <<
" <key>WarningOption</key>\n"
88 llvm::raw_svector_ostream OS(Msg);
91 if (!MainFilename.empty()) {
92 OS <<
" <key>main-file</key>\n"
96 if (!DwarfDebugFlags.empty()) {
97 OS <<
" <key>dwarf-debug-flags</key>\n"
101 OS <<
" <key>diagnostics</key>\n";
103 for (
auto &DE : Entries)
104 EmitDiagEntry(OS, DE);
108 this->OS << OS.str();
121 if (
const FileEntry *FE =
SM.getFileEntryForID(FID))
128 DE.DiagnosticID = Info.
getID();
129 DE.DiagnosticLevel =
Level;
141 DE.Line = DE.Column = 0;
150 if (
const FileEntry *FE =
SM.getFileEntryForID(FID))
161 Entries.push_back(DE);
Level
The level of the diagnostic, after it has been through mapping.
unsigned getLine() const
Return the presumed line number of this location.
void EndSourceFile() override
Callback to inform the diagnostic client that processing of a source file has ended.
This class handles loading and caching of source files into memory.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
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.
raw_ostream & EmitInteger(raw_ostream &o, int64_t value)
const char * getFilename() const
Return the presumed filename of this location.
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.
unsigned getColumn() const
Return the presumed column number of this location.
Cached information about one file (either on disk or in the virtual file system).
bool isInvalid() const
Return true if this object is invalid or uninitialized.
LogDiagnosticPrinter(raw_ostream &OS, DiagnosticOptions *Diags, std::unique_ptr< raw_ostream > StreamOwner)
const SourceLocation & getLocation() const
raw_ostream & EmitString(raw_ostream &o, StringRef s)
SourceManager & getSourceManager() const
static StringRef getLevelName(DiagnosticsEngine::Level Level)
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
bool isValid() const
Return true if this is a valid SourceLocation object.
bool hasSourceManager() const
Represents an unpacked "presumed" location which can be presented to the user.
void FormatDiagnostic(SmallVectorImpl< char > &OutStr) const
Format this diagnostic into a string, substituting the formal arguments into the %0 slots.
static StringRef getWarningOptionForDiag(unsigned DiagID)
Return the lowest-level warning option that enables the specified diagnostic.
Options for controlling the compiler diagnostics engine.
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...