clang: include/clang/Frontend/VerifyDiagnosticConsumer.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICCONSUMER_H

10#define LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICCONSUMER_H

11

17#include "llvm/ADT/DenseMap.h"

18#include "llvm/ADT/PointerIntPair.h"

19#include "llvm/ADT/StringRef.h"

20#include

21#include

22#include

23#include

24#include

25

27

28class FileEntry;

29class LangOptions;

30class SourceManager;

31class TextDiagnosticBuffer;

32

33

34

35

36

37

40public:

41

42

44 public:

45 static std::unique_ptr

49

50 public:

51

52 static const unsigned MaxCount = std::numeric_limits::max();

53

56 const std::string Text;

60

64

65

66

67 virtual bool isValid(std::string &Error) = 0;

68

69

70 virtual bool match(StringRef S) = 0;

71

72 protected:

75 unsigned Min, unsigned Max)

81 "DiagnosticLoc is invalid!");

82 }

83 };

84

85 using DirectiveList = std::vector<std::unique_ptr>;

86

87

93

99 }

100 };

101

108

109 class MarkerTracker;

110

111private:

114 std::unique_ptr PrimaryClientOwner;

115 std::unique_ptr Buffer;

116 std::unique_ptr Markers;

117 const Preprocessor *CurrentPreprocessor = nullptr;

120 unsigned ActiveSourceFiles = 0;

123

124 void CheckDiagnostics();

125

127 assert((!SrcManager || SrcManager == &SM) && "SourceManager changed!");

128 SrcManager = &SM;

129 }

130

131

132 class UnparsedFileStatus {

134 bool FoundDirectives;

135

136 public:

138 : File(File), FoundDirectives(FoundDirectives) {}

139

141 bool foundDirectives() const { return FoundDirectives; }

142 };

143

144 using ParsedFilesMap = llvm::DenseMap<FileID, const FileEntry *>;

145 using UnparsedFilesMap = llvm::DenseMap<FileID, UnparsedFileStatus>;

146

147 ParsedFilesMap ParsedFiles;

148 UnparsedFilesMap UnparsedFiles;

149

150public:

151

152

153

156

158 const Preprocessor *PP) override;

159

161

163

165

166

168

169

172

173

175

177

180};

181

182}

183

184#endif

Defines the Diagnostic-related interfaces.

Defines the clang::FileManager interface and associated types.

Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.

Defines the clang::Preprocessor interface.

Defines the clang::SourceLocation class and associated facilities.

VerifyDiagnosticConsumer::ExpectedData ExpectedData

Abstract interface, implemented by clients of the front-end, which formats and prints fully processed...

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

Concrete class used by the front-end to report problems and issues.

Level

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

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

Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...

Engages in a tight little dance with the lexer to efficiently preprocess tokens.

Encodes a location in the source.

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

A trivial tuple used to represent a source range.

Directive - Abstract class representing a parsed verify directive.

virtual ~Directive()=default

virtual bool isValid(std::string &Error)=0

static std::unique_ptr< Directive > create(bool RegexKind, SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc, bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max)

static const unsigned MaxCount

Constant representing n or more matches.

Directive(const Directive &)=delete

virtual bool match(StringRef S)=0

Directive(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc, bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max)

Directive & operator=(const Directive &)=delete

SourceLocation DiagnosticLoc

SourceLocation DirectiveLoc

VerifyDiagnosticConsumer - Create a diagnostic client which will use markers in the input source to c...

void UpdateParsedFileStatus(SourceManager &SM, FileID FID, ParsedStatus PS)

Update lists of parsed and unparsed files.

VerifyDiagnosticConsumer(DiagnosticsEngine &Diags)

Create a new verifying diagnostic client, which will issue errors to the currently-attached diagnosti...

@ IsUnparsed

File has diagnostics and may have directives.

@ IsUnparsedNoDirectives

File has diagnostics but guaranteed no directives.

@ IsParsed

File has been processed via HandleComment.

void EndSourceFile() override

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

void BeginSourceFile(const LangOptions &LangOpts, const Preprocessor *PP) override

Callback to inform the diagnostic client that processing of a source file is beginning.

std::vector< std::unique_ptr< Directive > > DirectiveList

~VerifyDiagnosticConsumer() override

@ HasExpectedNoDiagnostics

@ HasNoDirectivesReported

@ HasOtherExpectedDirectives

bool HandleComment(Preprocessor &PP, SourceRange Comment) override

HandleComment - Hook into the preprocessor and extract comments containing expected errors and warnin...

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.

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

CustomizableOptional< FileEntryRef > OptionalFileEntryRef

ExpectedData - owns directive objects and deletes on destructor.