9#ifndef LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICCONSUMER_H
10#define LLVM_CLANG_FRONTEND_VERIFYDIAGNOSTICCONSUMER_H
17#include "llvm/ADT/DenseMap.h"
18#include "llvm/ADT/PointerIntPair.h"
19#include "llvm/ADT/StringRef.h"
31class TextDiagnosticBuffer;
193 static std::unique_ptr<Directive>
200 static const unsigned MaxCount = std::numeric_limits<unsigned>::max();
218 virtual bool match(StringRef S) = 0;
223 unsigned Min,
unsigned Max)
229 "DiagnosticLoc is invalid!");
262 std::unique_ptr<DiagnosticConsumer> PrimaryClientOwner;
263 std::unique_ptr<TextDiagnosticBuffer> Buffer;
264 std::unique_ptr<MarkerTracker> Markers;
268 unsigned ActiveSourceFiles = 0;
272 void CheckDiagnostics();
275 assert((!SrcManager || SrcManager == &
SM) &&
"SourceManager changed!");
280 class UnparsedFileStatus {
281 llvm::PointerIntPair<const FileEntry *, 1, bool>
Data;
284 UnparsedFileStatus(
const FileEntry *
File,
bool FoundDirectives)
287 const FileEntry *getFile()
const {
return Data.getPointer(); }
288 bool foundDirectives()
const {
return Data.getInt(); }
291 using ParsedFilesMap = llvm::DenseMap<FileID, const FileEntry *>;
292 using UnparsedFilesMap = llvm::DenseMap<FileID, UnparsedFileStatus>;
294 ParsedFilesMap ParsedFiles;
295 UnparsedFilesMap UnparsedFiles;
305 const Preprocessor *PP)
override;
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) ...
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.
ExpectedData - owns directive objects and deletes on destructor.