clang: lib/Frontend/LogDiagnosticPrinter.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

13#include "llvm/Support/ErrorHandling.h"

14#include "llvm/Support/raw_ostream.h"

15using namespace clang;

16using namespace markup;

17

20 std::unique_ptr<raw_ostream> StreamOwner)

21 : OS(os), StreamOwner(std::move(StreamOwner)), LangOpts(nullptr) {}

22

24 switch (Level) {

31 }

32 llvm_unreachable("Invalid DiagnosticsEngine level!");

33}

34

35void

36LogDiagnosticPrinter::EmitDiagEntry(llvm::raw_ostream &OS,

37 const LogDiagnosticPrinter::DiagEntry &DE) {

38 OS << " \n";

39 OS << " level\n"

40 << " ";

42 if (!DE.Filename.empty()) {

43 OS << " filename\n"

44 << " ";

46 }

47 if (DE.Line != 0) {

48 OS << " line\n"

49 << " ";

51 }

52 if (DE.Column != 0) {

53 OS << " column\n"

54 << " ";

56 }

57 if (!DE.Message.empty()) {

58 OS << " message\n"

59 << " ";

61 }

62 OS << " ID\n"

63 << " ";

65 if (!DE.WarningOption.empty()) {

66 OS << " WarningOption\n"

67 << " ";

68 EmitString(OS, DE.WarningOption) << '\n';

69 }

70 OS << " \n";

71}

72

74

75

76

77

78

79

80 if (Entries.empty())

81 return;

82

83

85 llvm::raw_svector_ostream OS(Msg);

86

87 OS << "\n";

88 if (!MainFilename.empty()) {

89 OS << " main-file\n"

90 << " ";

92 }

93 if (!DwarfDebugFlags.empty()) {

94 OS << " dwarf-debug-flags\n"

95 << " ";

96 EmitString(OS, DwarfDebugFlags) << '\n';

97 }

98 OS << " diagnostics\n";

99 OS << " \n";

100 for (auto &DE : Entries)

101 EmitDiagEntry(OS, DE);

102 OS << " \n";

103 OS << "\n";

104

105 this->OS << OS.str();

106}

107

110

112

113

116 FileID FID = SM.getMainFileID();

119 MainFilename = std::string(FE->getName());

120 }

121 }

122

123

124 DiagEntry DE;

125 DE.DiagnosticID = Info.getID();

126 DE.DiagnosticLevel = Level;

127

128 DE.WarningOption =

130 DE.DiagnosticID));

131

132

135 DE.Message = std::string(MessageStr);

136

137

138 DE.Filename = "";

139 DE.Line = DE.Column = 0;

143

145

149 DE.Filename = std::string(FE->getName());

150 }

151 } else {

153 DE.Line = PLoc.getLine();

155 }

156 }

157

158

159 Entries.push_back(DE);

160}

static StringRef getLevelName(DiagnosticsEngine::Level Level)

Definition LogDiagnosticPrinter.cpp:23

Defines the SourceManager interface.

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.

Options for controlling the compiler diagnostics engine.

A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...

const SourceLocation & getLocation() const

void FormatDiagnostic(SmallVectorImpl< char > &OutStr) const

Format this diagnostic into a string, substituting the formal arguments into the %0 slots.

SourceManager & getSourceManager() const

bool hasSourceManager() const

const DiagnosticsEngine * getDiags() const

Level

The level of the diagnostic, after it has been through mapping.

const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const

An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...

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.

Definition LogDiagnosticPrinter.cpp:108

void EndSourceFile() override

Callback to inform the diagnostic client that processing of a source file has ended.

Definition LogDiagnosticPrinter.cpp:73

LogDiagnosticPrinter(raw_ostream &OS, DiagnosticOptions &DiagOpts, std::unique_ptr< raw_ostream > StreamOwner)

Definition LogDiagnosticPrinter.cpp:18

Represents an unpacked "presumed" location which can be presented to the user.

unsigned getColumn() const

Return the presumed column number of this location.

const char * getFilename() const

Return the presumed filename of this location.

unsigned getLine() const

Return the presumed line number of this location.

bool isInvalid() const

Return true if this object is invalid or uninitialized.

bool isValid() const

Return true if this is a valid SourceLocation object.

This class handles loading and caching of source files into memory.

raw_ostream & EmitString(raw_ostream &o, StringRef s)

raw_ostream & EmitInteger(raw_ostream &o, int64_t value)

The JSON file list parser is used to communicate input to InstallAPI.

CustomizableOptional< FileEntryRef > OptionalFileEntryRef

nullptr

This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...